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 <mark@stackhpc.com> Co-authored-by: Matt Crees <mattc@stackhpc.com> Co-authored-by: Pierre Riteau <pierre@stackhpc.com>
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

0 commit comments

Comments
 (0)