Skip to content

Commit f5a1ee6

Browse files
Merge pull request #44 from aitorpazos/wait-for-cloud-init-completion
Adjust cloud-init user-data to account for Ubuntu 24.04 bug
2 parents 0641923 + b369165 commit f5a1ee6

File tree

10 files changed

+89
-2
lines changed

10 files changed

+89
-2
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,4 @@ dmypy.json
130130
src/molecule_plugins/_version.py
131131

132132
.vscode/
133+
.idea/

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ test-network: test-network-shared test-network-user ## Test network
2626
test-os-debian: test-os-debian-bullseye test-os-debian-bookworm ## Test Debian OS
2727

2828
.PHONY: test-os-ubuntu
29-
test-os-ubuntu: test-os-ubuntu-focal test-os-ubuntu-jammy ## Test Ubuntu OS
29+
test-os-ubuntu: test-os-ubuntu-focal test-os-ubuntu-jammy test-os-ubuntu-noble ## Test Ubuntu OS
3030

3131
.PHONY: test-os
3232
test-os: test-os-debian test-os-ubuntu ## Test OS

molecule_qemu/playbooks/create.yml

+21
Original file line numberDiff line numberDiff line change
@@ -438,3 +438,24 @@
438438
content: "{{ instance_conf | to_json | from_json | to_yaml }}"
439439
dest: "{{ molecule_instance_config }}"
440440
mode: "0644"
441+
442+
### wait for cloud-init to complete #######################################
443+
- name: Add hosts to in-memory inventory for follow-up tasks
444+
ansible.builtin.add_host:
445+
name: "{{ item.name }}"
446+
ansible_user: "root"
447+
ansible_become: yes
448+
ansible_ssh_host: "{{ molecule_instances_ipv4[item.name] }}"
449+
ansible_ssh_port: "{{ item.network_ssh_port }}"
450+
ansible_ssh_host_key_checking: no
451+
ansible_ssh_private_key_file: "{{ ssh_keypair.filename }}"
452+
loop: "{{ molecule_instances }}"
453+
loop_control:
454+
label: "{{ item.name }}"
455+
456+
- name: Wait for Cloud-init to complete
457+
ansible.builtin.command: "cloud-init status --wait"
458+
register: cloud_init_status
459+
changed_when: false
460+
delegate_to: "{{ item.name }}"
461+
loop: "{{ molecule_instances }}"

molecule_qemu/playbooks/templates/user-data.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ users:
1616
- wheel
1717
{%- endif +%}
1818
shell: /bin/bash
19-
sudo: ["ALL=(ALL) NOPASSWD:ALL"]
19+
sudo: "ALL=(ALL) NOPASSWD:ALL"
2020
lock_passwd: true
2121
ssh_authorized_keys:
2222
- {{ ssh_keypair.public_key }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
collections:
3+
- name: community.crypto
4+
version: ">=2.11.1"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
- name: Converge
3+
hosts: all
4+
5+
environment:
6+
http_proxy: "{{ lookup('ansible.builtin.env', 'http_proxy') | default(omit) }}"
7+
https_proxy: "{{ lookup('ansible.builtin.env', 'https_proxy') | default(omit) }}"
8+
9+
tasks:
10+
- name: "Include tests"
11+
ansible.builtin.include_role:
12+
name: "tests"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
dependency:
3+
name: galaxy
4+
driver:
5+
name: molecule-qemu
6+
platforms:
7+
- name: ubuntu-noble-amd64
8+
image_url: https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img
9+
image_checksum: sha256:https://cloud-images.ubuntu.com/noble/current/SHA256SUMS
10+
network_ssh_port: 2222
11+
- name: ubuntu-noble-arm64
12+
image_arch: aarch64
13+
image_url: https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-arm64.img
14+
image_checksum: sha256:https://cloud-images.ubuntu.com/noble/current/SHA256SUMS
15+
network_ssh_port: 2223
16+
provisioner:
17+
name: ansible
18+
verifier:
19+
name: ansible
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
- name: Prepare
3+
hosts: all
4+
become: true
5+
gather_facts: false
6+
7+
environment:
8+
http_proxy: "{{ lookup('ansible.builtin.env', 'http_proxy') | default(omit) }}"
9+
https_proxy: "{{ lookup('ansible.builtin.env', 'https_proxy') | default(omit) }}"
10+
11+
tasks:
12+
- name: Wait for SSH to become available
13+
ansible.builtin.wait_for_connection:
14+
delay: 5
15+
timeout: 300
16+
17+
- name: Gather facts
18+
ansible.builtin.setup:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
roles: []
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
# This is an example playbook to execute Ansible tests.
3+
4+
- name: Verify
5+
hosts: all
6+
gather_facts: false
7+
tasks:
8+
- name: Example assertion
9+
ansible.builtin.assert:
10+
that: true

0 commit comments

Comments
 (0)