Skip to content

Instantly share code, notes, and snippets.

@danehans
Last active March 9, 2016 00:15
Show Gist options
  • Select an option

  • Save danehans/7dc04f49ea220af5aaaa to your computer and use it in GitHub Desktop.

Select an option

Save danehans/7dc04f49ea220af5aaaa to your computer and use it in GitHub Desktop.
ansible_networkd_route_mgt
TASK: [Create internal networkd file] *****************
fatal: [172.22.111.161] => {'msg': "AnsibleUndefinedVariable: One or more undefined variables: 'list' object has no attribute 'split'", 'failed': True}
fatal: [172.22.111.161] => {'msg': "AnsibleUndefinedVariable: One or more undefined variables: 'list' object has no attribute 'split'", 'failed': True}
manage_internal_network: true
# Add internal routes in the form of:
# destination_network,destination_mask,next_hop_ip
# Example: - 192.168.0.0,/16,192.168.111.192
internal_routes:
- 192.168.0.0,/16,192.168.111.192
internal_interface: enp11s0
internal_ip: 192.168.111.161
internal_cidr: /24
[Match]
Name={{ internal_interface }}
[Network]
Address={{ internal_ip }}{{ internal_cidr }}
{% for route in internal_routes %}
{% set route_list = internal_routes.split(',') %}
[Route]
Destination={{ route_list[0] }}{{ route_list[1] }}
Gateway={{ route_list[2] }}
{% endfor %}
- name: Manage networkd file
template: src=networkd.j2 dest=/etc/systemd/network/{{ internal_interface }}.network
notify:
- restart systemd-networkd
- systemd-resolved
when: manage_internal_network
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment