diff --git a/.gitignore b/.gitignore index 4b455ba..f7439bf 100644 --- a/.gitignore +++ b/.gitignore @@ -130,3 +130,4 @@ dmypy.json src/molecule_plugins/_version.py .vscode/ +.idea/ diff --git a/Makefile b/Makefile index f1efa1c..de02261 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ test-network: test-network-shared test-network-user ## Test network test-os-debian: test-os-debian-bullseye test-os-debian-bookworm ## Test Debian OS .PHONY: test-os-ubuntu -test-os-ubuntu: test-os-ubuntu-focal test-os-ubuntu-jammy ## Test Ubuntu OS +test-os-ubuntu: test-os-ubuntu-focal test-os-ubuntu-jammy test-os-ubuntu-noble ## Test Ubuntu OS .PHONY: test-os test-os: test-os-debian test-os-ubuntu ## Test OS diff --git a/molecule_qemu/playbooks/create.yml b/molecule_qemu/playbooks/create.yml index 7e262e3..04c02de 100644 --- a/molecule_qemu/playbooks/create.yml +++ b/molecule_qemu/playbooks/create.yml @@ -438,3 +438,24 @@ content: "{{ instance_conf | to_json | from_json | to_yaml }}" dest: "{{ molecule_instance_config }}" mode: "0644" + + ### wait for cloud-init to complete ####################################### + - name: Add hosts to in-memory inventory for follow-up tasks + ansible.builtin.add_host: + name: "{{ item.name }}" + ansible_user: "root" + ansible_become: yes + ansible_ssh_host: "{{ molecule_instances_ipv4[item.name] }}" + ansible_ssh_port: "{{ item.network_ssh_port }}" + ansible_ssh_host_key_checking: no + ansible_ssh_private_key_file: "{{ ssh_keypair.filename }}" + loop: "{{ molecule_instances }}" + loop_control: + label: "{{ item.name }}" + + - name: Wait for Cloud-init to complete + ansible.builtin.command: "cloud-init status --wait" + register: cloud_init_status + changed_when: false + delegate_to: "{{ item.name }}" + loop: "{{ molecule_instances }}" diff --git a/molecule_qemu/playbooks/templates/user-data.j2 b/molecule_qemu/playbooks/templates/user-data.j2 index a7319d9..2ed42e1 100644 --- a/molecule_qemu/playbooks/templates/user-data.j2 +++ b/molecule_qemu/playbooks/templates/user-data.j2 @@ -16,7 +16,7 @@ users: - wheel {%- endif +%} shell: /bin/bash - sudo: ["ALL=(ALL) NOPASSWD:ALL"] + sudo: "ALL=(ALL) NOPASSWD:ALL" lock_passwd: true ssh_authorized_keys: - {{ ssh_keypair.public_key }} diff --git a/tests/molecule/os-ubuntu-noble/collections.yml b/tests/molecule/os-ubuntu-noble/collections.yml new file mode 100644 index 0000000..1b1a38c --- /dev/null +++ b/tests/molecule/os-ubuntu-noble/collections.yml @@ -0,0 +1,4 @@ +--- +collections: + - name: community.crypto + version: ">=2.11.1" diff --git a/tests/molecule/os-ubuntu-noble/converge.yml b/tests/molecule/os-ubuntu-noble/converge.yml new file mode 100644 index 0000000..8d580ce --- /dev/null +++ b/tests/molecule/os-ubuntu-noble/converge.yml @@ -0,0 +1,12 @@ +--- +- name: Converge + hosts: all + + environment: + http_proxy: "{{ lookup('ansible.builtin.env', 'http_proxy') | default(omit) }}" + https_proxy: "{{ lookup('ansible.builtin.env', 'https_proxy') | default(omit) }}" + + tasks: + - name: "Include tests" + ansible.builtin.include_role: + name: "tests" diff --git a/tests/molecule/os-ubuntu-noble/molecule.yml b/tests/molecule/os-ubuntu-noble/molecule.yml new file mode 100644 index 0000000..c9b48d0 --- /dev/null +++ b/tests/molecule/os-ubuntu-noble/molecule.yml @@ -0,0 +1,19 @@ +--- +dependency: + name: galaxy +driver: + name: molecule-qemu +platforms: + - name: ubuntu-noble-amd64 + image_url: https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img + image_checksum: sha256:https://cloud-images.ubuntu.com/noble/current/SHA256SUMS + network_ssh_port: 2222 + - name: ubuntu-noble-arm64 + image_arch: aarch64 + image_url: https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-arm64.img + image_checksum: sha256:https://cloud-images.ubuntu.com/noble/current/SHA256SUMS + network_ssh_port: 2223 +provisioner: + name: ansible +verifier: + name: ansible diff --git a/tests/molecule/os-ubuntu-noble/prepare.yml b/tests/molecule/os-ubuntu-noble/prepare.yml new file mode 100644 index 0000000..ce23c04 --- /dev/null +++ b/tests/molecule/os-ubuntu-noble/prepare.yml @@ -0,0 +1,18 @@ +--- +- name: Prepare + hosts: all + become: true + gather_facts: false + + environment: + http_proxy: "{{ lookup('ansible.builtin.env', 'http_proxy') | default(omit) }}" + https_proxy: "{{ lookup('ansible.builtin.env', 'https_proxy') | default(omit) }}" + + tasks: + - name: Wait for SSH to become available + ansible.builtin.wait_for_connection: + delay: 5 + timeout: 300 + + - name: Gather facts + ansible.builtin.setup: diff --git a/tests/molecule/os-ubuntu-noble/requirements.yml b/tests/molecule/os-ubuntu-noble/requirements.yml new file mode 100644 index 0000000..7265dc5 --- /dev/null +++ b/tests/molecule/os-ubuntu-noble/requirements.yml @@ -0,0 +1,2 @@ +--- +roles: [] diff --git a/tests/molecule/os-ubuntu-noble/verify.yml b/tests/molecule/os-ubuntu-noble/verify.yml new file mode 100644 index 0000000..a5cfa75 --- /dev/null +++ b/tests/molecule/os-ubuntu-noble/verify.yml @@ -0,0 +1,10 @@ +--- +# This is an example playbook to execute Ansible tests. + +- name: Verify + hosts: all + gather_facts: false + tasks: + - name: Example assertion + ansible.builtin.assert: + that: true