Skip to content

Commit a906c2e

Browse files
committed
Add ansible-lint CI
1 parent 161fbd7 commit a906c2e

File tree

62 files changed

+514
-458
lines changed

Some content is hidden

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

62 files changed

+514
-458
lines changed

.ansible-lint-ignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This file contains ignores rule violations for ansible-lint
2+
etc/kayobe/ansible/ceph-enter-maintenance.yml syntax-check[specific]
3+
etc/kayobe/ansible/ceph-exit-maintenance.yml syntax-check[specific]
4+
etc/kayobe/ansible/cephadm-commands-post.yml syntax-check[specific]
5+
etc/kayobe/ansible/cephadm-commands-pre.yml syntax-check[specific]
6+
etc/kayobe/ansible/cephadm-crush-rules.yml syntax-check[specific]
7+
etc/kayobe/ansible/cephadm-deploy.yml syntax-check[specific]
8+
etc/kayobe/ansible/cephadm-ec-profiles.yml syntax-check[specific]
9+
etc/kayobe/ansible/cephadm-gather-keys.yml syntax-check[unknown-module]
10+
etc/kayobe/ansible/cephadm-keys.yml syntax-check[specific]
11+
etc/kayobe/ansible/cephadm-pools.yml syntax-check[specific]
12+
etc/kayobe/ansible/cephadm.yml name[play]
13+
etc/kayobe/ansible/configure-vxlan.yml syntax-check[specific]
14+
etc/kayobe/ansible/deploy-github-runner.yml syntax-check[specific]
15+
etc/kayobe/ansible/fix-houston.yml command-instead-of-module
16+
etc/kayobe/ansible/rabbitmq-reset.yml command-instead-of-module
17+
etc/kayobe/ansible/ubuntu-upgrade.yml syntax-check[missing-file]
18+
etc/kayobe/ansible/vault-deploy-barbican.yml syntax-check[unknown-module]
19+
etc/kayobe/ansible/vault-deploy-overcloud.yml syntax-check[specific]
20+
etc/kayobe/ansible/vault-deploy-seed.yml syntax-check[specific]
21+
etc/kayobe/ansible/vault-generate-backend-tls.yml syntax-check[unknown-module]
22+
etc/kayobe/ansible/vault-generate-internal-tls.yml syntax-check[unknown-module]
23+
etc/kayobe/ansible/vault-generate-test-external-tls.yml syntax-check[unknown-module]
24+
etc/kayobe/ansible/vault-unseal-overcloud.yml syntax-check[specific]
25+
etc/kayobe/ansible/vault-unseal-seed.yml syntax-check[specific]
26+
etc/kayobe/ansible/wazuh-agent.yml syntax-check[specific]
27+
etc/kayobe/ansible/wazuh-manager.yml syntax-check[specific]
28+
etc/kayobe/ansible/write-github-workflows.yml syntax-check[specific]

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,9 @@ jobs:
6969
matrix:
7070
include:
7171
# NOTE(upgrade): Keep these in sync with Kayobe's supported Ansible and Python versions (see release notes).
72-
- ansible: "2.12"
73-
# ansible-lint 6+ is not supported on Python 3.8.
74-
ansible-lint: "5"
75-
python: "3.8"
76-
- ansible: "2.13"
77-
ansible-lint: "6"
72+
- ansible: "2.16"
73+
python: "3.12"
74+
- ansible: "2.15"
7875
python: "3.10"
7976
name: Ansible ${{ matrix.ansible }} lint with Python ${{ matrix.python }}
8077
if: github.repository == 'stackhpc/stackhpc-kayobe-config'
@@ -90,7 +87,7 @@ jobs:
9087
- name: Install dependencies 📦
9188
run: |
9289
python -m pip install --upgrade pip
93-
pip install ansible-core==${{ matrix.ansible }}.* ansible-lint==${{ matrix.ansible-lint }}.* -r requirements.txt
90+
pip install ansible-core==${{ matrix.ansible }}.* ansible-lint -r requirements.txt
9491
9592
- name: Install Ansible Galaxy collections and roles
9693
run: |
@@ -99,7 +96,7 @@ jobs:
9996
10097
- name: Linting code 🧪
10198
run: |
102-
ansible-lint -v --force-color etc/kayobe/ansible/
99+
ansible-lint -v --force-color -x no-changed-when,risky-file-permissions,unknown-module,run-once,name[template],package-latest etc/kayobe/ansible/.
103100
104101
# A skipped job is treated as success when used as a required status check.
105102
# The registered required status checks refer to the name of the job in the

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: 7 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,8 @@
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_\
46+
{{ stackhpc_pulp_doca_ofed_version }}_rhel9{{ stackhpc_pulp_repo_rocky_9_minor_version }}.x86_64.rpm"
4647
disable_gpg_check: true
4748

