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:
Michael Grote 2023-11-24 14:11:59 +01:00 committed by mg
parent 92eb30ccb3
commit 4a507b9dc6
10 changed files with 59 additions and 0 deletions

View file

@ -7,6 +7,9 @@ file_header: |
# This file is managed with ansible! #
#----------------------------------------------------------------#
### mgrote_netplan
netplan_configure: true
### mgrote.restic
restic_user: root
restic_group: restic

View file

@ -1,4 +1,7 @@
---
### mgrote_netplan
netplan_configure: false
### mgrote.postfix
postfix_erlaubte_netzwerke: "127.0.0.0/8 192.168.2.0/24 192.168.3.0/24"

View file

@ -1,4 +1,7 @@
---
### mgrote_netplan
netplan_configure: false
### mgrote.restic
restic_folders_to_backup: "/ /etc/pve"

View file

@ -13,6 +13,8 @@
- role: mgrote_users
tags: "user"
become: true
- role: mgrote_netplan
tags: "netplan"
post_tasks:
- name: Change user password

View file

@ -20,3 +20,5 @@
# $manage_lvm gehört zu dieser Rolle, wird aber extra abgefragt um das PLaybook zu "aktivieren"
- role: mgrote_ssh
tags: "ssh"
- role: mgrote_netplan
tags: "netplan"

View file

@ -0,0 +1,2 @@
---
netplan_configure: false # this role dos nothing if this variable is false or the os is not ubuntu

View file

@ -0,0 +1,4 @@
---
- name: netplan apply # noqa no-changed-when
become: true
ansible.builtin.command: netplan apply

View 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

View 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

View file

@ -0,0 +1,7 @@
{{ file_header | default () }}
network:
version: 2
renderer: networkd
ethernets:
{{ ansible_default_ipv4.interface }}:
dhcp4: yes