configure netplan (#610)
Reviewed-on: #610 Co-authored-by: Michael Grote <michael.grote@posteo.de> Co-committed-by: Michael Grote <michael.grote@posteo.de>
This commit is contained in:
parent
92eb30ccb3
commit
4a507b9dc6
10 changed files with 59 additions and 0 deletions
|
@ -7,6 +7,9 @@ file_header: |
|
||||||
# This file is managed with ansible! #
|
# This file is managed with ansible! #
|
||||||
#----------------------------------------------------------------#
|
#----------------------------------------------------------------#
|
||||||
|
|
||||||
|
### mgrote_netplan
|
||||||
|
netplan_configure: true
|
||||||
|
|
||||||
### mgrote.restic
|
### mgrote.restic
|
||||||
restic_user: root
|
restic_user: root
|
||||||
restic_group: restic
|
restic_group: restic
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
---
|
---
|
||||||
|
### mgrote_netplan
|
||||||
|
netplan_configure: false
|
||||||
|
|
||||||
### mgrote.postfix
|
### mgrote.postfix
|
||||||
postfix_erlaubte_netzwerke: "127.0.0.0/8 192.168.2.0/24 192.168.3.0/24"
|
postfix_erlaubte_netzwerke: "127.0.0.0/8 192.168.2.0/24 192.168.3.0/24"
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
---
|
---
|
||||||
|
### mgrote_netplan
|
||||||
|
netplan_configure: false
|
||||||
|
|
||||||
### mgrote.restic
|
### mgrote.restic
|
||||||
restic_folders_to_backup: "/ /etc/pve"
|
restic_folders_to_backup: "/ /etc/pve"
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
- role: mgrote_users
|
- role: mgrote_users
|
||||||
tags: "user"
|
tags: "user"
|
||||||
become: true
|
become: true
|
||||||
|
- role: mgrote_netplan
|
||||||
|
tags: "netplan"
|
||||||
|
|
||||||
post_tasks:
|
post_tasks:
|
||||||
- name: Change user password
|
- name: Change user password
|
||||||
|
|
|
@ -20,3 +20,5 @@
|
||||||
# $manage_lvm gehört zu dieser Rolle, wird aber extra abgefragt um das PLaybook zu "aktivieren"
|
# $manage_lvm gehört zu dieser Rolle, wird aber extra abgefragt um das PLaybook zu "aktivieren"
|
||||||
- role: mgrote_ssh
|
- role: mgrote_ssh
|
||||||
tags: "ssh"
|
tags: "ssh"
|
||||||
|
- role: mgrote_netplan
|
||||||
|
tags: "netplan"
|
||||||
|
|
2
roles/mgrote_netplan/defaults/main.yml
Normal file
2
roles/mgrote_netplan/defaults/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
netplan_configure: false # this role dos nothing if this variable is false or the os is not ubuntu
|
4
roles/mgrote_netplan/handlers/main.yml
Normal file
4
roles/mgrote_netplan/handlers/main.yml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
- name: netplan apply # noqa no-changed-when
|
||||||
|
become: true
|
||||||
|
ansible.builtin.command: netplan apply
|
6
roles/mgrote_netplan/tasks/main.yml
Normal file
6
roles/mgrote_netplan/tasks/main.yml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
- name: Include tasks only when the OS is Ubuntu
|
||||||
|
ansible.builtin.include_tasks: netplan.yml
|
||||||
|
when:
|
||||||
|
- "'Ubuntu' in ansible_distribution"
|
||||||
|
- netplan_configure is true
|
27
roles/mgrote_netplan/tasks/netplan.yml
Normal file
27
roles/mgrote_netplan/tasks/netplan.yml
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
---
|
||||||
|
- name: Install netplan
|
||||||
|
become: true
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name:
|
||||||
|
- netplan.io
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Template netplan-config
|
||||||
|
become: true
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: 10_config.yml.j2
|
||||||
|
dest: /etc/netplan/00-installer-config.yaml
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: '0400'
|
||||||
|
notify: netplan apply
|
||||||
|
|
||||||
|
- name: Ensure default config is absent
|
||||||
|
become: true
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "/etc/netplan/{{ item }}"
|
||||||
|
state: absent
|
||||||
|
notify: netplan apply
|
||||||
|
loop:
|
||||||
|
- 10_config.yml
|
||||||
|
- 01-netcfg.yaml
|
7
roles/mgrote_netplan/templates/10_config.yml.j2
Normal file
7
roles/mgrote_netplan/templates/10_config.yml.j2
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{{ file_header | default () }}
|
||||||
|
network:
|
||||||
|
version: 2
|
||||||
|
renderer: networkd
|
||||||
|
ethernets:
|
||||||
|
{{ ansible_default_ipv4.interface }}:
|
||||||
|
dhcp4: yes
|
Loading…
Reference in a new issue