mirror of
https://github.com/BluemediaGER/homelab.git
synced 2024-11-22 11:05:28 +01:00
Add role to configure systemd-networkd
This commit is contained in:
parent
6c674ff530
commit
f226b09f0a
|
@ -1,5 +1,5 @@
|
|||
ansible_ssh_private_key_file: ~/.ssh/id_rsa
|
||||
ssh_public_key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
|
||||
ssh_public_key: "{{ lookup('file', '~/.ssh/id_ed25519.pub') }}"
|
||||
|
||||
# Network config
|
||||
subnet: "192.168.6.0"
|
||||
|
|
|
@ -9,8 +9,13 @@
|
|||
roles:
|
||||
- wol-wake
|
||||
|
||||
- name: Clean up playbook execution
|
||||
- name: Clean up PXE environment
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
roles:
|
||||
- pxe-cleanup
|
||||
- pxe-cleanup
|
||||
|
||||
- name: Configure networking
|
||||
hosts: metal
|
||||
roles:
|
||||
- systemd-networkd
|
|
@ -2,9 +2,25 @@ metal:
|
|||
children:
|
||||
masters:
|
||||
hosts:
|
||||
lab-mini-1: {ansible_host: 192.168.6.21, mac: '4c:52:62:1c:bf:6c', disk: '/dev/sda'}
|
||||
lab-mini-2: {ansible_host: 192.168.6.22, mac: '4c:52:62:0f:09:6d', disk: '/dev/sda'}
|
||||
lab-mini-3: {ansible_host: 192.168.6.23, mac: '4c:52:62:0f:0a:23', disk: '/dev/sda'}
|
||||
lab-mini-1:
|
||||
ansible_host: 192.168.6.21
|
||||
mac: '4c:52:62:1c:bf:6c'
|
||||
disk: '/dev/nvme0n1'
|
||||
ansible_become_pass: '{{ vault_ansible_become_password }}'
|
||||
lab-mini-2:
|
||||
ansible_host: 192.168.6.22
|
||||
mac: '4c:52:62:0f:09:6d'
|
||||
disk: '/dev/nvme0n1'
|
||||
ansible_become_pass: '{{ vault_ansible_become_password }}'
|
||||
lab-mini-3:
|
||||
ansible_host: 192.168.6.23
|
||||
mac: '4c:52:62:0f:0a:23'
|
||||
disk: '/dev/nvme0n1'
|
||||
ansible_become_pass: '{{ vault_ansible_become_password }}'
|
||||
workers:
|
||||
hosts:
|
||||
lab-mini-4: {ansible_host: 192.168.6.24, mac: '90:1b:0e:f8:e8:af', disk: '/dev/sda'}
|
||||
lab-mini-4:
|
||||
ansible_host: 192.168.6.24
|
||||
mac: '90:1b:0e:f8:e8:af'
|
||||
disk: '/dev/nvme0n1'
|
||||
ansible_become_pass: '{{ vault_ansible_become_password }}'
|
||||
|
|
28
metal/roles/systemd-networkd/tasks/main.yaml
Normal file
28
metal/roles/systemd-networkd/tasks/main.yaml
Normal file
|
@ -0,0 +1,28 @@
|
|||
- name: "Configure systemd-networkd"
|
||||
become: true
|
||||
block:
|
||||
- name: "Render network config"
|
||||
template:
|
||||
src: default.network.j2
|
||||
dest: "/etc/systemd/network/default.network"
|
||||
mode: 0644
|
||||
|
||||
- name: "Enable systemd-networkd"
|
||||
ansible.builtin.systemd:
|
||||
name: systemd-networkd
|
||||
enabled: true
|
||||
|
||||
- name: "Remove /etc/network"
|
||||
ansible.builtin.file:
|
||||
path: /etc/network
|
||||
state: absent
|
||||
|
||||
- name: "Reboot with systemd-networkd configured"
|
||||
ansible.builtin.reboot:
|
||||
reboot_timeout: 180
|
||||
|
||||
- name: "Remove ifupdown"
|
||||
ansible.builtin.apt:
|
||||
name: ifupdown
|
||||
state: absent
|
||||
purge: true
|
|
@ -0,0 +1,7 @@
|
|||
[Match]
|
||||
MACAddress={{ hostvars[inventory_hostname]['mac'] }}
|
||||
|
||||
[Network]
|
||||
Address={{ hostvars[inventory_hostname]['ansible_host'] }}/{{ (hostvars[inventory_hostname]['ansible_host'] + '/' + netmask) | ansible.utils.ipaddr('prefix') }}
|
||||
Gateway={{ gateway }}
|
||||
DNS={{ nameserver }}
|
Loading…
Reference in a new issue