mirror of
https://github.com/BluemediaGER/homelab.git
synced 2024-11-22 19:05:29 +01:00
Compare commits
2 commits
537590d799
...
f226b09f0a
Author | SHA1 | Date | |
---|---|---|---|
Oliver Traber | f226b09f0a | ||
Oliver Traber | 6c674ff530 |
|
@ -1,5 +1,5 @@
|
||||||
ansible_ssh_private_key_file: ~/.ssh/id_rsa
|
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
|
# Network config
|
||||||
subnet: "192.168.6.0"
|
subnet: "192.168.6.0"
|
||||||
|
|
|
@ -9,8 +9,13 @@
|
||||||
roles:
|
roles:
|
||||||
- wol-wake
|
- wol-wake
|
||||||
|
|
||||||
- name: Clean up playbook execution
|
- name: Clean up PXE environment
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
roles:
|
roles:
|
||||||
- pxe-cleanup
|
- pxe-cleanup
|
||||||
|
|
||||||
|
- name: Configure networking
|
||||||
|
hosts: metal
|
||||||
|
roles:
|
||||||
|
- systemd-networkd
|
|
@ -2,9 +2,25 @@ metal:
|
||||||
children:
|
children:
|
||||||
masters:
|
masters:
|
||||||
hosts:
|
hosts:
|
||||||
lab-mini-1: {ansible_host: 192.168.6.21, mac: '4c:52:62:1c:bf:6c', disk: '/dev/sda'}
|
lab-mini-1:
|
||||||
lab-mini-2: {ansible_host: 192.168.6.22, mac: '4c:52:62:0f:09:6d', disk: '/dev/sda'}
|
ansible_host: 192.168.6.21
|
||||||
lab-mini-3: {ansible_host: 192.168.6.23, mac: '4c:52:62:0f:0a:23', disk: '/dev/sda'}
|
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:
|
workers:
|
||||||
hosts:
|
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 }}'
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
- name: Tear down PXE stack
|
- name: Tear down PXE stack
|
||||||
docker_compose:
|
ansible.builtin.command: "docker compose --project-name pxe down"
|
||||||
project_name: "pxe"
|
|
||||||
project_src: "{{ playbook_dir }}/roles/pxe-server/files/"
|
|
||||||
state: absent
|
|
||||||
|
|
||||||
- name: Remove preseed files
|
- name: Remove preseed files
|
||||||
file:
|
file:
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
os_download_url: "https://deb.debian.org/debian/dists/bullseye/main/installer-amd64/current/images/netboot/netboot.tar.gz"
|
os_download_url: "https://deb.debian.org/debian/dists/bullseye/main/installer-amd64/current/images/netboot/netboot.tar.gz"
|
||||||
os_download_checksum: "sha256:ec3b71964457f30a57061ea758c12394bf2b792b461c697e61cc2d47053c5878"
|
os_download_checksum: "sha256:e8edf26ac9837d7dbbcfd96f47f51530260a6c68568938978e1b63ea698d5663"
|
||||||
|
|
|
@ -30,9 +30,4 @@
|
||||||
loop: "{{ groups['metal'] }}"
|
loop: "{{ groups['metal'] }}"
|
||||||
|
|
||||||
- name: Start PXE stack
|
- name: Start PXE stack
|
||||||
docker_compose:
|
ansible.builtin.command: "docker compose --project-name pxe -f {{ role_path }}/files/docker-compose.yml up -d --build"
|
||||||
project_src: "{{ role_path }}/files"
|
|
||||||
project_name: "pxe"
|
|
||||||
state: present
|
|
||||||
restarted: true
|
|
||||||
build: true
|
|
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 }}
|
|
@ -5,4 +5,4 @@
|
||||||
|
|
||||||
- name: Wait for machines to come online with installed OS
|
- name: Wait for machines to come online with installed OS
|
||||||
wait_for_connection:
|
wait_for_connection:
|
||||||
timeout: 600
|
timeout: 900
|
Loading…
Reference in a new issue