Merge "Allow networkd filename override"

This commit is contained in:
Zuul 2018-03-21 03:08:45 +00:00 committed by Gerrit Code Review
commit 0cd72804e9
3 changed files with 13 additions and 4 deletions

View File

@ -19,6 +19,10 @@ systemd_interface_cleanup: false
# Enable systemd-networkd and (re)start the service
systemd_run_networkd: false
# Default filename formatting
systemd_networkd_netdev_filename: "{{ item.0 }}-{{ item.1.NetDev.Name }}.netdev"
systemd_networkd_network_filename: "{{ item.0 }}-{{ item.1.interface }}.network"
# The `systemd_link_config_overrides` option can be used on the default link.
# See the following link for all available options:
# https://www.freedesktop.org/software/systemd/man/systemd.link.html
@ -41,6 +45,7 @@ systemd_link_config_overrides: {}
# - NetDev:
# Name: dummy1
# Kind: dummy
# filename: "{{ item.1.NetDev.Name }}.netdev"
# - NetDev:
# Name: bond0
# Kind: bond
@ -84,6 +89,7 @@ systemd_netdevs: []
# bridge: "bond0"
# mtu: 9000
# - interface: "dummy1"
# filename: "{{ item.1.interface }}.network"
# bridge: "bond0"
# mtu: 9000
# - interface: "bond0"

View File

@ -55,7 +55,7 @@
- name: Create systemd-networkd network device(s)
template:
src: "systemd-netdev.j2"
dest: "/etc/systemd/network/{{ item.0 }}-{{ item.1.NetDev.Name }}.netdev"
dest: "/etc/systemd/network/{{ item.1.filename | default(systemd_networkd_netdev_filename) }}"
owner: "root"
group: "root"
mode: "0644"
@ -66,7 +66,7 @@
- name: Create systemd-networkd network(s)
config_template:
src: "systemd-network.j2"
dest: "/etc/systemd/network/{{ item.0 }}-{{ item.1.interface }}.network"
dest: "/etc/systemd/network/{{ item.1.filename | default(systemd_networkd_network_filename) }}"
owner: "root"
group: "root"
mode: "0644"

View File

@ -1,9 +1,12 @@
# {{ ansible_managed }}
{% set _ignored_sections = ['filename'] %}
{% for key, values in item.1.items() %}
{% if key not in _ignored_sections %}
[{{ key }}]
{% for k, v in values.items() %}
{% for k, v in values.items() %}
{{ k }}={{ v }}
{% endfor %}
{% endfor %}
{% endif %}
{% endfor %}