Skip to content

Commit

Permalink
netplan_loopback
Browse files Browse the repository at this point in the history
  • Loading branch information
james-otten committed Dec 29, 2024
1 parent e4e622e commit 41e2c1f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions roles/.ansible-lint-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
certbot_rfc2136/tasks/main.yml no-changed-when
netplan_loopback/tasks/main.yml no-changed-when
14 changes: 14 additions & 0 deletions roles/netplan_loopback/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
- name: Fail if netplan_loopback_ips is not provided
ansible.builtin.fail:
msg: The variable netplan_loopback_ips was not provided
when: not ((netplan_loopback_ips is defined) and (netplan_loopback_ips|length > 0))

- name: Setup IPs on lo interface
ansible.builtin.template:
src: netplan_loopback.yaml.j2
dest: /etc/netplan/lo.yaml
mode: "600"

- name: Netplan apply
ansible.builtin.command:
cmd: "netplan apply"
11 changes: 11 additions & 0 deletions roles/netplan_loopback/templates/netplan_loopback.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
network:
version: 2
renderer: networkd
ethernets:
lo:
dhcp4: no
dhcp6: no
addresses:
{% for ip in netplan_loopback_ips.split(';') %}
- {{ ip }}/32
{% endfor %}

0 comments on commit 41e2c1f

Please sign in to comment.