mirror of
https://github.com/khuedoan/homelab.git
synced 2025-02-02 04:14:28 +07:00
Provision bare metal with Ansible
This commit is contained in:
parent
b4c0a0b1d1
commit
b44b6c0860
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
.venv/
|
||||
target/
|
||||
|
||||
*.log
|
||||
|
13
metal/Makefile
Normal file
13
metal/Makefile
Normal file
@ -0,0 +1,13 @@
|
||||
.POSIX:
|
||||
|
||||
default: init run
|
||||
|
||||
init:
|
||||
python3 -m venv .venv \
|
||||
&& . .venv/bin/activate \
|
||||
&& pip3 install --upgrade pip \
|
||||
&& pip3 install -r requirements.txt
|
||||
|
||||
run:
|
||||
. .venv/bin/activate \
|
||||
&& ansible-playbook --inventory hosts.ini playbook.yml
|
5
metal/hosts.ini
Normal file
5
metal/hosts.ini
Normal file
@ -0,0 +1,5 @@
|
||||
[homelab]
|
||||
192.168.1.110 mac='00:23:24:d1:f3:f0' ansible_user=root
|
||||
192.168.1.111 mac='00:23:24:d1:f4:d6' ansible_user=root
|
||||
192.168.1.112 mac='00:23:24:e7:04:60' ansible_user=root
|
||||
192.168.1.113 mac='00:23:24:d1:f5:69' ansible_user=root
|
15
metal/playbook.yml
Normal file
15
metal/playbook.yml
Normal file
@ -0,0 +1,15 @@
|
||||
- name: Start PXE server on the controller
|
||||
hosts: localhost
|
||||
roles:
|
||||
- { role: pxe, tag: pxe }
|
||||
|
||||
- name: Wake all nodes up
|
||||
hosts: homelab
|
||||
gather_facts: no
|
||||
roles:
|
||||
- { role: wake, tag: wake }
|
||||
|
||||
# - name: Shutdown all nodes
|
||||
# hosts: homelab
|
||||
# roles:
|
||||
# - { role: shutdown, tag: shutdown }
|
3
metal/requirements.txt
Normal file
3
metal/requirements.txt
Normal file
@ -0,0 +1,3 @@
|
||||
ansible
|
||||
docker
|
||||
docker-compose
|
3
metal/roles/pxe/tasks/main.yml
Normal file
3
metal/roles/pxe/tasks/main.yml
Normal file
@ -0,0 +1,3 @@
|
||||
- name: Start PXE server
|
||||
community.general.docker_compose:
|
||||
project_src: /home/khuedoan/Documents/lab/homelab/infra/pxe-server
|
3
metal/roles/shutdown/tasks/main.yml
Normal file
3
metal/roles/shutdown/tasks/main.yml
Normal file
@ -0,0 +1,3 @@
|
||||
- name: Unconditionally shut down the machine with all defaults
|
||||
community.general.shutdown:
|
||||
delay: 0
|
8
metal/roles/wake/tasks/main.yml
Normal file
8
metal/roles/wake/tasks/main.yml
Normal file
@ -0,0 +1,8 @@
|
||||
- name: Send magic Wake-on-LAN packet
|
||||
community.general.wakeonlan:
|
||||
mac: "{{ hostvars[inventory_hostname]['mac'] }}"
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Wait for the servers to comes up
|
||||
wait_for_connection:
|
||||
timeout: 600
|
Loading…
Reference in New Issue
Block a user