4849
- name: Install DOCA extra packages
@@ -53,13 +54,13 @@
5354
ansible.builtin.file:
5455
path: /home/cloud-user/ofed
5556
state: directory
56-
mode: 0777
57+
mode: "0777"
5758

5859
- name: Set build directory
5960
ansible.builtin.replace:
6061
path: /opt/mellanox/doca/tools/doca-kernel-support
61-
regexp: 'TMP_DIR=\$1'
62-
replace: 'TMP_DIR=/home/cloud-user/ofed'
62+
regexp: TMP_DIR=\$1
63+
replace: TMP_DIR=/home/cloud-user/ofed
6364

6465
- name: Build OFED kernel modules
6566
ansible.builtin.shell:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
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+
command: cephadm shell -- ceph config generate-minimal-conf
3636
become: true
3737
register: cephadm_ceph_conf
3838
changed_when: false

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'
Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
---
2-
32
- name: Ensure dependencies are installed
43
hosts: controllers[0]
54
gather_facts: true
65
vars:
7-
venv: '{{ virtualenv_path }}/openstack'
6+
venv: "{{ virtualenv_path }}/openstack"
87
tasks:
98
- name: Install python build dependencies
10-
package:
9+
ansible.builtin.package:
1110
name: "{{ packages | select | list }}"
1211
cache_valid_time: "{{ apt_cache_valid_time if ansible_facts.os_family == 'Debian' else omit }}"
1312
update_cache: "{{ True if ansible_facts.os_family == 'Debian' else omit }}"
@@ -16,56 +15,53 @@
1615
vars:
1716
packages:
1817
- "{% if ansible_facts.os_family == 'RedHat' %}gcc{% else %}build-essential{% endif %}"
19-
- "python3-dev{% if ansible_facts.os_family == 'RedHat' %}el{% endif %}"
18+
- python3-dev{% if ansible_facts.os_family == 'RedHat' %}el{% endif %}
2019
- "{% if ansible_facts.os_family == 'Debian' %}python3-venv{% endif %}"
2120

2221
- name: Ensure latest version of pip is installed
23-
pip:
22+
ansible.builtin.pip:
2423
name: pip
2524
state: latest
26-
virtualenv: '{{ venv }}'
27-
virtualenv_command: "/usr/bin/python3 -m venv"
25+
virtualenv: "{{ venv }}"
26+
virtualenv_command: /usr/bin/python3 -m venv
2827

2928
- name: Ensure python openstack client is installed
30-
pip:
29+
ansible.builtin.pip:
3130
name: python-openstackclient
32-
virtualenv: '{{ venv }}'
31+
virtualenv: "{{ venv }}"
3332
extra_args: -c "{{ pip_upper_constraints_file }}"
3433

3534
- name: Include kolla secrets
36-
include_vars:
37-
dir: '{{ kayobe_env_config_path }}/kolla/'
35+
ansible.builtin.include_vars:
36+
dir: "{{ kayobe_env_config_path }}/kolla/"
3837
files_matching: passwords.yml
3938
name: kolla_passwords
4039

