Files
ansible-role_podman-host/extensions/molecule/linode/create.yml
T
Mike Holloway 0fcfdd4bbc
Gitea Actions - molecule test work / Explore-terraform-molecule-Gitea-Action (push) Successful in 7m20s
Move certain packages to role instead of linode CI
2025-01-07 22:42:24 -05:00

114 lines
2.8 KiB
YAML

---
- name: Create
hosts: localhost
connection: local
gather_facts: false
# no_log: "{{ molecule_no_log }}"
vars:
molecule_inventory:
all:
hosts: {}
linode: {}
tasks:
- name: ssh key setup
copy:
content: |
{{ lookup('env', 'ACT_RUNNER_DEPLOY_KEY') }}
dest: "~/.ssh/id_ed25519"
- name: ssh config setup
copy:
content: |
Host act_worker
Hostname {{ lookup('env', 'TARGET_IP_ADDRESS') }}
StrictHostKeyChecking accept-new
User root
IdentityFile ~/.ssh/id_ed25519
dest: "~/.ssh/config"
- name: Confirm we can reach
command:
cmd: |
ssh -vv -T act_worker
retries: 12
delay: 10
register: isping
until: isping.rc == 0
- debug:
msg: |
{{ isping }}
- 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:
act_worker:
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: Package procps-ng
ansible.builtin.dnf:
name: procps-ng
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 }}"