From d1508efd3f7210ffc94803d7dd2028967ef17911 Mon Sep 17 00:00:00 2001 From: michael Date: Mon, 24 Oct 2022 15:50:38 +1300 Subject: [PATCH] restructure --- ansible/inventory/host_vars/fw00/fw00.yaml | 1 + ansible/inventory/host_vars/hv00/hv00.yaml | 3 +++ ansible/playbooks/00_baremetal.yaml | 7 +++++++ ansible/playbooks/{lab.yaml => 01_hypervisor.yaml} | 4 ++-- ansible/playbooks/02_vm_template.yaml | 7 +++++++ ansible/playbooks/{k8s.yaml => 03_vm_deploy.yaml} | 11 ++--------- ansible/playbooks/04_k8s.yaml | 7 +++++++ ansible/roles/baremetal/defaults/main.yml | 2 ++ ansible/roles/baremetal/files/packages | 3 +++ ansible/roles/baremetal/tasks/main.yml | 11 +++++++++++ ansible/roles/baremetal/templates/eno.network.j2 | 9 +++++++++ .../roles/{k8s_vms => vm_deploy}/defaults/main.yml | 0 ansible/roles/{k8s_vms => vm_deploy}/tasks/main.yml | 0 .../{k8s_vms => vm_deploy}/templates/eno1.network.j2 | 0 .../templates/vm_template.xml.j2 | 0 ansible/roles/vm_template/defaults/main.yml | 1 + ansible/roles/vm_template/tasks/main.yml | 7 +++++++ .../roles/vm_template/templates/vm_template.xml.j2 | 0 18 files changed, 62 insertions(+), 11 deletions(-) create mode 100644 ansible/inventory/host_vars/fw00/fw00.yaml create mode 100644 ansible/inventory/host_vars/hv00/hv00.yaml create mode 100644 ansible/playbooks/00_baremetal.yaml rename ansible/playbooks/{lab.yaml => 01_hypervisor.yaml} (77%) create mode 100644 ansible/playbooks/02_vm_template.yaml rename ansible/playbooks/{k8s.yaml => 03_vm_deploy.yaml} (65%) create mode 100644 ansible/playbooks/04_k8s.yaml create mode 100644 ansible/roles/baremetal/defaults/main.yml create mode 100644 ansible/roles/baremetal/files/packages create mode 100644 ansible/roles/baremetal/tasks/main.yml create mode 100644 ansible/roles/baremetal/templates/eno.network.j2 rename ansible/roles/{k8s_vms => vm_deploy}/defaults/main.yml (100%) rename ansible/roles/{k8s_vms => vm_deploy}/tasks/main.yml (100%) rename ansible/roles/{k8s_vms => vm_deploy}/templates/eno1.network.j2 (100%) rename ansible/roles/{k8s_vms => vm_deploy}/templates/vm_template.xml.j2 (100%) create mode 100644 ansible/roles/vm_template/defaults/main.yml create mode 100644 ansible/roles/vm_template/tasks/main.yml create mode 100644 ansible/roles/vm_template/templates/vm_template.xml.j2 diff --git a/ansible/inventory/host_vars/fw00/fw00.yaml b/ansible/inventory/host_vars/fw00/fw00.yaml new file mode 100644 index 0000000..ed97d53 --- /dev/null +++ b/ansible/inventory/host_vars/fw00/fw00.yaml @@ -0,0 +1 @@ +--- diff --git a/ansible/inventory/host_vars/hv00/hv00.yaml b/ansible/inventory/host_vars/hv00/hv00.yaml new file mode 100644 index 0000000..e736e95 --- /dev/null +++ b/ansible/inventory/host_vars/hv00/hv00.yaml @@ -0,0 +1,3 @@ +--- +vhd_template: "kube_template_vda.qcow2" +root_vhd_pool_dir: "/vhds" # No trailing / \ No newline at end of file diff --git a/ansible/playbooks/00_baremetal.yaml b/ansible/playbooks/00_baremetal.yaml new file mode 100644 index 0000000..47c9d17 --- /dev/null +++ b/ansible/playbooks/00_baremetal.yaml @@ -0,0 +1,7 @@ +--- +- name: bare metal os installation + gather_facts: false + hosts: hv00 + become: true + roles: + - baremetal \ No newline at end of file diff --git a/ansible/playbooks/lab.yaml b/ansible/playbooks/01_hypervisor.yaml similarity index 77% rename from ansible/playbooks/lab.yaml rename to ansible/playbooks/01_hypervisor.yaml index 196c96d..aa01f7b 100644 --- a/ansible/playbooks/lab.yaml +++ b/ansible/playbooks/01_hypervisor.yaml @@ -1,7 +1,7 @@ --- -- name: Configure lab host +- name: configure hyervisor host gather_facts: false - hosts: lab + hosts: hv00 become: true roles: diff --git a/ansible/playbooks/02_vm_template.yaml b/ansible/playbooks/02_vm_template.yaml new file mode 100644 index 0000000..e1bdf71 --- /dev/null +++ b/ansible/playbooks/02_vm_template.yaml @@ -0,0 +1,7 @@ +--- +- name: create vm template + hosts: hv00 + gather_facts: true + become: true + roles: + - vm_template diff --git a/ansible/playbooks/k8s.yaml b/ansible/playbooks/03_vm_deploy.yaml similarity index 65% rename from ansible/playbooks/k8s.yaml rename to ansible/playbooks/03_vm_deploy.yaml index 580e913..9d616ca 100644 --- a/ansible/playbooks/k8s.yaml +++ b/ansible/playbooks/03_vm_deploy.yaml @@ -4,7 +4,7 @@ gather_facts: true become: true roles: - - k8s_vms + - vm_deploy - name: python bootstrap hosts: k8s @@ -19,11 +19,4 @@ become: true roles: - sshd - - firewall - -- name: configure control plane - hosts: k8s_control - gather_facts: true - become: false - roles: - - k8s_control + - firewall \ No newline at end of file diff --git a/ansible/playbooks/04_k8s.yaml b/ansible/playbooks/04_k8s.yaml new file mode 100644 index 0000000..7994a84 --- /dev/null +++ b/ansible/playbooks/04_k8s.yaml @@ -0,0 +1,7 @@ +--- +- name: configure control plane + hosts: k8s_control + gather_facts: true + become: false + roles: + - k8s_control diff --git a/ansible/roles/baremetal/defaults/main.yml b/ansible/roles/baremetal/defaults/main.yml new file mode 100644 index 0000000..0048b5f --- /dev/null +++ b/ansible/roles/baremetal/defaults/main.yml @@ -0,0 +1,2 @@ +--- +iso_source: diff --git a/ansible/roles/baremetal/files/packages b/ansible/roles/baremetal/files/packages new file mode 100644 index 0000000..2a2e155 --- /dev/null +++ b/ansible/roles/baremetal/files/packages @@ -0,0 +1,3 @@ +linux-lts +linux-lts-headers +base \ No newline at end of file diff --git a/ansible/roles/baremetal/tasks/main.yml b/ansible/roles/baremetal/tasks/main.yml new file mode 100644 index 0000000..701355b --- /dev/null +++ b/ansible/roles/baremetal/tasks/main.yml @@ -0,0 +1,11 @@ +--- +- name: attach installation iso as virtual media + +- name: boot from installation iso + +- name: detect booted ip address + +- name: configure disks + +- name: sync ntp + diff --git a/ansible/roles/baremetal/templates/eno.network.j2 b/ansible/roles/baremetal/templates/eno.network.j2 new file mode 100644 index 0000000..ade6816 --- /dev/null +++ b/ansible/roles/baremetal/templates/eno.network.j2 @@ -0,0 +1,9 @@ +[Match] +MACAddress={{ mac_address }} + +[Link] +ARP=no + +[Network] +DHCP=no +Bond=lacp diff --git a/ansible/roles/k8s_vms/defaults/main.yml b/ansible/roles/vm_deploy/defaults/main.yml similarity index 100% rename from ansible/roles/k8s_vms/defaults/main.yml rename to ansible/roles/vm_deploy/defaults/main.yml diff --git a/ansible/roles/k8s_vms/tasks/main.yml b/ansible/roles/vm_deploy/tasks/main.yml similarity index 100% rename from ansible/roles/k8s_vms/tasks/main.yml rename to ansible/roles/vm_deploy/tasks/main.yml diff --git a/ansible/roles/k8s_vms/templates/eno1.network.j2 b/ansible/roles/vm_deploy/templates/eno1.network.j2 similarity index 100% rename from ansible/roles/k8s_vms/templates/eno1.network.j2 rename to ansible/roles/vm_deploy/templates/eno1.network.j2 diff --git a/ansible/roles/k8s_vms/templates/vm_template.xml.j2 b/ansible/roles/vm_deploy/templates/vm_template.xml.j2 similarity index 100% rename from ansible/roles/k8s_vms/templates/vm_template.xml.j2 rename to ansible/roles/vm_deploy/templates/vm_template.xml.j2 diff --git a/ansible/roles/vm_template/defaults/main.yml b/ansible/roles/vm_template/defaults/main.yml new file mode 100644 index 0000000..ed97d53 --- /dev/null +++ b/ansible/roles/vm_template/defaults/main.yml @@ -0,0 +1 @@ +--- diff --git a/ansible/roles/vm_template/tasks/main.yml b/ansible/roles/vm_template/tasks/main.yml new file mode 100644 index 0000000..2b57f62 --- /dev/null +++ b/ansible/roles/vm_template/tasks/main.yml @@ -0,0 +1,7 @@ +--- + +- name: sysprep the template vhd + when: template_created is changed + ansible.builtin.shell: + cmd: | + virt-sysprep -a {{ root_vhd_pool_dir }}/{{ vhd_template }} \ No newline at end of file diff --git a/ansible/roles/vm_template/templates/vm_template.xml.j2 b/ansible/roles/vm_template/templates/vm_template.xml.j2 new file mode 100644 index 0000000..e69de29