Files
ansible-role_podman-host/extensions/molecule/linode/create.yml
T
Mike Holloway 189e33d9f4
Gitea Actions - molecule test work / Explore-terraform-molecule-Gitea-Action (push) Failing after 1m15s
tofu and molecule combined test, first try
2025-01-07 06:18:10 -05:00

95 lines
2.6 KiB
YAML

---
- name: Create
hosts: localhost
connection: local
gather_facts: false
# no_log: "{{ molecule_no_log }}"
vars:
molecule_inventory:
all:
hosts: {}
linode: {}
tasks:
- name: Confirm we can reach
command:
cmd: "ping -c5 {{ lookup('env', 'TARGET_IP_ADDRESS') }}"
register: isping
- debug:
msg: |
"{{ isping.failed }}"
- name: Fail if instance is not running
when: isping.failed
fail:
- name: Add linode to molecule_inventory
vars:
inventory_partial_yaml: |
all:
children:
linode:
hosts:
"{{ lookup('env', 'TARGET_IP_ADDRESS') }}":
ansible_ssh_private_key_file: "{{ lookup('env', 'GITHUB_WORKSPACE') }}/.ssh/act_runner_id-ed25519"
ansible_connection: ssh
service_users:
- name: serviceuser1
services:
- service1
- service2
ansible.builtin.set_fact:
molecule_inventory: >
{{ molecule_inventory | combine(inventory_partial_yaml | from_yaml, recursive=true) }}
- name: Dump molecule_inventory
ansible.builtin.copy:
content: |
{{ molecule_inventory | to_yaml }}
dest: "{{ molecule_ephemeral_directory }}/inventory/molecule_inventory.yml"
mode: "0600"
- name: Force inventory refresh
ansible.builtin.meta: refresh_inventory
- name: Fail if linode group is missing
ansible.builtin.assert:
that: "'linode' in groups"
fail_msg: |
linode group was not found inside inventory groups: {{ groups }}
run_once: true # noqa: run-once[task]
# we want to avoid errors like "Failed to create temporary directory"
- name: Validate that inventory was refreshed
hosts: linode
gather_facts: false
tasks:
- name: Check uname
ansible.builtin.raw: uname -a
register: result
changed_when: false
- name: Display uname info
ansible.builtin.debug:
msg: "{{ result.stdout }}"
- name: Verify linode properties
hosts: linode
gather_facts: false
tasks:
- name: Packages openssh-server, python3-policycoreutils
ansible.builtin.dnf:
name: ['openssh-server', 'python3-policycoreutils']
state: present
- name: systemd PID
command: ps -q 1
register: ps_result
changed_when: false
- name: Display PID 1 info
ansible.builtin.debug:
msg: "{{ ps_result.stdout }}"