Compare commits
42 Commits
master
...
tofu-linod
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16d5fe607d | ||
|
|
193c5485fe | ||
|
|
5bcc48a2b6 | ||
|
|
fb97fd0adf | ||
|
|
cb3017206b | ||
|
|
f8c1e31062 | ||
|
|
af9073354f | ||
|
|
604bbceaeb | ||
|
|
2a28432984 | ||
|
|
9c91ccca44 | ||
|
|
5f70f076cc | ||
|
|
88f848cb20 | ||
|
|
05751e3dbf | ||
|
|
f3306efb0f | ||
|
|
f073fbd981 | ||
|
|
943553d4a6 | ||
|
|
188bf20236 | ||
|
|
857fb87791 | ||
|
|
f019cf8c04 | ||
|
|
eeea2d4485 | ||
|
|
0c1d2a0de3 | ||
|
|
ae0eb538e4 | ||
|
|
d753983fb5 | ||
|
|
17e4c288b8 | ||
|
|
b1a396a3ba | ||
|
|
4e3f239259 | ||
|
|
f5cd8f6491 | ||
|
|
3dacc06c64 | ||
|
|
2572c7cb1a | ||
|
|
6cbf0889d7 | ||
|
|
c29ad94601 | ||
|
|
756158ccdb | ||
|
|
248a5291b7 | ||
|
|
01f16a40c4 | ||
|
|
e8d36340de | ||
|
|
f8696ae0c9 | ||
|
|
9543799cc6 | ||
|
|
003c6646d1 | ||
|
|
ab623685fe | ||
|
|
1cdd3d4a9b | ||
|
|
3bbfad68bd | ||
|
|
c8329a242b |
@ -1,28 +0,0 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
linode = {
|
||||
source = "linode/linode"
|
||||
# version = "..."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Configure the Linode Provider
|
||||
provider "linode" {
|
||||
token = var.token
|
||||
}
|
||||
|
||||
resource "linode_instance" "eqit_test_instance" {
|
||||
image = "linode/almalinux9"
|
||||
label = "act_worker"
|
||||
region = "us-ord"
|
||||
type = "g6-nanode-1"
|
||||
authorized_keys = ["ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCeRI1w3uNny7KjK2UdlAnyoGdGgtOx4isSD52u5dr4QkkdLRMj42dLjgT0MK+QehlgaH2XzFPMDz+hZQ+66YeBSm+F4km/8F9XVyUzGl0scUA1p0pqeL3FiyM3Art4Bo71zuE3PvMjyI3pGMKQ3VDWVA0XdAjjSw4G+czJTxZLLBPGvzDT07WuWM4Evl6H21Gn7PB6CKNV0vuUZwGiCsjRbghml1L2kDtTXV1B6wQsniuhQigIVo6YXhMgge/2UCcmiyeEizdfaSstrQHEyxFMvlPUJyw4a3plAuPORDyZdAFF6OA7/wP5fVWoCu/CkbMIDjPifXGQOuhQU1qUVy7r m00t@miserver.lan","ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINi1TmECeYdnrw8OCiBVB+rm8SwBWcz98Se/q+3l3iM/ act_runner@miserver.lan"]
|
||||
root_pass = "supersecrettestpassword"
|
||||
}
|
||||
|
||||
variable "token" {}
|
||||
|
||||
output "act_worker_ip_address" {
|
||||
value = linode_instance.eqit_test_instance.ip_address
|
||||
}
|
||||
@ -2,8 +2,8 @@ name: Gitea Actions - molecule test work
|
||||
run-name: ${{ gitea.actor }} is running molecule test work
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'molecule-test'
|
||||
branches:
|
||||
- molecule-test
|
||||
|
||||
jobs:
|
||||
Explore-molecule-Gitea-Action:
|
||||
|
||||
@ -9,28 +9,48 @@ jobs:
|
||||
Explore-terraform-molecule-Gitea-Action:
|
||||
env:
|
||||
ANSIBLE_ROLES_PATH: '/workspace/seasharp/ansible-role_podman-host'
|
||||
TF_VAR_token: "${{ secrets.LINODE_API_TOKEN }}"
|
||||
|
||||
TF_VAR_token: '3cc179bda24ac499f6d7ffbaa48d4a1def3f048483861d09d6cd9346e87e2b36'
|
||||
TF_VAR_root_pass: 'supersecretpassword'
|
||||
# ANSIBLE_REMOTE_TMP: '/root/.ansible/tmp/'
|
||||
# Add comment for CI debug
|
||||
EQIT_VPC: '136994'
|
||||
EQIT_VPC_SUBNET: '131754'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
path: 'podman-host'
|
||||
- uses: opentofu/setup-opentofu@v1
|
||||
- name: tofu apply
|
||||
run: "tofu init && tofu apply -auto-approve"
|
||||
working-directory: "${{ gitea.workspace }}/podman-host/.gitea/tofu"
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
- name: molecule test
|
||||
continue-on-error: true
|
||||
run: |
|
||||
export TARGET_IP_ADDRESS=$(tofu output -raw act_worker_ip_address)
|
||||
export ACT_RUNNER_DEPLOY_KEY="${{ secrets.ACT_RUNNER_DEPLOY_KEY }}"
|
||||
cd ${{ gitea.workspace}}/podman-host/extensions
|
||||
molecule test -s linode
|
||||
working-directory: "${{ gitea.workspace }}/podman-host/.gitea/tofu"
|
||||
- name: tofu destroy
|
||||
run: "sleep 180 && tofu destroy -auto-approve"
|
||||
working-directory: "${{ gitea.workspace }}/podman-host/.gitea/tofu"
|
||||
|
||||
run:
|
||||
working-directory: '${{ env.tf_actions_working_dir }}'
|
||||
# - name: Update ssh config
|
||||
# run: |
|
||||
# umask 077
|
||||
# mkdir .ssh
|
||||
# echo -e "Host git.libre.audio\n Port 2222" >> ~/.ssh/config
|
||||
# - name: tofu Checkout
|
||||
# uses: actions/checkout@v4
|
||||
# with:
|
||||
# repository: 'seasharp/eqit_tofu-plan'
|
||||
# ref: 'refs/heads/main'
|
||||
# path: 'tofu'
|
||||
# ssh-key: |-
|
||||
# -----BEGIN OPENSSH PRIVATE KEY-----
|
||||
# b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
|
||||
# QyNTUxOQAAACCrwBEqzNuM0VFHpy9bBprXebPnu6oZFBfucpT1k3Bv8gAAAJh9CogdfQqI
|
||||
# HQAAAAtzc2gtZWQyNTUxOQAAACCrwBEqzNuM0VFHpy9bBprXebPnu6oZFBfucpT1k3Bv8g
|
||||
# AAAECnSrigm9ALsWTb6RnDhDFV/nViuPK1jzoE+FAmrwYfdavAESrM24zRUUenL1sGmtd5
|
||||
# s+e7qhkUF+5ylPWTcG/yAAAAEW0wMHRAbWlzZXJ2ZXIubGFuAQIDBA==
|
||||
# -----END OPENSSH PRIVATE KEY-----
|
||||
# ssh-known-hosts: |
|
||||
# git.libre.audio ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFLiDhNN7aPdGUt8gvvAftF5Oo3xwsy/JcT9gcX00BDW
|
||||
# [git.libre.audio]:2222 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFLiDhNN7aPdGUt8gvvAftF5Oo3xwsy/JcT9gcX00BDW
|
||||
#
|
||||
# - name: Project Checkout
|
||||
# uses: actions/checkout@v4
|
||||
# with:
|
||||
# path: 'podman-host'
|
||||
# - name: Set up Python
|
||||
# uses: actions/setup-python@v2
|
||||
# - name: Molecule test
|
||||
# run: |
|
||||
# cd podman-host/extensions
|
||||
# molecule test -s linode
|
||||
|
||||
@ -91,9 +91,9 @@
|
||||
gather_facts: false
|
||||
|
||||
tasks:
|
||||
- name: Package procps-ng
|
||||
- name: Packages openssh-server, python3-policycoreutils
|
||||
ansible.builtin.dnf:
|
||||
name: procps-ng
|
||||
name: ['openssh-server', 'python3-policycoreutils']
|
||||
state: present
|
||||
|
||||
- name: systemd PID
|
||||
|
||||
@ -9,7 +9,7 @@ driver:
|
||||
ansible_connection: docker
|
||||
platforms:
|
||||
- name: instance
|
||||
image: geerlingguy/docker-${MOLECULE_DISTRO:-rockylinux9}-ansible:latest
|
||||
image: geerlingguy/docker-rockylinux9-ansible:latest
|
||||
command: "/sbin/init"
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
|
||||
@ -1,26 +1,8 @@
|
||||
---
|
||||
- name: Fail if linode group is missing
|
||||
hosts: localhost
|
||||
tasks:
|
||||
- name: Print some info
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ groups }}"
|
||||
|
||||
- name: Assert group existence
|
||||
ansible.builtin.assert:
|
||||
that: "'linode' in groups"
|
||||
fail_msg: |
|
||||
linode group was not found inside inventory groups: {{ groups }}
|
||||
|
||||
- name: Converge
|
||||
hosts: linode
|
||||
# We disable gather facts because it would fail due to our container not
|
||||
# having python installed. This will not prevent use from running 'raw'
|
||||
# commands. Most molecule users are expected to use containers that already
|
||||
# have python installed in order to avoid notable delays installing it.
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Apply podman-host Role
|
||||
include_role:
|
||||
name: podman-host
|
||||
# ansible.builtin.assert:
|
||||
# that: result.stdout | regex_search("^Linux")
|
||||
- name: Replace this task with one that validates your content
|
||||
ansible.builtin.debug:
|
||||
msg: "This is the effective test"
|
||||
|
||||
@ -4,110 +4,53 @@
|
||||
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
|
||||
# TODO: Developer must implement and populate 'server' variable
|
||||
- name: Import state into tofu
|
||||
command:
|
||||
cmd: |
|
||||
ssh -vv -T act_worker
|
||||
retries: 12
|
||||
delay: 10
|
||||
register: isping
|
||||
until: isping.rc == 0
|
||||
{{ 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
|
||||
|
||||
- name: Tofu show
|
||||
command:
|
||||
cmd: |
|
||||
tofu state ls
|
||||
chdir: "/workspace/seasharp/ansible-role_podman-host/tofu"
|
||||
register: mycmd
|
||||
## grep names from subnet data
|
||||
## tofu import module.instance
|
||||
- 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 }}"
|
||||
{{ 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"
|
||||
|
||||
@ -5,11 +5,20 @@
|
||||
gather_facts: false
|
||||
# no_log: "{{ molecule_no_log }}"
|
||||
tasks:
|
||||
- name: Remove dynamic molecule inventory
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Remove dynamic inventory file
|
||||
ansible.builtin.file:
|
||||
path: "{{ molecule_ephemeral_directory }}/inventory/molecule_inventory.yml"
|
||||
state: absent # Developer must implement.
|
||||
# Developer must implement.
|
||||
|
||||
# Mandatory configuration for Molecule to function.
|
||||
|
||||
- name: Populate instance config
|
||||
ansible.builtin.set_fact:
|
||||
instance_conf: {}
|
||||
|
||||
- name: Dump instance config
|
||||
ansible.builtin.copy:
|
||||
content: |
|
||||
# Molecule managed
|
||||
|
||||
{{ instance_conf | to_json | from_json | to_yaml }}
|
||||
dest: "{{ molecule_instance_config }}"
|
||||
mode: "0600"
|
||||
when: server.changed | default(false) | bool # noqa no-handler
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
collections:
|
||||
- community.general
|
||||
@ -1,17 +1,8 @@
|
||||
- import_tasks: include-vars.yml
|
||||
|
||||
- name: Install podman, podman networking plugins, and python support packages
|
||||
vars:
|
||||
dnf_packages:
|
||||
- 'openssh-server'
|
||||
- 'podman'
|
||||
- 'podman-plugins'
|
||||
- 'systemd-container'
|
||||
- 'containernetworking-plugins'
|
||||
- 'python3-pip'
|
||||
- 'python3-policycoreutils'
|
||||
dnf:
|
||||
name: "{{ dnf_packages }}"
|
||||
name: ['podman', 'containernetworking-plugins', 'podman-plugins', 'python3-pip', 'systemd-container']
|
||||
state: present
|
||||
|
||||
- name: Install podman-compose pip Package
|
||||
@ -30,7 +21,6 @@
|
||||
- "{{ service_users }}"
|
||||
|
||||
- name: Create service folders
|
||||
become: yes
|
||||
become_user: "{{ item.0.name }}"
|
||||
file:
|
||||
path: "/home/{{ item.0.name }}/{{ item.1 }}"
|
||||
@ -111,7 +101,8 @@
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
when: '"molecule" not in group_names'
|
||||
tags:
|
||||
- 'molecule-notest'
|
||||
|
||||
- lineinfile:
|
||||
path: /etc/hosts
|
||||
@ -120,7 +111,8 @@
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
when: '"molecule" not in group_names'
|
||||
tags:
|
||||
- 'molecule-notest'
|
||||
# - name: Copy cni networking driver config into place
|
||||
# blockinfile:
|
||||
# name: "/etc/cni/net.d/podman.conflist"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user