mirror of
https://github.com/khuedoan/homelab.git
synced 2025-01-05 21:11:52 +07:00
Rework role structure
This commit is contained in:
parent
472003d94b
commit
e6341de6e7
@ -1,12 +1,5 @@
|
||||
iso_url: "https://mirrors.nhanhoa.com/centos/8.3.2011/isos/x86_64/CentOS-8.3.2011-x86_64-dvd1.iso"
|
||||
|
||||
subnet: "192.168.1.0"
|
||||
netmask: "255.255.255.0"
|
||||
gateway: "192.168.1.1"
|
||||
range_start: "192.168.1.11"
|
||||
range_end: "192.168.1.99"
|
||||
pxe_server: "192.168.1.19"
|
||||
dns: "8.8.8.8"
|
||||
network_device: "eno1"
|
||||
disk: "sda"
|
||||
network_interface: "eno1"
|
||||
ssh_public_key: "{{lookup('file', '~/.ssh/id_rsa.pub') }}"
|
||||
|
@ -9,4 +9,3 @@ metal3 ansible_host=192.168.1.113 mac='00-23-24-d1-f5-69'
|
||||
|
||||
[metal:vars]
|
||||
ansible_user=root
|
||||
subnet=192.168.1.0/24
|
||||
|
@ -1,18 +0,0 @@
|
||||
- name: Add remote
|
||||
command:
|
||||
argv:
|
||||
- lxc
|
||||
- remote
|
||||
- add
|
||||
- vagrant
|
||||
- "{{ hostvars[groups['metal'][0]]['ansible_host'] }}"
|
||||
- --accept-certificate
|
||||
- --password
|
||||
- 1
|
||||
- name: Change default remote
|
||||
command:
|
||||
argv:
|
||||
- lxc
|
||||
- remote
|
||||
- switch
|
||||
- vagrant
|
@ -1,5 +0,0 @@
|
||||
ETCDV3_USERNAME={{ etcd_username }}
|
||||
ETCDV3_PASSWORD={{ etcd_password }}
|
||||
|
||||
LXD_ADDR={{ hostvars[groups['metal'][0]]['ansible_host'] }}
|
||||
LXD_PASSWORD= {{ lxd_password }}
|
@ -1,3 +1,7 @@
|
||||
- name: Disable SELinux
|
||||
selinux:
|
||||
state: disabled
|
||||
|
||||
- name: Install LXD
|
||||
snap:
|
||||
name: lxd
|
||||
@ -22,3 +26,23 @@
|
||||
stdin: "{{ lookup('template', 'member.yaml.j2') }}"
|
||||
creates: /var/snap/lxd/common/lxd/server.crt
|
||||
when: inventory_hostname != groups['metal'][0]
|
||||
|
||||
- name: Add remote
|
||||
command:
|
||||
argv:
|
||||
- lxc
|
||||
- remote
|
||||
- add
|
||||
- vagrant
|
||||
- "{{ hostvars[groups['metal'][0]]['ansible_host'] }}"
|
||||
- --accept-certificate
|
||||
- --password
|
||||
- 1
|
||||
|
||||
- name: Change default remote
|
||||
command:
|
||||
argv:
|
||||
- lxc
|
||||
- remote
|
||||
- switch
|
||||
- vagrant
|
||||
|
@ -4,7 +4,7 @@ config:
|
||||
networks:
|
||||
- config:
|
||||
bridge.mode: fan
|
||||
fan.underlay_subnet: {{ hostvars[inventory_hostname]['subnet'] }}
|
||||
fan.underlay_subnet: {{ hostvars[inventory_hostname]['lxd_subnet'] }}
|
||||
description: ""
|
||||
name: lxdfan0
|
||||
type: ""
|
||||
|
@ -7,10 +7,10 @@
|
||||
- "{{ role_path }}/build/images"
|
||||
- "{{ role_path }}/build/mnt"
|
||||
|
||||
- name: Download ISO
|
||||
get_url:
|
||||
url: "{{ iso_url }}"
|
||||
dest: "{{ role_path }}/build/images/centos8.iso"
|
||||
# - name: Download ISO
|
||||
# get_url:
|
||||
# url: "{{ iso_url }}"
|
||||
# dest: "{{ role_path }}/build/images/centos8.iso"
|
||||
|
||||
- name: Mount the ISO
|
||||
mount:
|
||||
@ -52,3 +52,21 @@
|
||||
project_src: "{{ role_path }}/build"
|
||||
build: yes
|
||||
delegate_to: localhost
|
||||
|
||||
- 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
|
||||
|
||||
- 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
|
@ -1,5 +1,5 @@
|
||||
%pre --interpreter=/bin/sh
|
||||
mac=$(ip --brief link show dev {{ network_device }} | tr -s ' ' | cut -d ' ' -f 3 | sed 's/:/-/g')
|
||||
mac=$(ip --brief link show dev {{ network_interface }} | tr -s ' ' | cut -d ' ' -f 3 | sed 's/:/-/g')
|
||||
curl "http://{{ pxe_server }}/kickstart/network/$mac.ks" > /tmp/network.ks
|
||||
%end
|
||||
|
@ -0,0 +1,2 @@
|
||||
network --bootproto=static --device={{ network_interface }} --ip={{ hostvars[item]['ansible_host'] }} --gateway={{ gateway }} --nameserver={{ dns }} --netmask={{ netmask }} --ipv6=auto --activate
|
||||
network --hostname={{ hostvars[item]['inventory_hostname'] }}
|
@ -1,2 +0,0 @@
|
||||
network --bootproto=static --device={{ network_device }} --ip={{ hostvars[item]['ansible_host'] }} --gateway={{ gateway }} --nameserver={{ dns }} --netmask={{ netmask }} --ipv6=auto --activate
|
||||
network --hostname={{ hostvars[item]['inventory_hostname'] }}
|
@ -1,8 +0,0 @@
|
||||
- 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
|
@ -1,8 +0,0 @@
|
||||
- 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