From 20c79d51254c6fca862bf6096e8b9a6c25e5f66d Mon Sep 17 00:00:00 2001 From: Mike Russell Date: Mon, 19 Dec 2022 11:54:19 -0800 Subject: [PATCH] feat: Introduce Ansible Driver For AirGap Harvester-Installer CI * introduces Ansible yaml that creates isolation from previous CI Ansible workload * new Ansible CI provides deeper flexibility to condition Ansible driving factors for Harvester-Installer while not altering previous CI infrastructure / Ansible Playbook Resolves: feat/airgap-harvester-airgap-rancher-install-test --- ...cher_and_airgap_harvester_install_test.yml | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 ci/run_airgap_rancher_and_airgap_harvester_install_test.yml diff --git a/ci/run_airgap_rancher_and_airgap_harvester_install_test.yml b/ci/run_airgap_rancher_and_airgap_harvester_install_test.yml new file mode 100644 index 000000000..815404456 --- /dev/null +++ b/ci/run_airgap_rancher_and_airgap_harvester_install_test.yml @@ -0,0 +1,110 @@ +--- +- name: Run Airgap Rancher and Airgap Harvester Installation Test + hosts: localhost + connection: local + gather_facts: false + + vars: + REPO: "{{ harvester_installer_repo_name | default('irishgordo/harvester-installer') }}" + + tasks: + - name: Make sure WORKSPACE is defined + fail: + msg: "Variable WORKSPACE is not defined." + when: WORKSPACE is not defined + + - name: Check for harvester-installer + stat: + path: "{{ WORKSPACE }}/harvester-installer" + register: harvester_installer_dir_check_result + + - name: Make sure harvester-installer directory exist + fail: + msg: "{{ WORKSPACE }}/harvester-installer not found" + when: not harvester_installer_dir_check_result.stat.exists + + - name: Build harvester-installer artifacts + shell: > + make + args: + chdir: "{{ WORKSPACE }}/harvester-installer" + retries: 5 + delay: 20 + register: shell_result + until: shell_result.rc == 0 + + - name: Check for existing environment + stat: + path: "{{ WORKSPACE }}/ipxe-examples" + register: check_ipxe_examples_result + + - name: Cleanup vagrants + shell: > + vagrant destroy -f + args: + chdir: "{{ WORKSPACE }}/ipxe-examples/vagrant-pxe-airgap-harvester" + when: check_ipxe_examples_result.stat.exists + + - name: Cleanup ipxe-examples dir + file: + path: "{{ WORKSPACE }}/ipxe-examples" + state: absent + + - name: Clone ipxe-examples repo + git: + repo: https://github.com/harvester/ipxe-examples.git + version: main + dest: "{{ WORKSPACE }}/ipxe-examples" + + - name: Check to see if "/usr/share/qemu/OVMF.fd" exist + stat: + path: /usr/share/qemu/OVMF.fd + register: file_ovmf_fd_check_result + + - name: Remove OVMF.fd line if needed + lineinfile: + path: "{{ WORKSPACE }}/ipxe-examples/vagrant-pxe-airgap-harvester/Vagrantfile" + regexp: '.*\/OVMF\.fd.*' + state: absent + when: not file_ovmf_fd_check_result.stat.exists + + - name: Set harvester_iso_url + replace: + path: "{{ WORKSPACE }}/ipxe-examples/vagrant-pxe-airgap-harvester/settings.yml" + regexp: "^harvester_iso_url:.*" + replace: "harvester_iso_url: file://{{ WORKSPACE }}/harvester-installer/dist/artifacts/harvester-master-amd64.iso" + + - name: Set harvester_kernel_url + replace: + path: "{{ WORKSPACE }}/ipxe-examples/vagrant-pxe-airgap-harvester/settings.yml" + regexp: "^harvester_kernel_url:.*" + replace: "harvester_kernel_url: file://{{ WORKSPACE }}/harvester-installer/dist/artifacts/harvester-master-vmlinuz-amd64" + + - name: Set harvester_ramdisk_url + replace: + path: "{{ WORKSPACE }}/ipxe-examples/vagrant-pxe-airgap-harvester/settings.yml" + regexp: "^harvester_ramdisk_url:.*" + replace: "harvester_ramdisk_url: file://{{ WORKSPACE }}/harvester-installer/dist/artifacts/harvester-master-initrd-amd64" + + - name: Set harvester_rootfs_url + replace: + path: "{{ WORKSPACE }}/ipxe-examples/vagrant-pxe-airgap-harvester/settings.yml" + regexp: "^harvester_rootfs_url:.*" + replace: "harvester_rootfs_url: file://{{ WORKSPACE }}/harvester-installer/dist/artifacts/harvester-master-rootfs-amd64.squashfs" + + - name: Run setup Harvester + shell: > + ./setup_harvester.sh -c -s /var/lib/jenkins/.ssh/known_hosts + register: setup_harvester_result + args: + chdir: "{{ WORKSPACE }}/ipxe-examples/vagrant-pxe-airgap-harvester" + ignore_errors: yes + + - name: Print Harvester installation output + debug: + msg: "{{ setup_harvester_result.stdout_lines }}" + + - name: Check result + fail: + msg: "ERROR: {{ setup_harvester_result.stderr }}" + when: setup_harvester_result.failed