Skip to content

Commit 07f0078

Browse files
Alex-WelshmarkgoddardMoteHuepriteau
authored
Add ansible-lint CI (#1368)
CI: Add Ansible lint job Co-authored-by: Mark Goddard <[email protected]> Co-authored-by: Matt Crees <[email protected]> Co-authored-by: Pierre Riteau <[email protected]>
1 parent 76433b6 commit 07f0078

File tree

71 files changed

+661
-541
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+661
-541
lines changed

.ansible-lint

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
skip_list:
3+
- no-changed-when
4+
- risky-file-permissions
5+
- run-once
6+
- name[template]
7+
- package-latest
8+
- yaml
9+
- role-name[path]
10+
- yaml[line-length]

.ansible-lint-ignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This file contains ignores to rule violations for ansible-lint
2+
etc/kayobe/ansible/vault-deploy-barbican.yml fqcn[action-core]
3+
etc/kayobe/ansible/vault-generate-backend-tls.yml fqcn[action-core]
4+
etc/kayobe/ansible/vault-generate-internal-tls.yml fqcn[action-core]
5+
etc/kayobe/ansible/vault-generate-test-external-tls.yml fqcn[action-core]
6+
etc/kayobe/ansible/rabbitmq-reset.yml command-instead-of-module
7+
etc/kayobe/ansible/ubuntu-upgrade.yml syntax-check[missing-file]

.github/workflows/stackhpc-pull-request.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,43 @@ jobs:
6161
- name: Run Tox ${{ matrix.environment }} 🧪
6262
run: tox -e ${{ matrix.environment }}
6363

64+
lint:
65+
runs-on: ubuntu-22.04
66+
permissions: {}
67+
strategy:
68+
fail-fast: false
69+
matrix:
70+
include:
71+
# NOTE(upgrade): Keep these in sync with Kayobe's supported Ansible and Python versions (see release notes).
72+
- ansible: "2.16"
73+
python: "3.12"
74+
- ansible: "2.15"
75+
python: "3.10"
76+
name: Ansible ${{ matrix.ansible }} lint with Python ${{ matrix.python }}
77+
if: github.repository == 'stackhpc/stackhpc-kayobe-config'
78+
steps:
79+
- name: GitHub Checkout 🛎
80+
uses: actions/checkout@v3
81+
82+
- name: Setup Python ${{ matrix.python-version }} 🐍
83+
uses: actions/setup-python@v4
84+
with:
85+
python-version: ${{ matrix.python }}
86+
87+
- name: Install dependencies 📦
88+
run: |
89+
python -m pip install --upgrade pip
90+
pip install ansible-core==${{ matrix.ansible }}.* ansible-lint -r requirements.txt
91+
92+
- name: Install Ansible Galaxy collections and roles
93+
run: |
94+
ansible-galaxy collection install -r etc/kayobe/ansible/requirements.yml
95+
ansible-galaxy role install -r etc/kayobe/ansible/requirements.yml
96+
97+
- name: Linting code 🧪
98+
run: |
99+
ansible-lint -v --force-color etc/kayobe/ansible/.
100+
64101
# A skipped job is treated as success when used as a required status check.
65102
# The registered required status checks refer to the name of the job in the
66103
# called reusable workflow rather than the jobs in this file. The following

etc/kayobe/ansible/advise-run.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
---
22
- name: ADVise run
33
hosts: localhost
4-
gather_facts: no
4+
gather_facts: false
55
tags:
66
- advise
77
vars:
8-
venv: "~/venvs/advise-review"
8+
venv: ~/venvs/advise-review
99
input_dir: "{{ lookup('env', 'PWD') }}/overcloud-introspection-data"
1010
output_dir: "{{ lookup('env', 'PWD') }}/review"
11-
advise_pattern: ".*.eval" # Uses regex
11+
advise_pattern: .*.eval # Uses regex
1212
tasks:
1313
- name: Install dependencies
14-
pip:
14+
ansible.builtin.pip:
1515
virtualenv: "{{ venv }}"
1616
name:
1717
- git+https://github.com/stackhpc/ADVise
1818
state: latest
19-
virtualenv_command: "python3 -m venv"
19+
virtualenv_command: python3 -m venv
2020

2121
- name: Create data directory
22-
file:
23-
path: '{{ output_dir }}/data'
22+
ansible.builtin.file:
23+
path: "{{ output_dir }}/data"
2424
state: directory
2525

2626
- name: Extract data
27-
shell:
27+
ansible.builtin.shell:
2828
cmd: >
2929
{{ venv }}/bin/m2-extract {{ input_dir }}/*.json --output_dir {{ output_dir }}/data
3030
3131
- name: Create review directory
32-
file:
33-
path: '{{ output_dir }}/results'
32+
ansible.builtin.file:
33+
path: "{{ output_dir }}/results"
3434
state: directory
3535

3636
- name: Process data
37-
shell:
37+
ansible.builtin.shell:
3838
cmd: >
3939
{{ venv }}/bin/advise-process
4040
-I ipmi
4141
-p '{{ output_dir }}/data/extra-hardware/{{ advise_pattern }}'
4242
-o '{{ output_dir }}'
4343
4444
- name: Visualise data
45-
command: >
45+
ansible.builtin.command: >
4646
{{ venv }}/bin/advise-visualise
4747
--output_dir '{{ output_dir }}'

etc/kayobe/ansible/build-ofed-rocky.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
tasks:
77
- name: Check whether noexec is enabled for /var/tmp
88
ansible.builtin.lineinfile:
9-
path: "/etc/fstab"
10-
regexp: "noexec"
9+
path: /etc/fstab
10+
regexp: noexec
1111
state: absent
1212
changed_when: false
1313
check_mode: true
@@ -42,7 +42,7 @@
4242

4343
- name: Add DOCA host repository package
4444
ansible.builtin.dnf:
45-
name: https://developer.nvidia.com/downloads/networking/secure/doca-sdk/DOCA_2.8/doca-host-2.8.0-204000_{{ stackhpc_pulp_doca_ofed_version }}_rhel9{{ stackhpc_pulp_repo_rocky_9_minor_version }}.x86_64.rpm
45+
name: "https://developer.nvidia.com/downloads/networking/secure/doca-sdk/DOCA_2.8/doca-host-2.8.0-204000_{{ stackhpc_pulp_doca_ofed_version }}_rhel9{{ stackhpc_pulp_repo_rocky_9_minor_version }}.x86_64.rpm"
4646
disable_gpg_check: true
4747

4848
- name: Install DOCA extra packages
@@ -53,13 +53,13 @@
5353
ansible.builtin.file:
5454
path: /home/cloud-user/ofed
5555
state: directory
56-
mode: 0777
56+
mode: "0777"
5757

5858
- name: Set build directory
5959
ansible.builtin.replace:
6060
path: /opt/mellanox/doca/tools/doca-kernel-support
61-
regexp: 'TMP_DIR=\$1'
62-
replace: 'TMP_DIR=/home/cloud-user/ofed'
61+
regexp: TMP_DIR=\$1
62+
replace: TMP_DIR=/home/cloud-user/ofed
6363

6464
- name: Build OFED kernel modules
6565
ansible.builtin.shell:

etc/kayobe/ansible/cephadm-commands-post.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
- cephadm
88
- cephadm-commands
99
tasks:
10-
- import_role:
10+
- name: Apply Cephadm commands role
11+
ansible.builtin.import_role:
1112
name: stackhpc.cephadm.commands
1213
vars:
1314
cephadm_commands: "{{ cephadm_commands_post | default([]) }}"

etc/kayobe/ansible/cephadm-commands-pre.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
- cephadm
88
- cephadm-commands
99
tasks:
10-
- import_role:
10+
- name: Apply Cephadm commands role
11+
ansible.builtin.import_role:
1112
name: stackhpc.cephadm.commands
1213
vars:
1314
cephadm_commands: "{{ cephadm_commands_pre | default([]) }}"

etc/kayobe/ansible/cephadm-crush-rules.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
- cephadm
88
- cephadm-crush-rules
99
tasks:
10-
- import_role:
10+
- name: Apply Cephadm crush rule role
11+
ansible.builtin.import_role:
1112
name: stackhpc.cephadm.crush_rules

etc/kayobe/ansible/cephadm-deploy.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
- cephadm
88
- cephadm-deploy
99
tasks:
10-
- import_role:
10+
- name: Apply Cephadm role
11+
ansible.builtin.import_role:
1112
name: stackhpc.cephadm.cephadm

etc/kayobe/ansible/cephadm-ec-profiles.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
- cephadm
88
- cephadm-ec-profiles
99
tasks:
10-
- import_role:
10+
- name: Apply Cephadm EC profiles role
11+
ansible.builtin.import_role:
1112
name: stackhpc.cephadm.ec_profiles

etc/kayobe/ansible/cephadm-gather-keys.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@
3232
loop: "{{ kolla_ceph_services | selectattr('required') | map(attribute='keys') | flatten | unique }}"
3333

3434
- name: Generate ceph.conf
35-
command: "cephadm shell -- ceph config generate-minimal-conf"
35+
ansible.builtin.command: cephadm shell -- ceph config generate-minimal-conf
3636
become: true
3737
register: cephadm_ceph_conf
3838
changed_when: false
3939

4040
- name: Ensure Kolla config directories are present
41-
file:
41+
ansible.builtin.file:
4242
state: directory
4343
path: "{{ kayobe_env_config_path }}/kolla/config/{{ kolla_service_to_key_dir[item.name] }}"
4444
loop: "{{ kolla_ceph_services | selectattr('required') }}"
@@ -51,7 +51,7 @@
5151
key_info: "{{ cephadm_key_info.results | selectattr('item', 'equalto', item.1) | first }}"
5252
cephadm_key: "{{ key_info.stdout }}"
5353
cephadm_user: "{{ item.1 }}"
54-
copy:
54+
ansible.builtin.copy:
5555
# Include a trailing newline.
5656
content: |
5757
{{ cephadm_key }}
@@ -63,7 +63,7 @@
6363
notify: Please add and commit the Kayobe configuration
6464

6565
- name: Save ceph.conf to Kayobe configuration
66-
copy:
66+
ansible.builtin.copy:
6767
# Include a trailing newline.
6868
# Kolla Ansible's merge_configs module does not like the leading tabs in ceph.conf.
6969
content: |
@@ -77,7 +77,7 @@
7777

7878
handlers:
7979
- name: Please add and commit the Kayobe configuration
80-
debug:
80+
ansible.builtin.debug:
8181
msg: >-
8282
Please add and commit the Ceph configuration files and keys in Kayobe
8383
configuration. Remember to encrypt the keys using Ansible Vault.

etc/kayobe/ansible/cephadm-keys.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
- cephadm
88
- cephadm-keys
99
tasks:
10-
- import_role:
10+
- name: Apply Cephadm keys role
11+
ansible.builtin.import_role:
1112
name: stackhpc.cephadm.keys

etc/kayobe/ansible/cephadm-pools.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
- cephadm
88
- cephadm-keys
99
tasks:
10-
- import_role:
10+
- name: Apply Cephadm pools role
11+
ansible.builtin.import_role:
1112
name: stackhpc.cephadm.pools

etc/kayobe/ansible/cephadm.yml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
---
22
# Deploy Ceph via Cephadm. Create EC profiles, CRUSH rules, pools and keys.
3-
- import_playbook: cephadm-deploy.yml
4-
- import_playbook: cephadm-commands-pre.yml
5-
- import_playbook: cephadm-ec-profiles.yml
6-
- import_playbook: cephadm-crush-rules.yml
7-
- import_playbook: cephadm-pools.yml
8-
- import_playbook: cephadm-keys.yml
9-
- import_playbook: cephadm-commands-post.yml
3+
- name: Import Cephadm deploy playbook
4+
import_playbook: cephadm-deploy.yml
5+
6+
- name: Import Cephadm commands pre playbook
7+
import_playbook: cephadm-commands-pre.yml
8+
9+
- name: Import Cephadm EC profiles playbook
10+
import_playbook: cephadm-ec-profiles.yml
11+
12+
- name: Import Cephadm crush rules playbook
13+
import_playbook: cephadm-crush-rules.yml
14+
15+
- name: Import Cephadm pools playbook
16+
import_playbook: cephadm-pools.yml
17+
18+
- name: Import Cephadm keys playbook
19+
import_playbook: cephadm-keys.yml
20+
21+
- name: Import Cephadm commands post playbook
22+
import_playbook: cephadm-commands-post.yml

etc/kayobe/ansible/check-tags.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@
77
gather_facts: false
88
tasks:
99
- name: Query images and tags
10-
command:
10+
ansible.builtin.command:
1111
cmd: >-
1212
{{ kayobe_config_path }}/../../tools/kolla-images.py list-tags
1313
register: kolla_images_result
1414
changed_when: false
1515

1616
- name: Set a fact about images and tags
17-
set_fact:
17+
ansible.builtin.set_fact:
1818
kolla_images: "{{ kolla_images_result.stdout | from_yaml }}"
1919

2020
# Use state=read and allow_missing=false to check for missing tags in test pulp.
21-
- import_role:
21+
- name: Check for missing tags
22+
ansible.builtin.import_role:
2223
name: stackhpc.pulp.pulp_container_content
2324
vars:
2425
pulp_container_content: >-

etc/kayobe/ansible/cis.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
32
- name: Security hardening
43
hosts: cis-hardening
54
become: true
@@ -9,14 +8,14 @@
98
# TODO: Remove this when Red Hat FIPS policy has been updated to allow ed25519 keys.
109
# https://gitlab.com/gitlab-org/gitlab/-/issues/367429#note_1840422075
1110
- name: Assert that we are using a supported SSH key
12-
assert:
11+
ansible.builtin.assert:
1312
that:
1413
- ssh_key_type != 'ed25519'
1514
fail_msg: FIPS policy does not currently support ed25519 SSH keys on RHEL family systems
1615
when: ansible_facts.os_family == 'RedHat'
1716

1817
- name: Ensure the cron package is installed on ubuntu
19-
package:
18+
ansible.builtin.package:
2019
name: cron
2120
state: present
2221
when: ansible_facts.distribution == 'Ubuntu'
@@ -25,17 +24,19 @@
2524
# This is to workaround an issue where we set the expiry to 365 days on kayobe
2625
# service accounts in a previous iteration of the CIS benchmark hardening
2726
# defaults. This should restore the defaults and can eventually be removed.
28-
command: chage -m 0 -M 99999 -W 7 -I -1 {{ item }}
27+
ansible.builtin.command: chage -m 0 -M 99999 -W 7 -I -1 {{ item }}
2928
become: true
3029
changed_when: false
3130
with_items:
3231
- "{{ kayobe_ansible_user }}"
3332
- "{{ kolla_ansible_user }}"
3433

35-
- include_role:
34+
- name: Run CIS hardening role (RHEL 9)
35+
ansible.builtin.include_role:
3636
name: ansible-lockdown.rhel9_cis
3737
when: ansible_facts.os_family == 'RedHat' and ansible_facts.distribution_major_version == '9'
3838

39-
- include_role:
39+
- name: Run CIS hardening role (Ubuntu 22)
40+
ansible.builtin.include_role:
4041
name: ansible-lockdown.ubuntu22_cis
4142
when: ansible_facts.distribution == 'Ubuntu' and ansible_facts.distribution_major_version == '22'

0 commit comments

Comments
 (0)