Configure additional network interfaces in Ubuntu.
This commit is contained in:
parent
5250c17d18
commit
61c5a0a528
|
@ -25,6 +25,11 @@ sysctl_custom_options: []
|
||||||
# sysctl_reload: '{{ sysctl_opts_reload }}'
|
# sysctl_reload: '{{ sysctl_opts_reload }}'
|
||||||
# sysctlfile_state: '{{ sysctl_custom_file_state }}'
|
# sysctlfile_state: '{{ sysctl_custom_file_state }}'
|
||||||
|
|
||||||
|
ubuntu_configure_additional_interfaces: true
|
||||||
|
ubuntu_netplan_interfaces:
|
||||||
|
- name: "enp8s0"
|
||||||
|
dhcp4: true
|
||||||
|
mtu: "{{ ansible_enp8s0.mtu }}"
|
||||||
disable_ipv6: false
|
disable_ipv6: false
|
||||||
ipv6_sysctl_value: 1
|
ipv6_sysctl_value: 1
|
||||||
ipv6_sysctl_file: /etc/sysctl.d/10-ipv6-disable.conf
|
ipv6_sysctl_file: /etc/sysctl.d/10-ipv6-disable.conf
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
---
|
---
|
||||||
# handlers file for ansible-role-template
|
- name: Netplan Apply
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: netplan Apply
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
ansible.builtin.import_tasks: timezone.yml
|
ansible.builtin.import_tasks: timezone.yml
|
||||||
- name: Sysctl kernel parameters
|
- name: Sysctl kernel parameters
|
||||||
ansible.builtin.import_tasks: sysctl.yml
|
ansible.builtin.import_tasks: sysctl.yml
|
||||||
|
- name: Additional network interface(s)
|
||||||
|
ansible.builtin.import_tasks:
|
||||||
|
- network-interfaces.yml
|
||||||
- name: Create a directory that will contain the local generated certificates
|
- name: Create a directory that will contain the local generated certificates
|
||||||
ansible.builtin.import_tasks: pki_dir.yml
|
ansible.builtin.import_tasks: pki_dir.yml
|
||||||
- name: Self signed certificates waiting for the letsencrypt ones
|
- name: Self signed certificates waiting for the letsencrypt ones
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
---
|
||||||
|
- name: network-interfaces | Manage additional network interfaces, Ubuntu style
|
||||||
|
tags:
|
||||||
|
- network_interface
|
||||||
|
- networking
|
||||||
|
when:
|
||||||
|
- ansible_distribution == 'Ubuntu'
|
||||||
|
- ubuntu_configure_additional_interfaces
|
||||||
|
block:
|
||||||
|
- name: network-interfaces | Check if netplan is in use
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: /etc/netplan
|
||||||
|
register: netplan_in_use
|
||||||
|
- name: network-interfaces | Check if additional interfaces have been defined
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
net_ints: "{% for i in ansible_interfaces %}{% if i != ansible_lo.device or i != ansible_default_ipv4.interface %}{{ i }}{% if not loop.last %},{% endif %}{% endfor %}"
|
||||||
|
when: netplan_in_use.stat.isdir
|
||||||
|
- name: network-interfaces | Create a dictionary of additional interfaces
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
new_ints: "[{% for i in ansible_interfaces %}{% if i != ansible_lo.device or i != ansible_default_ipv4.interface %}{{ i }}{% if not loop.last %},{% endif %}{% endfor %}]"
|
||||||
|
when: net_ints is not defined or net_ints == None or net_ints | length == 0
|
||||||
|
- name: network-interfaces | Install the network interface file
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: 70-ansible.yaml.j2
|
||||||
|
dest: /etc/netplan/70-ansible.yaml
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
when: net_ints is not defined or net_ints == None or net_ints | length == 0
|
||||||
|
notify: Netplan Apply
|
|
@ -0,0 +1,7 @@
|
||||||
|
network:
|
||||||
|
version: 2
|
||||||
|
ethernets:
|
||||||
|
{% for int in ubuntu_netplan_interfaces %}
|
||||||
|
{{ int.name }}:
|
||||||
|
dhcp4: {{ int.dhcp4 }}
|
||||||
|
mtu: {{ int.mtu }}
|
Loading…
Reference in New Issue