This commit is contained in:
parent
32a3299e32
commit
73a29b0619
@ -1,10 +1,11 @@
|
||||
---
|
||||
network_hostname: localhost
|
||||
network_fqdn: localdomain
|
||||
network_defaultif: eth0
|
||||
network_ipv6_enabled: True
|
||||
network_dns_server: 8.8.8.8
|
||||
|
||||
network_reboot_enabled: True
|
||||
network_ipv6_enabled: True
|
||||
|
||||
network_defaultif: eth0
|
||||
network_interfaces: {}
|
||||
# @var network_interfaces:example: >
|
||||
# network_interfaces:
|
||||
@ -26,9 +27,13 @@ network_routes: {}
|
||||
# 10.168.0.0/27 via 10.168.0.1 dev eth0
|
||||
# @end
|
||||
|
||||
network_hosts_entries: []
|
||||
# @var network_hosts_entries:example: >
|
||||
# network_hosts_entries:
|
||||
network_resolve_enabled: False
|
||||
network_resolve_server:
|
||||
- 8.8.8.8
|
||||
|
||||
network_hosts_extra: []
|
||||
# @var network_hosts_extra:example: >
|
||||
# network_hosts_extra:
|
||||
# - hostname: myhost
|
||||
# fqdn: myhost.rknet.org
|
||||
# address: 1.2.3.4
|
||||
|
@ -1,52 +0,0 @@
|
||||
---
|
||||
- block:
|
||||
- name: Set hostname
|
||||
hostname:
|
||||
name: "{{ network_hostname }}"
|
||||
when: network_hostname
|
||||
notify: __host_reboot
|
||||
|
||||
- name: Set hosts file
|
||||
template:
|
||||
src: etc/hosts.j2
|
||||
dest: /etc/hosts
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
notify: __host_reboot
|
||||
|
||||
- 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
|
||||
loop: "{{ network_interfaces | dict2items }}"
|
||||
loop_control:
|
||||
label: "{{ item.key }}"
|
||||
when: item.key in ansible_interfaces or item.key.split(":")[0] in ansible_interfaces
|
||||
notify: __network_restart
|
||||
|
||||
- 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
|
||||
|
||||
- name: Set dns server
|
||||
template:
|
||||
src: etc/resolv.conf.j2
|
||||
dest: /etc/resolv.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
become: True
|
||||
become_user: root
|
@ -1,5 +1,57 @@
|
||||
---
|
||||
- name: Set flag require_reboot
|
||||
set_fact:
|
||||
require_reboot: "{{ True if network_fqdn != ansible_fqdn else False }}"
|
||||
- include_tasks: config.yml
|
||||
require_reboot: "{{ True if (network_fqdn != ansible_fqdn and network_reboot_enabled == True) else False }}"
|
||||
|
||||
- block:
|
||||
- name: Set hostname
|
||||
hostname:
|
||||
name: "{{ network_hostname }}"
|
||||
when: network_hostname
|
||||
notify: __host_reboot
|
||||
|
||||
- name: Write hosts file
|
||||
template:
|
||||
src: etc/hosts.j2
|
||||
dest: /etc/hosts
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
notify: __host_reboot
|
||||
|
||||
- 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
|
||||
loop: "{{ network_interfaces | dict2items }}"
|
||||
loop_control:
|
||||
label: "{{ item.key }}"
|
||||
when: item.key in ansible_interfaces or item.key.split(":")[0] in ansible_interfaces
|
||||
notify: __network_restart
|
||||
|
||||
- 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
|
||||
|
||||
- name: Set DNS servers
|
||||
template:
|
||||
src: etc/resolv.conf.j2
|
||||
dest: /etc/resolv.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
when: network_resolve_enabled | bool
|
||||
become: True
|
||||
become_user: root
|
||||
|
@ -1,14 +1,14 @@
|
||||
#jinja2: lstrip_blocks: True
|
||||
{{ ansible_managed | comment }}
|
||||
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
|
||||
127.0.0.1 localhost localhost.localdomain
|
||||
{% if network_ipv6_enabled %}
|
||||
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
|
||||
::1 localhost6 localhost6.localdomain6
|
||||
{% endif %}
|
||||
{% if network_hostname is defined and network_fqdn is defined and network_interfaces[network_defaultif].ipaddr is defined %}
|
||||
{{ network_interfaces[network_defaultif].ipaddr }} {{ network_fqdn }} {{ network_hostname }}
|
||||
{% endif %}
|
||||
{% if network_hosts_entries %}
|
||||
{% for item in network_hosts_entries %}
|
||||
{% if network_hosts_extra %}
|
||||
{% for item in network_hosts_extra %}
|
||||
{{ item.address }} {{ item.fqdn }} {{ item.hostname }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{{ ansible_managed | comment }}
|
||||
{% for item in network_dns_server %}
|
||||
{% for item in network_resolve_server %}
|
||||
nameserver {{ item }}
|
||||
{% endfor %}
|
||||
|
@ -1,6 +1,12 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
#jinja2: lstrip_blocks: True
|
||||
{{ ansible_managed | comment }}
|
||||
DEVICE="{{ item.key }}"
|
||||
{%+ for key, value in item.value.items() -%}
|
||||
{{ key | upper }}="{{ value }}"
|
||||
{% for key, value in item.value.items() %}
|
||||
{% if key | lower == "dns" and not value is string and value is iterable %}
|
||||
{% for item in value -%}
|
||||
DNS{{ loop.index }}={{ item }}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{{- key | upper }}={{ value }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
Loading…
Reference in New Issue
Block a user