diff --git a/defaults/main.yml b/defaults/main.yml index 794be06..99019ac 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -16,6 +16,15 @@ network_interfaces: {} # prefix: 26 # gateway: "192.168.0.1" # userctl: no +# @end + +network_routes: {} +# @var network_routes: +# network_routes: +# eth0: | +# 10.168.0.1/32 via 0.0.0.0 dev eth0 scope link +# 10.168.0.0/27 via 10.168.0.1 dev eth0 +# @end network_hosts_entries: [] # @var network_hosts_entries:example: > @@ -23,3 +32,4 @@ network_hosts_entries: [] # - hostname: myhost # fqdn: myhost.rknet.org # address: 1.2.3.4 +# @end diff --git a/tasks/config.yml b/tasks/config.yml index 44233a3..1808fae 100644 --- a/tasks/config.yml +++ b/tasks/config.yml @@ -28,6 +28,19 @@ 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