You've already forked ansible-role-common
102 lines
2.9 KiB
YAML
102 lines
2.9 KiB
YAML
---
|
|
- name: What is virtualization type?
|
|
debug:
|
|
msg: "Virtualization is: {{ ansible_virtualization_type }}"
|
|
|
|
- name: Ensure Network Setup (RedHat only)
|
|
template:
|
|
src: "{{ network_config.src }}"
|
|
dest: "{{ network_config.dest }}"
|
|
mode: "{{ network_config.mode }}"
|
|
backup: yes
|
|
with_items:
|
|
- {
|
|
src: etc.sysconfig.network.j2,
|
|
dest: /etc/sysconfig/network,
|
|
mode: u+rw,
|
|
a+r,
|
|
}
|
|
when: >
|
|
ansible_virtualization_type != "docker"
|
|
and ansible_virtualization_type != "container"
|
|
and ansible_os_family == "RedHat"
|
|
loop_control:
|
|
loop_var: network_config
|
|
tags: dns
|
|
|
|
- name: Ensure Resolvers Configured
|
|
template:
|
|
src: "{{ network_config.src }}"
|
|
dest: "{{ network_config.dest }}"
|
|
mode: "{{ network_config.mode }}"
|
|
backup: yes
|
|
with_items:
|
|
- { src: etc.resolv.conf.j2, dest: /etc/resolv.conf, mode: u+rw, a+r }
|
|
when: >
|
|
ansible_virtualization_type != "docker"
|
|
and ansible_virtualization_type != "container"
|
|
loop_control:
|
|
loop_var: network_config
|
|
tags: dns
|
|
|
|
- name: Ensure hosts file correct
|
|
lineinfile:
|
|
dest: /etc/hosts
|
|
regexp: "{{ hosts_config.regexp }}"
|
|
line: "{{ hosts_config.line }}"
|
|
backrefs: yes
|
|
backup: yes
|
|
with_items:
|
|
- {
|
|
regexp: "^127.0.0.1.+localdomain4$",
|
|
line: "127.0.0.1 localhost {{ inventory_hostname }}",
|
|
}
|
|
- {
|
|
regexp: "^::1.+localdomain6$",
|
|
line: "::1 localhost {{ inventory_hostname }}",
|
|
}
|
|
- {
|
|
regexp: "^{{ ansible_default_ipv4.address }}.*{{ ansible_default_ipv4.address.split('.')[-1] }}$",
|
|
line: "{{ ansible_default_ipv4.address }} {{ inventory_hostname }}.{{ domain }} {{ inventory_hostname }}",
|
|
}
|
|
- {
|
|
regexp: "^127.0.0.1.+{{ ansible_nodename.split('.')[0] }}$",
|
|
line: "127.0.0.1 localhost {{ inventory_hostname }}",
|
|
}
|
|
- {
|
|
regexp: "^::1.+{{ ansible_nodename.split('.')[0] }}$",
|
|
line: "::1 localhost {{ inventory_hostname }}",
|
|
}
|
|
- {
|
|
regexp: "^{{ ansible_default_ipv4.address }}.*{{ ansible_nodename.split('.')[0] }}$",
|
|
line: "{{ ansible_default_ipv4.address }} {{ inventory_hostname }}.{{ domain }} {{ inventory_hostname }}",
|
|
}
|
|
loop_control:
|
|
loop_var: hosts_config
|
|
when: ansible_virtualization_type != "docker" and ansible_virtualization_type != "container"
|
|
|
|
- name: Ensure NetworkManager does not fiddle DNS
|
|
ini_file:
|
|
dest: /etc/NetworkManager/NetworkManager.conf
|
|
section: "main"
|
|
option: "dns"
|
|
value: "none"
|
|
backup: yes
|
|
when: (ansible_os_family == "RedHat" and ansible_distribution_major_version == "7")
|
|
notify:
|
|
- Restart NetworkManager
|
|
changed_when: false
|
|
|
|
- name: Ensure correct permissions (hosts/resolv.conf)
|
|
file:
|
|
path: "{{ perm_config }}"
|
|
state: touch
|
|
mode: u+rw,g+r,a+r
|
|
with_items:
|
|
- /etc/resolv.conf
|
|
- /etc/hosts
|
|
loop_control:
|
|
loop_var: perm_config
|
|
changed_when: false
|
|
tags: dns
|