feat: add option to set static routes
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Robert Kaussow 2021-12-28 17:15:48 +01:00
parent b252b16100
commit 7c2eb01048
Signed by: xoxys
GPG Key ID: 4E692A2EAECC03C0
2 changed files with 23 additions and 0 deletions

View File

@ -16,6 +16,15 @@ network_interfaces: {}
# prefix: 26 # prefix: 26
# gateway: "192.168.0.1" # gateway: "192.168.0.1"
# userctl: no # 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: [] network_hosts_entries: []
# @var network_hosts_entries:example: > # @var network_hosts_entries:example: >
@ -23,3 +32,4 @@ network_hosts_entries: []
# - hostname: myhost # - hostname: myhost
# fqdn: myhost.rknet.org # fqdn: myhost.rknet.org
# address: 1.2.3.4 # address: 1.2.3.4
# @end

View File

@ -28,6 +28,19 @@
when: item.key in ansible_interfaces or item.key.split(":")[0] in ansible_interfaces when: item.key in ansible_interfaces or item.key.split(":")[0] in ansible_interfaces
notify: __network_restart 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 - name: Set dns server
template: template:
src: etc/resolv.conf.j2 src: etc/resolv.conf.j2