tofu and molecule combined test, first try
Some checks failed
Gitea Actions - molecule test work / Explore-terraform-molecule-Gitea-Action (push) Failing after 1m15s
Some checks failed
Gitea Actions - molecule test work / Explore-terraform-molecule-Gitea-Action (push) Failing after 1m15s
This commit is contained in:
parent
5cbd574a02
commit
189e33d9f4
@ -20,10 +20,10 @@ jobs:
|
||||
- name: tofu output capture
|
||||
run: |
|
||||
export TARGET_IP_ADDRESS=$(tofu output -raw act_worker_ip_address)
|
||||
echo $TARGET_IP_ADDRESS
|
||||
sleep 300
|
||||
cd ${{ gitea.workspace}}/podman-host/extensions
|
||||
molecule test
|
||||
working-directory: "${{ gitea.workspace }}/.gitea/tofu"
|
||||
- name: tofu destroy
|
||||
run: "tofu destroy -auto-approve"
|
||||
run: "sleep 180 && tofu destroy -auto-approve"
|
||||
working-directory: "${{ gitea.workspace }}/.gitea/tofu"
|
||||
|
||||
|
||||
@ -4,53 +4,91 @@
|
||||
connection: local
|
||||
gather_facts: false
|
||||
# no_log: "{{ molecule_no_log }}"
|
||||
tasks:
|
||||
# TODO: Developer must implement and populate 'server' variable
|
||||
- name: Import state into tofu
|
||||
command:
|
||||
cmd: |
|
||||
{{ item }}
|
||||
chdir: "/workspace/seasharp/ansible-role_podman-host/tofu"
|
||||
loop:
|
||||
- tofu init
|
||||
- tofu import module.main_vpc_subnet.linode_vpc.eqit_vpc {{ lookup('env', 'EQIT_VPC') }}
|
||||
- tofu import module.main_vpc_subnet.linode_vpc_subnet.eqit_vpc_subnet "{{ lookup('env', 'EQIT_VPC') }}, {{ lookup('env', 'EQIT_VPC_SUBNET') }}"
|
||||
- tofu refresh
|
||||
vars:
|
||||
molecule_inventory:
|
||||
all:
|
||||
hosts: {}
|
||||
linode: {}
|
||||
|
||||
- name: Tofu show
|
||||
tasks:
|
||||
- name: Confirm we can reach
|
||||
command:
|
||||
cmd: |
|
||||
tofu state ls
|
||||
chdir: "/workspace/seasharp/ansible-role_podman-host/tofu"
|
||||
register: mycmd
|
||||
## grep names from subnet data
|
||||
## tofu import module.instance
|
||||
cmd: "ping -c5 {{ lookup('env', 'TARGET_IP_ADDRESS') }}"
|
||||
register: isping
|
||||
|
||||
- debug:
|
||||
msg: |
|
||||
{{ mycmd.stdout_lines }}
|
||||
# - name: Create instance config
|
||||
# when: server.changed | default(false) | bool # noqa no-handler
|
||||
# block:
|
||||
# - name: Populate instance config dict # noqa jinja
|
||||
# ansible.builtin.set_fact:
|
||||
# instance_conf_dict: {}
|
||||
# # instance': "{{ }}",
|
||||
# # address': "{{ }}",
|
||||
# # user': "{{ }}",
|
||||
# # port': "{{ }}",
|
||||
# # 'identity_file': "{{ }}", }
|
||||
# with_items: "{{ server.results }}"
|
||||
# register: instance_config_dict
|
||||
#
|
||||
# - name: Convert instance config dict to a list
|
||||
# ansible.builtin.set_fact:
|
||||
# instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}"
|
||||
#
|
||||
# - name: Dump instance config
|
||||
# ansible.builtin.copy:
|
||||
# content: |
|
||||
# # Molecule managed
|
||||
#
|
||||
# {{ instance_conf | to_json | from_json | to_yaml }}
|
||||
# dest: "{{ molecule_instance_config }}"
|
||||
# mode: "0600"
|
||||
"{{ 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 }}"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user