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

Adjust cloud-init user-data to account for Ubuntu 24.04 bug #44

Merged
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,4 @@ dmypy.json
src/molecule_plugins/_version.py

.vscode/
.idea/
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions molecule_qemu/playbooks/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
2 changes: 1 addition & 1 deletion molecule_qemu/playbooks/templates/user-data.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
4 changes: 4 additions & 0 deletions tests/molecule/os-ubuntu-noble/collections.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
collections:
- name: community.crypto
version: ">=2.11.1"
12 changes: 12 additions & 0 deletions tests/molecule/os-ubuntu-noble/converge.yml
Original file line number Diff line number Diff line change
@@ -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"
19 changes: 19 additions & 0 deletions tests/molecule/os-ubuntu-noble/molecule.yml
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions tests/molecule/os-ubuntu-noble/prepare.yml
Original file line number Diff line number Diff line change
@@ -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:
2 changes: 2 additions & 0 deletions tests/molecule/os-ubuntu-noble/requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
roles: []
10 changes: 10 additions & 0 deletions tests/molecule/os-ubuntu-noble/verify.yml
Original file line number Diff line number Diff line change
@@ -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