diff --git a/README.md b/README.md index 5f79c84..a146d5b 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# Packer.Images [![Build Status](https://ci.spamasaurus.com/api/badges/djpbessems/Packer.Images/status.svg?ref=refs/heads/UbuntuServer22.04)](https://ci.spamasaurus.com/djpbessems/Packer.Images) +# Packer.Images [![Build Status](https://ci.spamasaurus.com/api/badges/djpbessems/Packer.Images/status.svg?ref=refs/heads/Kubernetes.Bootstrap.Appliance)](https://ci.spamasaurus.com/djpbessems/Packer.Images) diff --git a/ansible/playbook.yml b/ansible/playbook.yml index 997713c..4465571 100644 --- a/ansible/playbook.yml +++ b/ansible/playbook.yml @@ -1,7 +1,10 @@ --- - hosts: all gather_facts: false + group_vars: + - metacluster.yml become: true roles: - os - firstboot + - metacluster diff --git a/ansible/roles/bootstrap/tasks/dependencies.yml b/ansible/roles/bootstrap/tasks/dependencies.yml new file mode 100644 index 0000000..d0ee3af --- /dev/null +++ b/ansible/roles/bootstrap/tasks/dependencies.yml @@ -0,0 +1,11 @@ +- name: Create folder structure + ansible.builtin.file: + path: "{{ item }}" + state: directory + loop: + - /opt/x + +- name: Install ansible-galaxy collection + ansible.builtin.shell: + cmd: "ansible-galaxy collection install {{ item }}" + loop: "{{ dependencies.ansible_galaxy_collections }}" diff --git a/ansible/roles/bootstrap/tasks/main.yml b/ansible/roles/bootstrap/tasks/main.yml new file mode 100644 index 0000000..36a7c41 --- /dev/null +++ b/ansible/roles/bootstrap/tasks/main.yml @@ -0,0 +1,2 @@ +- name: XYZ + import_tasks: foo.yml diff --git a/ansible/roles/firstboot/tasks/main.yml b/ansible/roles/firstboot/tasks/main.yml index bc584b0..c933ca2 100644 --- a/ansible/roles/firstboot/tasks/main.yml +++ b/ansible/roles/firstboot/tasks/main.yml @@ -2,6 +2,7 @@ ansible.builtin.file: path: /opt/firstboot state: directory + - name: Create firstboot script file ansible.builtin.template: src: firstboot.j2 @@ -9,11 +10,13 @@ owner: root group: root mode: o+x + - name: Create @reboot crontab job ansible.builtin.cron: name: firstboot special_time: reboot job: "/opt/firstboot/firstboot.sh" + - name: Copy payload folder ansible.builtin.copy: src: ansible_payload/ @@ -21,6 +24,3 @@ owner: root group: root mode: '0644' -- name: Install ansible-galaxy collection - ansible.builtin.shell: - cmd: ansible-galaxy collection install community.general diff --git a/ansible/roles/metacluster/tasks/k3s.yml b/ansible/roles/metacluster/tasks/k3s.yml new file mode 100644 index 0000000..7e21c75 --- /dev/null +++ b/ansible/roles/metacluster/tasks/k3s.yml @@ -0,0 +1,6 @@ +- name: Create folder structure + ansible.builtin.file: + path: "{{ item }}" + state: directory + loop: + - /opt/x diff --git a/ansible/roles/metacluster/tasks/main.yml b/ansible/roles/metacluster/tasks/main.yml new file mode 100644 index 0000000..36a7c41 --- /dev/null +++ b/ansible/roles/metacluster/tasks/main.yml @@ -0,0 +1,2 @@ +- name: XYZ + import_tasks: foo.yml diff --git a/ansible/vars/metacluster.yml b/ansible/vars/metacluster.yml new file mode 100644 index 0000000..2f4e930 --- /dev/null +++ b/ansible/vars/metacluster.yml @@ -0,0 +1,20 @@ +k3s: + version: v1.24.1+k3s1 + +components: + + harbor: + version: + + argocd: + version: + +dependencies: + + ansible_galaxy_collections: + - community.general + - kubernetes.core + + static_binaries: + - binary: yq + url: diff --git a/packer/ubuntuserver22.04.pkr.hcl b/packer/k8sboostrap.pkr.hcl similarity index 86% rename from packer/ubuntuserver22.04.pkr.hcl rename to packer/k8sboostrap.pkr.hcl index 44a6401..e54b520 100644 --- a/packer/ubuntuserver22.04.pkr.hcl +++ b/packer/k8sboostrap.pkr.hcl @@ -3,7 +3,7 @@ packer { } } -source "vsphere-iso" "ubuntuserver" { +source "vsphere-iso" "k8sbootstrap" { vcenter_server = var.vcenter_server username = var.vsphere_username password = var.vsphere_password @@ -67,11 +67,11 @@ source "vsphere-iso" "ubuntuserver" { build { sources = [ - "source.vsphere-iso.ubuntuserver" + "source.vsphere-iso.k8sbootstrap" ] provisioner "ansible" { - only = ["vsphere-iso.ubuntuserver"] + only = ["vsphere-iso.k8sbootstrap"] playbook_file = "ansible/playbook.yml" user = "ubuntu" @@ -85,16 +85,16 @@ build { } post-processor "shell-local" { - only = ["vsphere-iso.ubuntuserver"] + only = ["vsphere-iso.k8sbootstrap"] inline = [ "pwsh -command \"& scripts/Update-OvfConfiguration.ps1 \\", - " -OVFFile '/scratch/ubuntuserver/${var.vm_guestos}-${var.vm_name}.ovf' \\", + " -OVFFile '/scratch/k8sbootstrap/${var.vm_guestos}-${var.vm_name}.ovf' \\", " -Parameter @{'appliance.name'='${var.vm_guestos}';'appliance.version'='${var.vm_name}'}\"", "pwsh -file scripts/Update-Manifest.ps1 \\", - " -ManifestFileName '/scratch/ubuntuserver/${var.vm_guestos}-${var.vm_name}.mf'", + " -ManifestFileName '/scratch/k8sbootstrap/${var.vm_guestos}-${var.vm_name}.mf'", "ovftool --acceptAllEulas --allowExtraConfig --overwrite \\", - " '/scratch/ubuntuserver/${var.vm_guestos}-${var.vm_name}.ovf' \\", - " /output/Ubuntu-Server-22.04.ova" + " '/scratch/k8sbootstrap/${var.vm_guestos}-${var.vm_name}.ovf' \\", + " /output/Kubernetes.Bootstrap.Appliance.ova" ] } }