-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaction.yml
103 lines (91 loc) · 3.36 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
---
name: "FreeIPA-Cluster-Test"
description: "Run test playbooks against a FreeIPA cluster"
inputs:
cluster_configuration:
description: "An ipalab-config cluster configuration."
required: true
test_playbooks:
description: "Test playbooks to be executed using the cluster."
required: true
distro:
description: "Default distro. Any accepted by 'ipalab-config'."
required: false
ansible_vars:
description: "Path to file with variables to be used when running the playbooks"
required: false
ansible_requirements:
description: "An Ansible requirements file for the test playbooks."
required: false
runs:
using: "composite"
steps:
- name: Verify entries
shell: bash
run: |
# Report entry verification
echo "Config: ${{ inputs.cluster_configuration }}"
[ -f "${{ inputs.cluster_configuration }}" ] || echo "Config file not found"
echo "Playbooks:"
for playbook in ${{ inputs.test_playbooks }}
do
echo -n " - ${playbook}"
[ -f "${playbook}" ] && echo ": OK" || echo ": Not found"
done
echo "ansible-requirements: ${{ inputs.ansible_requirements || 'None' }}"
if [ -n "${{ inputs.ansible_requirements }}" ] && [ ! -f "${{ inputs.ansible_requirements }}" ]
then
echo "Requirements file not found."
fi
# Fail step if any entry isn't valid.
[ -f "${{ inputs.cluster_configuration }}" ] || exit 1
for playbook in ${{ inputs.test_playbooks }}
do
[ -f "${playbook}" ] || exit 1
done
if [ -n "${{ inputs.ansible_requirements }}" ] && [ ! -f "${{ inputs.ansible_requirements }}" ]
then
exit 1
fi
- name: Install dependencies
shell: bash
run: |
sudo apt update -y
sudo apt install libkrb5-dev libvirt-dev
sudo apt install software-properties-common
sudo apt install ansible-core podman
- name: Setup ipalab config
shell: bash
run: |
python3 -m venv venv
source venv/bin/activate
pip3 install "ipalab-config>=0.6"
ipalab-config -d ${{ inputs.distro || 'fedora-latest' }} -o CONFIG_DIR ${{ inputs.cluster_configuration }}
- name: Create cluster pod
shell: bash
run: |
source venv/bin/activate
pip3 install podman-compose
cd CONFIG_DIR
podman-compose -f compose.yml up -d
- name: Ensure '/ect/shadow' is readable
shell: bash
run: ansible -i CONFIG_DIR/inventory.yml -m "ansible.builtin.shell" -a "chmod u+r /etc/shadow" -vvvv all
- name: Deploy cluster
shell: bash
run: |
ansible-galaxy collection install -r CONFIG_DIR/requirements.yml
ansible-playbook -i CONFIG_DIR/inventory.yml CONFIG_DIR/playbooks/install-cluster.yml
- name: Install Ansible collections
if: ${{ inputs.ansible_requirements }}
shell: bash
run: ansible-galaxy collection install -r ${{ inputs.ansible_requirements }}
- name: Run Ansible test playboooks
shell: bash
run: |
for playbook in ${{ inputs.test_playbooks }}
do
echo "Running playbook: ${playbook}"
[ -n "${{ inputs.ansible_vars }}" ] && extra_opts="-e '@${{ inputs.ansible_vars}}'"
ansible-playbook -i CONFIG_DIR/inventory.yml ${extra_opts} "${playbook}"
done