-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'ipv4_forwarding'/'ipv6_forwarding' parameters, and 'global' role.
These are necessary for users of systemd 256 (or higher) to manage packet forwarding, as the existing 'ip_forward' parameter is deprecated in that version of systemd (and isn't backward compatible even if it is left in place). Closes #38.
- Loading branch information
Showing
13 changed files
with
121 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Documentation for this role can be found [here](https://kpfleming.github.io/ansible-systemd-networkd). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
systemd_root: "" | ||
suppress_reload: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
- name: reload | ||
become: true | ||
when: not suppress_reload | ||
ansible.builtin.command: | ||
argv: | ||
- networkctl | ||
- reload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
argument_specs: | ||
main: | ||
short_description: Manages systemd-networkd global configuration. | ||
description: | ||
- | | ||
This role will create (or update) a dropin file named ansible.conf in /etc/systemd/networkd.conf.d | ||
- | | ||
Sets fact named 'systemd_networkd_global_changed' to either true or false to indicate whether | ||
any changes were made. | ||
options: | ||
suppress_reload: | ||
description: Suppress the reloading of systemd-networkd if changes are made. | ||
type: bool | ||
default: false | ||
systemd_root: | ||
description: Root path of filesystem containing systemd-networkd configuration files. | ||
type: str | ||
default: "" | ||
settings: | ||
description: Settings to be applied globally. | ||
type: dict | ||
required: true | ||
options: | ||
network: | ||
description: Settings for the Network section. | ||
type: dict | ||
options: | ||
ipv4_forwarding: | ||
description: Enable IPv4 forwarding. | ||
type: bool | ||
ipv6_forwarding: | ||
description: Enable IPv6 forwarding. | ||
type: bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
galaxy_info: | ||
author: Kevin P, Fleming <[email protected]> @kpfleming:irc/libera.chat | ||
description: Role to manage gloabl configuration of systemd-networkd. | ||
license: Apache-2.0 | ||
issue_tracker_url: https://github.com/kpfleming/ansible-systemd-networkd/issues | ||
min_ansible_version: "6.0" | ||
platforms: | ||
- name: GenericLinux | ||
galaxy_tags: | ||
- systemd | ||
- network |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
- name: manage global dropin directory | ||
become: true | ||
ansible.builtin.file: | ||
path: "{{ systemd_root ~ '/etc/systemd/networkd.conf.d' }}" | ||
state: directory | ||
mode: u=rwx,g=rx,o= | ||
group: systemd-network | ||
|
||
- name: manage global configuration | ||
become: true | ||
register: _global | ||
notify: "{{ ansible_role_name ~ ' : reload' }}" | ||
ansible.builtin.template: | ||
src: networkd.conf.j2 | ||
dest: "{{ systemd_root ~ '/etc/systemd/networkd.conf.d/ansible.conf' }}" | ||
mode: u=rw,g=r,o= | ||
group: systemd-network | ||
|
||
- name: set fact to indicate result | ||
ansible.builtin.set_fact: | ||
systemd_networkd_global_changed: "{{ systemd_networkd_global_changed|default(false) or _global.changed }}" | ||
|
||
- name: run handlers if needed | ||
ansible.builtin.meta: flush_handlers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{% if "network" in settings -%} | ||
[Network] | ||
{% for arg, value in settings.network.items() if arg in network_arguments.keys() %} | ||
{% if value is string or value is integer %} | ||
{{ network_arguments[arg] }}={{ value }} | ||
{% elif value is boolean %} | ||
{{ network_arguments[arg] }}={{ value|ternary('yes','no') }} | ||
{% else %} | ||
{% for v in value %} | ||
{{ network_arguments[arg] }}={{ v }} | ||
{% endfor %} | ||
{% endif %} | ||
{% endfor %} | ||
{% endif %} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
network_arguments: {{ global_network_arguments }} |