v1.0.5
This commit is contained in:
154
reassign.yaml
Normal file
154
reassign.yaml
Normal file
@@ -0,0 +1,154 @@
|
||||
- name: Deploy virtual machines
|
||||
hosts: poweredge-t640
|
||||
become: true
|
||||
vars_files:
|
||||
- ../secrets.yaml
|
||||
vars:
|
||||
libvirt_guests:
|
||||
- alpha-worker-8
|
||||
- alpha-worker-9
|
||||
- alpha-worker-10
|
||||
- alpha-worker-11
|
||||
- alpha-worker-12
|
||||
tasks:
|
||||
- name: Download base image
|
||||
get_url:
|
||||
url: https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2
|
||||
dest: /var/lib/libvirt/images/debian-12-generic-amd64.qcow2
|
||||
force: true
|
||||
|
||||
- name: Copy base image
|
||||
copy:
|
||||
src: /var/lib/libvirt/images/debian-12-generic-amd64.qcow2
|
||||
remote_src: true
|
||||
dest: "/var/lib/libvirt/images/{{ item }}.qcow2"
|
||||
force: true
|
||||
loop: "{{ libvirt_guests }}"
|
||||
|
||||
- name: Resize images
|
||||
command: "qemu-img resize -f qcow2 /var/lib/libvirt/images/{{ item }}.qcow2 16G"
|
||||
loop: "{{ libvirt_guests }}"
|
||||
|
||||
- name: Create cloud-config directory
|
||||
file:
|
||||
path: "/tmp/{{ item }}"
|
||||
state: directory
|
||||
loop: "{{ libvirt_guests }}"
|
||||
|
||||
- name: Copy cloud-config user-data template
|
||||
template:
|
||||
src: user-data.j2
|
||||
dest: "/tmp/{{ domain.name }}/user-data"
|
||||
force: true
|
||||
loop: "{{ libvirt_guests }}"
|
||||
vars:
|
||||
domain: "{{ hostvars[item] }}"
|
||||
|
||||
- name: Copy cloud-config meta-data template
|
||||
template:
|
||||
src: meta-data.j2
|
||||
dest: "/tmp/{{ domain.name }}/meta-data"
|
||||
force: true
|
||||
loop: "{{ libvirt_guests }}"
|
||||
vars:
|
||||
domain: "{{ hostvars[item] }}"
|
||||
|
||||
- name: Generate iso
|
||||
command: "genisoimage -output /var/lib/libvirt/images/{{ item }}.iso -volid cidata -joliet -rock /tmp/{{ item }}/user-data /tmp/{{ item }}/meta-data"
|
||||
loop: "{{ libvirt_guests }}"
|
||||
|
||||
- name: Define libvirt virtual machine
|
||||
community.libvirt.virt:
|
||||
command: define
|
||||
xml: "{{ lookup('template', 'libvirt-vm.xml.j2') }}"
|
||||
loop: "{{ libvirt_guests }}"
|
||||
vars:
|
||||
domain: "{{ hostvars[item] }}"
|
||||
|
||||
- name: Create libvirt virtual machine
|
||||
community.libvirt.virt:
|
||||
name: "{{ item }}"
|
||||
command: create
|
||||
loop: "{{ libvirt_guests }}"
|
||||
|
||||
- name: Autostart libvirt virtual machines
|
||||
community.libvirt.virt:
|
||||
name: "{{ item }}"
|
||||
autostart: true
|
||||
loop: "{{ libvirt_guests }}"
|
||||
|
||||
- name: Wait for guest initialization
|
||||
wait_for:
|
||||
timeout: 300
|
||||
|
||||
- name: Reset libvirt virtual machines for filesystem resize
|
||||
command: "virsh reset {{ item }}"
|
||||
loop: "{{ libvirt_guests }}"
|
||||
|
||||
- name: Wait for manual tasks
|
||||
hosts: localhost
|
||||
tasks:
|
||||
- name: Trust SSH identities
|
||||
pause:
|
||||
prompt: "Press Enter to continue..."
|
||||
|
||||
- name: Initialize virtual machines
|
||||
hosts:
|
||||
- alpha-worker-8
|
||||
- alpha-worker-9
|
||||
- alpha-worker-10
|
||||
- alpha-worker-11
|
||||
- alpha-worker-12
|
||||
become: true
|
||||
vars_files:
|
||||
- ../secrets.yaml
|
||||
roles:
|
||||
- role: ericomeehan.ericomeehan
|
||||
|
||||
- name: Initialize Kubernetes clusters
|
||||
hosts:
|
||||
- alpha-worker-8
|
||||
- alpha-worker-9
|
||||
- alpha-worker-10
|
||||
- alpha-worker-11
|
||||
- alpha-worker-12
|
||||
become: true
|
||||
pre_tasks:
|
||||
- name: Enable IPv4 packet forwarding
|
||||
lineinfile:
|
||||
path: /etc/sysctl.conf
|
||||
line: 'net.ipv4.ip_forward = 1'
|
||||
state: present
|
||||
|
||||
- name: Enable IPv6 packet forwarding
|
||||
lineinfile:
|
||||
path: /etc/sysctl.conf
|
||||
line: 'net.ipv6.conf.all.forwarding = 1'
|
||||
state: present
|
||||
|
||||
- name: Reload sysctl configuration
|
||||
command: sysctl --system
|
||||
|
||||
- name: Enable br_netfilter kernel module
|
||||
command: modprobe br_netfilter
|
||||
|
||||
- name: Add the module to a configuration file for persistence
|
||||
lineinfile:
|
||||
path: /etc/modules-load.d/modules.conf
|
||||
line: "br_netfilter"
|
||||
|
||||
- name: Install kubernetes library
|
||||
apt:
|
||||
name: python3-kubernetes
|
||||
state: present
|
||||
|
||||
roles:
|
||||
- role: geerlingguy.containerd
|
||||
|
||||
- name: Alpha Cluster
|
||||
hosts:
|
||||
- alpha
|
||||
become: true
|
||||
roles:
|
||||
- role: geerlingguy.kubernetes
|
||||
|
||||
Reference in New Issue
Block a user