Shutdown before wake up

This commit is contained in:
Khue Doan 2021-02-08 10:09:02 +07:00
parent f5b988991c
commit bfa7fa26a8
5 changed files with 24 additions and 34 deletions

View File

@ -10,6 +10,15 @@
- SSD: 128GB
- Switch TP-Link TL-SG108
## Design
| Layer | Name | Description | Provisioner |
|-------|----------|---------------------------------------------|---------------------|
| 0 | metal | bare metal PXE boot, etcd, docker, lxd, | Ansible, PXE server |
| 1 | infra | Cloud-like infrastructure, based on KVM/LXC | Terraform |
| 2 | platform | kubernetes, vault, git, ci/cd... | Helm |
| 3 | apps | Plex, PeerTube, Nextcloud... | ArgoCD |
## Features
### Infrastructure
@ -29,7 +38,3 @@
![Pastebin](https://img.shields.io/static/v1?logo=Pastebin&logoColor=white&label=&message=Pastebin&color=02456C)
![PeerTube](https://img.shields.io/static/v1?logo=PeerTube&logoColor=white&label=&message=PeerTube&color=F1680D)
![Plex](https://img.shields.io/static/v1?logo=Plex&logoColor=white&label=&message=Plex&color=E5A00D)
## Notes
- Node hostname must be different and has proper domain (for example `node0.homelab.local`)

View File

@ -3,13 +3,14 @@
roles:
- { role: pxe-server, tag: pxe-server }
- name: Shutdown all nodes
hosts: homelab
roles:
- { role: shutdown, tag: shutdown }
ignore_unreachable: yes
- 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 }

@ -1 +1 @@
Subproject commit 028f617e4dc9018182ec8d8c9fa26dfffd56522a
Subproject commit ba467bcc4d74e37468b2a63c956ca5271f1acbbd

View File

@ -2,28 +2,7 @@
# community.general.docker_compose:
# project_src: "{{ role_path }}/files/pxe-servers"
- name: Render DHCP config
- name: Render environment file
template:
src: "dhcp/dhcpd.conf.j2"
dest: "{{ role_path }}/files/dhcp/dhcpd.conf"
- name: Render GRUB config
template:
src: "tftp/tftpboot/grub.cfg.j2"
dest: "{{ role_path }}/files/tftp/tftpboot/grub.cfg"
- name: Create directories
ansible.builtin.file:
path: "{{ role_path }}/build/{{ item.path }}"
state: directory
mode: '{{ item.mode }}'
with_community.general.filetree: "{{ role_path }}/templates"
when: item.state == 'directory'
- name: Template files (explicitly skip directories in order to use the 'src' attribute)
ansible.builtin.template:
src: '{{ item.src }}'
dest: "{{ role_path }}/build/{{ item.path }}"
mode: '{{ item.mode }}'
with_community.general.filetree: "{{ role_path }}/templates"
when: item.state == 'file'
src: "{{ role_path }}/files/.env.j2"
dest: "{{ role_path }}/files/.env"

View File

@ -1,3 +1,8 @@
- name: Unconditionally shut down the machine with all defaults
community.general.shutdown:
delay: 0
- name: Wait for the machine to shutdown
wait_for:
timeout: 30
delegate_to: localhost