2017-05-18 21:10:07 +00:00
|
|
|
---
|
2019-01-09 20:51:48 +00:00
|
|
|
- block:
|
|
|
|
- name: Set hostname
|
2020-11-23 20:42:14 +00:00
|
|
|
hostname:
|
|
|
|
name: "{{ network_hostname }}"
|
|
|
|
when: network_hostname
|
2019-01-09 20:51:48 +00:00
|
|
|
notify: __host_reboot
|
2017-05-18 21:10:07 +00:00
|
|
|
|
2019-01-09 20:51:48 +00:00
|
|
|
- name: Set hosts file
|
|
|
|
template:
|
|
|
|
src: etc/hosts.j2
|
|
|
|
dest: /etc/hosts
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
notify: __host_reboot
|
2017-05-18 21:10:07 +00:00
|
|
|
|
2019-01-09 20:51:48 +00:00
|
|
|
- name: Add network interface configuration
|
|
|
|
template:
|
|
|
|
src: etc/sysconfig/network-scrips/ifcfg.j2
|
|
|
|
dest: "/etc/sysconfig/network-scripts/ifcfg-{{ item.key }}"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
2019-08-27 20:22:41 +00:00
|
|
|
loop: "{{ network_interfaces | dict2items }}"
|
2019-01-09 20:51:48 +00:00
|
|
|
loop_control:
|
|
|
|
label: "{{ item.key }}"
|
|
|
|
when: item.key in ansible_interfaces or item.key.split(":")[0] in ansible_interfaces
|
|
|
|
notify: __network_restart
|
2017-07-14 11:24:33 +00:00
|
|
|
|
2021-12-28 16:16:57 +00:00
|
|
|
- name: Add static routes
|
|
|
|
copy:
|
|
|
|
content: "{{ item.value }}"
|
|
|
|
dest: "/etc/sysconfig/network-scripts/route-{{ item.key }}"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
loop: "{{ network_routes | dict2items }}"
|
|
|
|
loop_control:
|
|
|
|
label: "{{ item.key }}"
|
|
|
|
when: item.key in ansible_interfaces
|
|
|
|
notify: __network_restart
|
2021-12-28 16:15:48 +00:00
|
|
|
|
2019-01-09 20:51:48 +00:00
|
|
|
- name: Set dns server
|
|
|
|
template:
|
|
|
|
src: etc/resolv.conf.j2
|
|
|
|
dest: /etc/resolv.conf
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
2018-07-06 21:20:38 +00:00
|
|
|
become: True
|
2019-01-09 20:51:48 +00:00
|
|
|
become_user: root
|