Skip to content

Commit

Permalink
feat: Introduce Ansible Driver For AirGap Harvester-Installer CI
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
irishgordo committed Jun 30, 2023
1 parent 937102f commit 99aff1b
Showing 1 changed file with 110 additions and 0 deletions.
110 changes: 110 additions & 0 deletions ci/run_airgap_rancher_and_airgap_harvester_install_test.yml
Original file line number Diff line number Diff line change
@@ -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('harvester/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

0 comments on commit 99aff1b

Please sign in to comment.