ansible/roles/networking/tasks/main.yml

83 lines
2 KiB
YAML
Raw Permalink Normal View History

2021-04-22 23:39:58 +02:00
---
2021-07-10 02:39:21 +02:00
- name: Install ifupdown2
apt:
name:
- ifupdown2
state: latest
update_cache: true
register: apt_result
retries: 3
until: apt_result is succeeded
2021-07-10 02:39:21 +02:00
when: ansible_facts["lsb"]["id"] == "Debian"
2021-07-11 02:55:12 +02:00
- name: Install bridge-utils
apt:
name:
- bridge-utils
state: latest
update_cache: true
register: apt_result
retries: 3
until: apt_result is succeeded
when: (ansible_facts["lsb"]["id"] == "Debian") and
(lookup('dict', interfaces, wantlist=True) | selectattr('value.bridge', 'defined') | selectattr('value.bridge') | list)
2021-04-22 23:39:58 +02:00
- name: Enable ipv4 forwarding
ansible.posix.sysctl:
name: net.ipv4.ip_forward
value: '1'
sysctl_set: true
2021-04-23 00:44:49 +02:00
when: ipv4_forwarding
2021-04-22 23:39:58 +02:00
- name: Enable ipv6 forwarding
ansible.posix.sysctl:
name: net.ipv6.conf.all.forwarding
value: '1'
sysctl_set: true
2021-04-23 00:44:49 +02:00
when: ipv6_forwarding
- name: Disable ipv4 forwarding
ansible.posix.sysctl:
name: net.ipv4.ip_forward
value: '0'
sysctl_set: true
when: not ipv4_forwarding
- name: Disable ipv6 forwarding
ansible.posix.sysctl:
name: net.ipv6.conf.all.forwarding
value: '0'
sysctl_set: true
when: not ipv6_forwarding
- name: Create interface config files
ansible.builtin.template:
2021-07-08 01:54:10 +02:00
src: "debian_interfaces.j2"
dest: "/etc/network/interfaces"
owner: root
group: root
mode: '644'
notify: Reload network interfaces debian
2021-07-08 01:54:10 +02:00
when: ansible_facts["lsb"]["id"] == "Debian"
2021-07-08 02:13:11 +02:00
- name: Create dhcpcd config files
ansible.builtin.template:
src: "raspbian_dhcpcd.conf.j2"
dest: "/etc/dhcpcd.conf"
owner: root
group: netdev
mode: '664'
notify: Restart dhcpcd raspbian
when: ansible_facts["lsb"]["id"] == "Raspbian"
2021-07-10 02:39:21 +02:00
- name: Create netplan config files
ansible.builtin.template:
src: "ubuntu_00-installer-config.yaml.j2"
dest: "/etc/netplan/00-installer-config.yaml"
owner: root
group: root
mode: '644'
notify: Apply netplan ubuntu
when: ansible_facts["lsb"]["id"] == "Ubuntu"