Commit b6baded8 authored by Pietsch, Martin's avatar Pietsch, Martin

added new system variables system_resolver_info and system_default_gateways

parent d8342502
......@@ -28,7 +28,7 @@
path: "/etc/rc.conf"
register: bfnetstrc
- name: set static ipv4 network interfaces
- name: set static IPv4 network interfaces
lineinfile:
dest: "/etc/rc.conf"
line: "{{ 'ifconfig_%s=\"inet %s netmask %s\"' | format(item.key, item.value.ipv4, '%s/%s' | format(item.value.ipv4, network.classes[item.value.class].ipv4.prefix) | ipaddr('netmask')) }}"
......@@ -37,7 +37,7 @@
when: not (item.value.ipv4 | default(False) | ip_in_range('%s-%s' | format(dhcp_ranges[item.value.class].ipv4.from, dhcp_ranges[item.value.class].ipv4.to))) and item.value.ipv4 is defined
with_dict: "{{ network.devices }}"
- name: set dynamic ipv4 network interfaces
- name: set dynamic IPv4 network interfaces
lineinfile:
dest: "/etc/rc.conf"
line: "{{ 'ifconfig_%s=\"SYNCDHCP\"' | format(item.key) }}"
......@@ -46,16 +46,15 @@
when: (item.value.ipv4 | default(False) | ip_in_range('%s-%s' | format(dhcp_ranges[item.value.class].ipv4.from, dhcp_ranges[item.value.class].ipv4.to))) and item.value.ipv4 is defined
with_dict: "{{ network.devices }}"
- name: set ipv4 default gateway
- name: set IPv4 default gateway
lineinfile:
dest: "/etc/rc.conf"
line: "{{ 'defaultgateway=\"%s\"' | format(item.value.ipv4.gateway) }}"
line: "{{ 'defaultgateway=\"%s\"' | format(system_default_gateways['ipv4']) }}"
regexp: "^defaultgateway="
create: yes
when: (item.value.default | default(False)) == True and item.value.ipv6 is defined
with_dict: "{{ network.classes }}"
when: system_default_gateways.ipv4 is defined
- name: set static ipv6 network interfaces
- name: set static IPv6 network interfaces
lineinfile:
dest: "/etc/rc.conf"
line: "{{ 'ifconfig_%s_ipv6=\"inet6 %s prefixlen %s\"' | format(item.key, item.value.ipv6, network.classes[item.value.class].ipv6.prefix) }}"
......@@ -64,7 +63,7 @@
when: not (item.value.ipv6 | default(False) | ip_in_range('%s-%s' | format(dhcp_ranges[item.value.class].ipv6.from, dhcp_ranges[item.value.class].ipv6.to))) and item.value.ipv6 is defined
with_dict: "{{ network.devices }}"
- name: set dynamic ipv6 network interfaces
- name: set dynamic IPv6 network interfaces
lineinfile:
dest: "/etc/rc.conf"
line: "{{ 'ifconfig_%s_ipv6=\"SYNCDHCP\"' | format(item.key) }}"
......@@ -73,14 +72,13 @@
when: (item.value.ipv6 | default(False) | ip_in_range('%s-%s' | format(dhcp_ranges[item.value.class].ipv6.from, dhcp_ranges[item.value.class].ipv6.to))) and item.value.ipv6 is defined
with_dict: "{{ network.devices }}"
- name: set ipv6 default gateway
- name: set IPv6 default gateway
lineinfile:
dest: "/etc/rc.conf"
line: "{{ 'defaultgateway_ipv6=\"%s\"' | format(item.value.ipv6.gateway) }}"
line: "{{ 'defaultgateway_ipv6=\"%s\"' | format(system_default_gateways['ipv6']) }}"
regexp: "^defaultgateway_ipv6="
create: yes
when: (item.value.default | default(False)) == True and item.value.ipv6 is defined
with_dict: "{{ network.classes }}"
when: system_default_gateways.ipv6 is defined
- set_fact:
natifs: []
......@@ -151,36 +149,37 @@
state: restarted
when: afnetstrc.stat.checksum != bfnetstrc.stat.checksum
- name: configure DNS search domains
lineinfile:
- name: create temporary resolv.conf
file:
path: /etc/resolv.conf.new
line: "{{ 'search %s' | format(item.value.dns.domain) }}"
create: yes
when: (item.value.dns | default({})).domain is defined
with_dict: "{{ network.classes }}"
state: touch
- name: configure DNS name server
- name: set DNS search domains in temporary resolv.conf
lineinfile:
path: /etc/resolv.conf.new
line: "{{ 'nameserver %s %s' | format(item.value.dns.nameservers.ipv4 | default(''), item.value.dns.nameservers.ipv6 | default('')) }}"
when: ((item.value.dns | default({})).nameservers | default({})).ipv4 is defined or ((item.value.dns | default({})).nameservers | default({})).ipv6 is defined
with_dict: "{{ network.classes }}"
line: "{{ 'search %s' | format(_dnsdoms) }}"
loop: "{{ system_resolver_info.domains }}"
loop_control:
loop_var: _dnsdoms
- name: publish new DNS configuration
stat:
- name: set DNS nameservers in temporary resolv.conf
lineinfile:
path: /etc/resolv.conf.new
register: rsvst
line: "{{ 'nameserver %s' | format(_dnsservs) }}"
loop: "{{ system_resolver_info.servers }}"
loop_control:
loop_var: _dnsservs
- copy:
- name: replace resolv.conf by temporary resolv.conf
copy:
src: /etc/resolv.conf.new
dest: /etc/resolv.conf
remote_src: yes
when: rsvst.stat.exists == True
- file:
- name: delete temporary resolv.conf
file:
path: /etc/resolv.conf.new
state: absent
when: rsvst.stat.exists == True
- name: configure firewall
include_role:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment