Skip to content

Commit f6e7968

Browse files
authored
Add necessary roles/playbooks for make show and make install functionality (#40)
1 parent 8c57aa0 commit f6e7968

File tree

29 files changed

+671
-26
lines changed

29 files changed

+671
-26
lines changed

.github/workflows/ansible-lint.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
name: Ansible Lint # feel free to pick your own name
1+
name: Ansible Lint
22

33
on: [push, pull_request]
44

55
jobs:
66
build:
77
runs-on: ubuntu-latest
8+
permissions:
9+
contents: read
810

911
steps:
10-
# Important: This sets up your GITHUB_WORKSPACE environment variable
11-
- uses: actions/checkout@v5
12+
- name: Checkout Code
13+
uses: actions/checkout@v5
14+
with:
15+
persist-credentials: false
1216

1317
- name: Lint Ansible Playbook
14-
uses: ansible/ansible-lint@main
15-
# Let's point it to the path
18+
uses: ansible/ansible-lint@50373efb440dd3b524956c075af715cd00eaf20b
1619
with:
1720
setup_python: "true"
18-
# args: ""
19-
# working_directory: ""

.github/workflows/ansible-sanitytest.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
---
22
name: Ansible collection sanity tests
33

4-
#
5-
# Documentation:
6-
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
7-
#
8-
94
on: [push, pull_request]
105

116
jobs:
@@ -16,12 +11,15 @@ jobs:
1611
python-version: [3.11.3, 3.12.6]
1712
ansible-core: ["2.16.*"]
1813
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
1916

2017
steps:
2118
- name: Checkout Code
2219
uses: actions/checkout@v5
2320
with:
2421
path: ansible_collections/rhvp/cluster_utils
22+
persist-credentials: false
2523

2624
- name: Set up Python ${{ matrix.python-version }}
2725
uses: actions/setup-python@v5

.github/workflows/ansible-unittest.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
---
22
name: Ansible unit tests
33

4-
#
5-
# Documentation:
6-
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
7-
#
8-
94
on: [push, pull_request]
105

116
jobs:
@@ -16,12 +11,15 @@ jobs:
1611
python-version: [3.11.3, 3.12.6]
1712
ansible-core: ["2.16.*"]
1813
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
1916

2017
steps:
2118
- name: Checkout Code
2219
uses: actions/checkout@v5
2320
with:
2421
path: ansible_collections/rhvp/cluster_utils
22+
persist-credentials: false
2523

2624
- name: Set up Python ${{ matrix.python-version }}
2725
uses: actions/setup-python@v5

.github/workflows/jsonschema.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ jobs:
1010
matrix:
1111
python-version: [3.11.3]
1212
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
1315

1416
steps:
1517
- name: Checkout Code
1618
uses: actions/checkout@v5
19+
with:
20+
persist-credentials: false
1721

1822
- name: Set up Python ${{ matrix.python-version }}
1923
uses: actions/setup-python@v5

.github/workflows/superlinter.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,24 @@ on: [push, pull_request]
55

66
jobs:
77
build:
8-
# Name the Job
98
name: Super linter
10-
# Set the agent to run on
119
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
1212

1313
steps:
1414
- name: Checkout Code
1515
uses: actions/checkout@v5
1616
with:
1717
# Full git history is needed to get a proper list of changed files within `super-linter`
1818
fetch-depth: 0
19+
persist-credentials: false
1920

2021
################################
2122
# Run Linter against code base #
2223
################################
2324
- name: Lint Code Base
24-
uses: super-linter/super-linter/slim@v8
25+
uses: super-linter/super-linter/slim@ffde3b2b33b745cb612d787f669ef9442b1339a6
2526
env:
2627
VALIDATE_ALL_CODEBASE: true
2728
DEFAULT_BRANCH: main

playbooks/install.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
- name: Install the pattern via pattern-install chart
3+
ansible.builtin.import_playbook: operator_deploy.yml
4+
5+
- name: Load secrets (if not explicity disabled in values-global.yaml)
6+
ansible.builtin.import_playbook: load_secrets.yml

playbooks/load_secrets.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
- name: Decide whether to load secrets
3+
hosts: localhost
4+
connection: local
5+
gather_facts: false
6+
roles:
7+
- role: pattern_settings
8+
9+
tasks:
10+
- name: Check values-global to see if secret loading is explicity disabled
11+
ansible.builtin.set_fact:
12+
secret_loader_disabled: "{{ values_global.global.secretLoader.disabled | default(false) | bool }}"
13+
14+
- name: Load secrets (when enabled)
15+
when: not secret_loader_disabled
16+
block:
17+
- name: Announce secrets loading
18+
ansible.builtin.shell: |
19+
printf "==> Loading secrets (this may take several minutes)...\n" > /dev/tty
20+
21+
- name: Process secrets via role
22+
ansible.builtin.include_role:
23+
name: load_secrets
24+
25+
- name: Print secret loading disabled message
26+
ansible.builtin.shell: |
27+
printf "==> Secrets loading is currently disabled. To enable, update the value of .global.secretLoader.disabled in your values-global.yaml to false.\n" > /dev/tty
28+
when: secret_loader_disabled

playbooks/manage_secret_app.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
block:
5454
- name: Add application '{{ application }}'
5555
ansible.builtin.command: |
56-
yq -i '.clusterGroup.applications.{{ app_def.name }} = {{ app_def | to_json }}' {{ yq_file }}
56+
yq -i '.clusterGroup.applications.{{ app_def.name }} = {{ app_def | to_json }}' {{ yq_file }}
5757
5858
- name: Manage application '{{ application }}' to be absent
5959
when: application_state == 'absent' and app_found

playbooks/operator_deploy.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
- name: Install pattern (using pattern-install chart)
3+
hosts: localhost
4+
connection: local
5+
gather_facts: false
6+
7+
roles:
8+
- role: pattern_settings # set general pattern vars
9+
- role: install_settings # set pattern-install specific vars
10+
- role: validate_prereq # ensure installation depencies are present
11+
- role: validate_cluster # ensure a cluster is connected and has a default storage class
12+
- role: pattern_install_template # render the pattern-install helm chart
13+
14+
tasks:
15+
- name: Origin validation (optional, controlled by DISABLE_VALIDATE_ORIGIN / disable_validate_origin)
16+
block:
17+
- name: Resolve disable_validate_origin flag
18+
ansible.builtin.set_fact:
19+
disable_validate_origin: >-
20+
{{
21+
(
22+
disable_validate_origin
23+
| default(lookup('env', 'DISABLE_VALIDATE_ORIGIN'), true)
24+
| default('false', false)
25+
) | bool
26+
}}
27+
28+
- name: Validate origin (remote/branch must exist)
29+
ansible.builtin.include_role:
30+
name: validate_origin
31+
when: not disable_validate_origin
32+
33+
- name: Apply rendered pattern-install chart manifests (with retry)
34+
block:
35+
- name: Preview manifest that will be applied
36+
ansible.builtin.shell: |
37+
printf "==> Applying the following manifest to the cluster:\n\n" > /dev/tty
38+
printf "%s\n" "{{ pattern_install_rendered_yaml }}" > /dev/tty
39+
40+
- name: Apply via oc with retry
41+
ansible.builtin.command: oc apply -f -
42+
args:
43+
stdin: "{{ pattern_install_rendered_yaml }}"
44+
stdin_add_newline: false
45+
register: _apply
46+
retries: 10
47+
delay: 15
48+
until: _apply.rc == 0
49+
50+
- name: Print success message
51+
ansible.builtin.shell: printf "==> Installation succeeded!\n" > /dev/tty
52+
53+
rescue:
54+
- name: Print failure summary and abort
55+
ansible.builtin.shell: |
56+
printf "==> Installation failed. Error:\n" > /dev/tty
57+
printf "%s\n" "{{ _apply.stderr | default(_apply.stdout) | default('') }}" > /dev/tty
58+
exit 1

playbooks/show.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
- name: Template patttern-install chart
3+
hosts: localhost
4+
connection: local
5+
gather_facts: false
6+
roles:
7+
- role: pattern_settings # set general pattern vars
8+
- role: install_settings # set pattern-install specific vars
9+
- role: pattern_install_template # render the pattern-install helm chart
10+
11+
tasks:
12+
- name: Print rendered pattern-install chart manifests
13+
ansible.builtin.shell: |
14+
printf "\n%s\n" "{{ pattern_install_rendered_yaml }}" > /dev/tty

0 commit comments

Comments
 (0)