Skip to content

Commit 48423b9

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "CI: Use ansible-lint for CI roles and playbooks"
2 parents 498b793 + af632db commit 48423b9

File tree

15 files changed

+94
-67
lines changed

15 files changed

+94
-67
lines changed

.ansible-lint

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
exclude_paths:
3+
- .cache/ # implicit unless exclude_paths is defined in config
4+
- .zuul.d/
5+
offline: true
6+
parseable: true
7+
profile: basic
8+
skip_list:
9+
- package-latest
10+
- role-name
11+
strict: true
12+
use_default_rules: true

.yamllint

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
collections:
3+
- ansible.posix
4+
- community.general

roles/configure-ephemeral/tasks/main.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@
33
# unallocated ephemeral device attached at /dev/xvde
44
- name: Set ephemeral device if /dev/xvde exists
55
when: ansible_devices["xvde"] is defined
6-
set_fact:
6+
ansible.builtin.set_fact:
77
ephemeral_device: "/dev/xvde"
88

99
# On other providers, we have a device called "ephemeral0".
1010
- name: Set ephemeral device by label
1111
when: ephemeral_device is undefined
1212
block:
1313
- name: Get ephemeral0 device node
14-
command: /sbin/blkid -L ephemeral0
14+
ansible.builtin.command: /sbin/blkid -L ephemeral0
1515
register: ephemeral0
1616
# rc !=0 is expected
17-
failed_when: False
18-
changed_when: False
17+
failed_when: false
18+
changed_when: false
1919

2020
- name: Set ephemeral device if LABEL exists
2121
when: "ephemeral0.rc == 0"
22-
set_fact:
22+
ansible.builtin.set_fact:
2323
ephemeral_device: "{{ ephemeral0.stdout }}"
2424

2525
- name: Configure additional disk (if available)
@@ -53,13 +53,13 @@
5353
fstype: ext4
5454
dev: "{{ ephemeral_device }}"
5555

56-
- name: "Ensure {{ configure_ephemeral_mountpoint }} mountpoint is created"
56+
- name: "Ensure mountpoint {{ configure_ephemeral_mountpoint }}"
5757
ansible.builtin.file:
5858
path: "{{ configure_ephemeral_mountpoint }}"
5959
owner: root
6060
group: root
6161
state: directory
62-
mode: 0755
62+
mode: "0755"
6363

6464
- name: Mount additional filesystem
6565
ansible.posix.mount:
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
---
22
- name: Ensure kolla-build.conf exists
3-
template:
3+
ansible.builtin.template:
44
src: kolla-build.conf.j2
55
dest: "{{ kolla_build_config_path }}"
6+
mode: "0660"
7+
owner: zuul
8+
group: zuul

roles/kolla-build-deps/tasks/main.yml

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,23 @@
33
ansible.builtin.file:
44
path: "{{ kolla_logs_dir }}"
55
state: directory
6+
mode: "0755"
7+
owner: zuul
8+
group: zuul
69

710
- name: Dump host info to logs
811
ansible.builtin.command: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tools/dump_info.sh"
912
args:
1013
chdir: "{{ kolla_logs_dir }}"
14+
changed_when: true
1115

1216
- name: Create dir for kolla build logs
1317
ansible.builtin.file:
1418
path: "{{ kolla_build_logs_dir }}"
1519
state: directory
20+
mode: "0755"
21+
owner: zuul
22+
group: zuul
1623

1724
- name: Install Python3 pip and setuptools
1825
ansible.builtin.package:
@@ -29,23 +36,6 @@
2936
become: true
3037
when: ansible_facts.os_family == "Debian"
3138

32-
- name: Install dbus-python dependencies on Debian systems
33-
ansible.builtin.package:
34-
name:
35-
- python3-dev
36-
- libdbus-glib-1-dev
37-
become: true
38-
when: ansible_facts.os_family == "Debian"
39-
40-
- name: Install dbus-python dependencies on EL systems
41-
ansible.builtin.package:
42-
name:
43-
- python3-devel
44-
- dbus-glib-devel
45-
- dbus-daemon
46-
become: true
47-
when: ansible_facts.os_family == "RedHat"
48-
4939
- name: Install kolla in a venv
5040
ansible.builtin.pip:
5141
name:
@@ -70,5 +60,5 @@
7060
- name: Ensure container engine socket is world-writable
7161
ansible.builtin.file:
7262
path: "{{ '/run/docker.sock' if container_engine == 'docker' else '/run/podman/podman.sock' }}"
73-
mode: 0666
63+
mode: "0666"
7464
become: true

roles/kolla-build/tasks/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,21 @@
33
ansible.builtin.template:
44
src: "{{ kolla_build_template_overrides_path }}"
55
dest: /etc/kolla/template_overrides.j2
6+
mode: "0660"
7+
owner: zuul
8+
group: zuul
69
when: kolla_build_template_overrides_path | length > 0
710

811
- name: Run kolla-build to template out dockerfiles
912
ansible.builtin.command:
1013
cmd: >-
1114
{{ kolla_build_venv_path }}/bin/kolla-build --template-only
1215
--work-dir {{ kolla_build_logs_dir }}/work_dir
16+
changed_when: true
1317

1418
- name: Run kolla-build
1519
vars:
1620
platform: "{{ '--platform linux/arm64' if base_arch == 'aarch64' and base_arch != ansible_facts.architecture }}"
1721
ansible.builtin.command:
1822
cmd: "{{ kolla_build_venv_path }}/bin/kolla-build {{ platform }}"
23+
changed_when: true

test-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
ansible-lint<25 # MIT
12
bandit!=1.6.0,>=1.1.0 # Apache-2.0
23
bashate>=0.5.1 # Apache-2.0
34
coverage!=4.4,>=4.0 # Apache-2.0

test-requirements.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
collections:
3+
- ansible.posix
4+
- community.docker
5+
- community.general

tests/playbooks/post.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
---
2-
- hosts: all
2+
- name: Zuul post
3+
hosts: all
34
tasks:
45
- name: Dump host info to logs
5-
command: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tools/dump_info.sh"
6+
ansible.builtin.command: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tools/dump_info.sh"
67
args:
78
chdir: "{{ kolla_logs_dir }}"
9+
changed_when: true
810

911
- name: Collect various info to logs
10-
shell:
12+
changed_when: true
13+
ansible.builtin.shell:
1114
cmd: |
1215
set +o errexit
1316
set -o xtrace
@@ -63,14 +66,17 @@
6366
ps -eo user,pid,ppid,lwp,%cpu,%mem,size,rss,cmd > ps.txt
6467
6568
# docker related information
66-
(sudo {{ container_engine }} info && sudo {{ container_engine }} system df && sudo {{ container_engine }} system df -v) > {{ container_engine }}-info.txt
69+
(sudo {{ container_engine }} info && \
70+
sudo {{ container_engine }} system df && \
71+
sudo {{ container_engine }} system df -v) > {{ container_engine }}-info.txt
6772
6873
sudo cp -r /etc/kolla kolla_configs
6974
7075
# last sudo to own all files
7176
sudo chown -R {{ ansible_user_id }}: .
7277
7378
# Parse build logs and extract pkg install info
74-
{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tests/files/process_build_logs.py -l build -b {{ base_distro }} > packages-info.txt
79+
{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tests/files/process_build_logs.py \
80+
-l build -b {{ base_distro }} > packages-info.txt
7581
executable: /bin/bash
7682
chdir: "{{ kolla_logs_dir }}"

0 commit comments

Comments
 (0)