Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Airgap Rancher Airgap Harvester Ansible Driver Playbook #400

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading