- Added `bootstrap_sparrowdo` role for bootstrapping Sparrowdo on a VM. - Introduced `cleanup_vm` role for cleaning up VMs and disk images. - Created `download_image` role to download and cache QCOW2 images. - Developed `golden_image` role for creating and customizing golden images. - Implemented `provision_vm` role for provisioning VMs as linked clones. - Added `run_test` role for executing tests with Sparrowdo. - Created playbooks for building golden images, running single tests, and running test suites. - Enhanced documentation with usage examples, configuration details, and troubleshooting tips. - Added support for multiple cloud providers (AWS, Azure) in the test execution workflow. Signed-off-by: Stephen Simpson <ssimpson89@users.noreply.github.com>
79 lines
2.1 KiB
YAML
79 lines
2.1 KiB
YAML
---
|
|
# Build a golden image: Download -> Customize -> Bootstrap Sparrowdo
|
|
|
|
- name: Build Golden Image
|
|
hosts: libvirt
|
|
gather_facts: true
|
|
|
|
vars_prompt:
|
|
- name: qcow2_url
|
|
prompt: "Rocky Linux QCOW2 URL (Enter for Rocky 9 default)"
|
|
default: "https://download.rockylinux.org/pub/rocky/9/images/x86_64/Rocky-9-GenericCloud-Base.latest.x86_64.qcow2"
|
|
private: false
|
|
|
|
pre_tasks:
|
|
- name: Verify sparrowdo is installed
|
|
stat:
|
|
path: ~/.raku/bin/sparrowdo
|
|
register: sparrowdo_check
|
|
failed_when: not sparrowdo_check.stat.exists
|
|
|
|
- name: Set build paths
|
|
set_fact:
|
|
build_id: "{{ lookup('pipe', 'date +%s') }}"
|
|
|
|
- name: Set golden image path
|
|
set_fact:
|
|
timestamped_golden_path: "{{ golden_images_dir }}/rocky-golden-{{ build_id }}.qcow2"
|
|
|
|
- name: Ensure directories exist
|
|
file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
mode: '0755'
|
|
become: true
|
|
loop:
|
|
- "{{ golden_images_dir }}"
|
|
- /tmp/rocky-test-keys
|
|
|
|
- name: Generate SSH keys if needed
|
|
command: ssh-keygen -t rsa -b 4096 -f /tmp/rocky-test-keys/id_rsa -N "" -C "rocky-test"
|
|
args:
|
|
creates: /tmp/rocky-test-keys/id_rsa
|
|
|
|
- name: Set SSH key paths
|
|
set_fact:
|
|
ssh_private_key_path: /tmp/rocky-test-keys/id_rsa
|
|
ssh_public_key_path: /tmp/rocky-test-keys/id_rsa.pub
|
|
|
|
tasks:
|
|
- name: Download base image
|
|
include_role:
|
|
name: download_image
|
|
vars:
|
|
image_path_var: "base_image_path"
|
|
|
|
- name: Create golden image
|
|
include_role:
|
|
name: golden_image
|
|
vars:
|
|
golden_image_path: "{{ timestamped_golden_path }}"
|
|
|
|
- name: Bootstrap Sparrowdo
|
|
include_role:
|
|
name: bootstrap_sparrowdo
|
|
vars:
|
|
golden_image_path: "{{ timestamped_golden_path }}"
|
|
|
|
- name: Create symlink to latest golden image
|
|
file:
|
|
src: "{{ timestamped_golden_path }}"
|
|
dest: "{{ golden_image_path }}"
|
|
state: link
|
|
force: yes
|
|
become: true
|
|
|
|
- name: Done
|
|
debug:
|
|
msg: "Golden image ready: {{ golden_image_path }}"
|