4140
- name: Add an IP to connect to the instances
4241
# FIXME: host configure will have bounced the bridge
4342
# and removed the IP
44-
command: ip a add 10.0.2.1/24 dev breth1
43+
ansible.builtin.command: ip a add 10.0.2.1/24 dev breth1
4544
register: result
46-
failed_when: 'result.rc !=0 and "RTNETLINK answers: File exists" not in
47-
result.stderr'
45+
failed_when: 'result.rc != 0 and "RTNETLINK answers: File exists" not in result.stderr'
4846
changed_when: result.rc == 0
4947
become: true
5048

5149
- name: Run init-run-once
52-
script:
50+
ansible.builtin.script:
5351
cmd: scripts/aio-init.sh
5452
creates: /tmp/.init-runonce
5553
environment:
56-
KOLLA_OPENSTACK_COMMAND: '{{ venv }}/bin/openstack'
54+
KOLLA_OPENSTACK_COMMAND: "{{ venv }}/bin/openstack"
5755
OS_PROJECT_DOMAIN_NAME: Default
5856
OS_USER_DOMAIN_NAME: Default
5957
OS_PROJECT_NAME: admin
6058
OS_TENANT_NAME: admin
6159
OS_USERNAME: admin
62-
OS_PASSWORD: "{{ kolla_passwords.keystone_admin_password | mandatory('Could\
63-
\ not find keystone_admin_password in passwords.yml') }}"
60+
OS_PASSWORD: "{{ kolla_passwords.keystone_admin_password | mandatory('Could not find keystone_admin_password in passwords.yml') }}"
6461
# Use kolla_external_fqdn in wallaby
65-
OS_AUTH_URL: http://{{ kolla_external_fqdn | default(public_net_name
66-
| net_fqdn) | default(public_net_name | net_vip_address, true) }}:5000
62+
OS_AUTH_URL: http://{{ kolla_external_fqdn | default(public_net_name | net_fqdn) | default(public_net_name | net_vip_address, true) }}:5000
6763
OS_INTERFACE: public
6864
OS_ENDPOINT_TYPE: publicURL
69-
OS_IDENTITY_API_VERSION: 3
65+
OS_IDENTITY_API_VERSION: "3"
7066
OS_REGION_NAME: RegionOne
7167
OS_AUTH_PLUGIN: password

etc/kayobe/ansible/configure-vxlan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
# python interpreter.
99
ansible_python_interpreter: /usr/bin/python3
1010
# Work around no known_hosts entry on first boot.
11-
ansible_ssh_common_args: "-o StrictHostKeyChecking=no"
11+
ansible_ssh_common_args: -o StrictHostKeyChecking=no
1212
roles:
1313
- role: stackhpc.vxlan

etc/kayobe/ansible/deploy-github-runner.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
- name: Deploy GitHub Runner
33
hosts: github-runners
4-
become: yes
4+
become: true
55
roles:
66
- role: geerlingguy.pip
77
- role: geerlingguy.docker
@@ -14,8 +14,7 @@
1414
runner_dir: "{{ base_runner_dir }}/{{ runner.key }}"
1515
runner_labels: "{{ runner.value.labels | default(default_runner_labels) }}"
1616
runner_state: "{{ runner.value.state | default('started') }}"
17-
with_dict:
18-
"{{ github_runners }}"
17+
with_dict: "{{ github_runners }}"
1918
loop_control:
2019
loop_var: runner
2120

@@ -28,7 +27,6 @@
2827
enabled: true
2928
become: true
3029
when: runner_state | default('started') == 'started'
31-
with_dict:
32-
"{{ github_runners }}"
30+
with_dict: "{{ github_runners }}"
3331
loop_control:
3432
loop_var: runner

0 commit comments

Comments
 (0)