Skip to content

Commit 5879800

Browse files
committed
(gh-26) Add a GHA workflow to test the configure task
1 parent 06cb388 commit 5879800

File tree

1 file changed

+134
-0
lines changed

1 file changed

+134
-0
lines changed
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
---
2+
name: 'PR Testing the configure task'
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
branches:
10+
- main
11+
12+
jobs:
13+
test-configure-task:
14+
strategy:
15+
matrix:
16+
os:
17+
- [almalinux, '9']
18+
- [ubuntu, '24.04']
19+
runs-on: ubuntu-22.04
20+
steps:
21+
- uses: actions/checkout@v4
22+
- id: install-bolt
23+
uses: ./.github/actions/bolt
24+
with:
25+
os-codename: jammy
26+
- id: vm-cluster
27+
uses: jpartlow/nested_vms@v1
28+
with:
29+
os: ${{ matrix.os[0] }}
30+
os-version: ${{ matrix.os[1] }}
31+
os-arch: ${{ matrix.os[2] || 'x86_64' }}
32+
host-root-access: true
33+
ruby-version: '3.3'
34+
install-openvox: false
35+
vms: |-
36+
[
37+
{
38+
"role": "primary",
39+
"cpus": 4,
40+
"mem_mb": 8192
41+
"cpu_mode": "host-model"
42+
},
43+
{
44+
"role": "agent",
45+
"cpus": 2,
46+
"mem_mb": 4096,
47+
"cpu_mode": "host-model"
48+
}
49+
]
50+
- name: Capture dereferenced inventory for use with openvox_bootstrap
51+
working-directory: kvm_automation_tooling
52+
run: |-
53+
bolt inventory --inventory terraform/instances/inventory.test.yaml show --format json --detail | \
54+
jq '.inventory | with_entries(select(.key == "targets")) | del(.targets[0].groups)' | \
55+
yq -P > ../inventory.yaml
56+
- name: Install openvox
57+
run: |-
58+
bolt task run openvox_bootstrap::install --inventory inventory.yaml --targets test-primary-1,test-agent-1
59+
- name: Install openvox-server
60+
run: |-
61+
bolt task run openvox_bootstrap::install --inventory inventory.yaml --targets test-primary-1 package=openvox-server
62+
- name: Configure openvox-server
63+
env:
64+
PUPPET_CONF: |-
65+
SIGN_SH: |-
66+
run: |-
67+
cat > /etc/puppetlabs/puppet/puppet.conf <<EOF
68+
[main]
69+
server = test-primary-1.vm
70+
[server]
71+
autosign = /etc/puppetlabs/puppet/sign.sh
72+
EOF
73+
chown puppet:puppet /etc/puppetlabs/puppet/puppet.conf
74+
cat > /etc/puppetlabs/puppet/sign.sh <<'EOF'
75+
#!/bin/bash
76+
csr_pem=$(cat)
77+
csr_text=$(openssl req -text <<<"$csr_pem")
78+
password=$(awk -F: -e '/challengePassword/ { print $2 }' <<<"$csr_text")
79+
[[ "${password}" == 'password' ]]
80+
EOF
81+
cat /etc/puppetlabs/puppet/sign.sh
82+
chmod 750 /etc/puppetlabs/puppet/sign.sh
83+
chown puppet:puppet /etc/puppetlabs/puppet/sign.sh
84+
85+
/opt/puppetlabs/server/bin/puppetserver ca setup
86+
systemctl start puppetserver
87+
- name: Write configure params
88+
run: |-
89+
cat > agent-params.yaml <<EOF
90+
{
91+
"puppet_conf": {
92+
"main": {
93+
"server": "test-primary-1.vm"
94+
}
95+
},
96+
"csr_attributes": {
97+
"custom_attributes": {
98+
"1.2.840.113549.1.9.7": "password"
99+
},
100+
"extension_requests": {
101+
"pp_role": "tomato"
102+
}
103+
},
104+
"puppet_service_running": true,
105+
"puppet_service_enabled": false
106+
}
107+
EOF
108+
jq 'del(.puppet_conf)' agent-params.yaml > server-params.yaml
109+
- name: Disable agents to prevent background service runs
110+
run: |-
111+
bolt command run '/opt/puppetlabs/bin/puppet agent --disable "OpenVox PR testing"' --inventory inventory.yaml --targets test-agent-1,test-primary-1
112+
- name: Run openvox_bootstrap::configure task
113+
run: |-
114+
echo "On the primary:"
115+
bolt task run openvox_bootstrap::configure --inventory inventory.yaml --targets test-agent-1 --params @agent-params.yaml
116+
echo "On the agent:"
117+
bolt task run openvox_bootstrap::configure --inventory inventory.yaml --targets test-agent-1 --params @server-params.yaml
118+
- name: Validate agent run on the primary
119+
run: |-
120+
bolt command run '/opt/puppetlabs/bin/puppet agent --agent_disabled_lockfile=/dev/null --test' --inventory inventory.yaml --targets test-primary-1 --stream
121+
- name: Validate agent run on the agent
122+
run: |-
123+
bolt command run '/opt/puppetlabs/bin/puppet agent --agent_disabled_lockfile=/dev/null --test' --inventory inventory.yaml --targets test-agent-1 --stream
124+
- name: Validate certificate extensions
125+
run: |-
126+
cat > check_cert_extensions.pp <<'EOF'
127+
notify { "Trusted Facts"
128+
message => $trusted,
129+
}
130+
if $trusted['extensions']['pp_role'] != 'tomato' {
131+
fail("Certificate extension 'pp_role' should be 'tomato', but is ${$trusted['extensions']['pp_role']}")
132+
}
133+
EOF
134+
bolt apply check_cert_extensions.pp --inventory inventory.yaml --targets test-primary-1,test-agent-1

0 commit comments

Comments
 (0)