--- # 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 }}"