Skip to content

Commit 4caa813

Browse files
author
scrungus
committed
more linting errors
1 parent 95d0079 commit 4caa813

File tree

4 files changed

+43
-48
lines changed

4 files changed

+43
-48
lines changed

roles/os_images/tasks/images.yml

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
---
22
- name: Include OS family-specific variables
3-
include_vars: "{{ ansible_facts.os_family }}.yml"
4-
3+
ansible.builtin.include_vars: "{{ ansible_facts.os_family }}.yml"
54
- name: Ensure required packages are installed
6-
package:
5+
ansible.builtin.package:
76
name: "{{ (os_images_package_dependencies + os_images_package_dependencies_extra) | select | list }}"
87
state: present
98
become: true
@@ -12,7 +11,7 @@
1211
- name: Ensure diskimage-builder SELinux dependencies are installed
1312
vars:
1413
package_name: "{{ 'policycoreutils-python' if ansible_facts.distribution_major_version | int == 7 else 'python3-policycoreutils' }}"
15-
package:
14+
ansible.builtin.package:
1615
name: "{{ package_name }}"
1716
state: present
1817
when:
@@ -22,15 +21,15 @@
2221
become: true
2322

2423
- name: Ensure download cache dir exists
25-
file:
24+
ansible.builtin.file:
2625
path: "{{ os_images_cache }}"
2726
owner: "{{ ansible_facts.user_uid }}"
2827
group: "{{ ansible_facts.user_gid }}"
2928
state: directory
3029
become: true
3130

3231
- name: Remove old images for force rebuild
33-
file:
32+
ansible.builtin.file:
3433
path: "{{ os_images_cache }}/{{ item.name }}"
3534
state: absent
3635
when: item.force_rebuild | default(os_images_force_rebuild) | bool
@@ -40,7 +39,7 @@
4039
tags: clean
4140

4241
- name: Generate per-image cache directories
43-
file:
42+
ansible.builtin.file:
4443
path: "{{ os_images_cache }}/{{ item.name }}"
4544
owner: "{{ ansible_facts.user_uid }}"
4645
group: "{{ ansible_facts.user_gid }}"
@@ -50,28 +49,28 @@
5049
label: "{{ item.name }}"
5150
become: true
5251

53-
- block:
52+
- vars:
53+
image_dest: "{{ os_images_cache }}/{{ item.name }}/{{ item.name }}.{{ item.type | default('qcow2') }}{{ '.xz' if image_is_xz else '' }}"
54+
image_is_xz: "{{ item.image_url.endswith('.xz') }}"
55+
when: item.image_url is defined
56+
57+
block:
5458
- name: Download the image to the directory when an image_url is defined
55-
get_url:
59+
ansible.builtin.get_url:
5660
url: "{{ item.image_url }}"
5761
dest: "{{ image_dest }}"
5862
checksum: "{{ item.checksum | default(omit) }}"
5963
with_items: "{{ os_images_list | list }}"
6064
loop_control:
6165
label: "{{ item.name }}"
6266
- name: Unpack the image if .xz format
63-
command: unxz --keep --force {{ image_dest }}
67+
ansible.builtin.command: unxz --keep --force {{ image_dest }}
6468
when: image_is_xz
6569
with_items: "{{ os_images_list | list }}"
6670
loop_control:
6771
label: "{{ item.name }}"
68-
vars:
69-
image_dest: "{{ os_images_cache }}/{{ item.name }}/{{ item.name }}.{{ item.type | default('qcow2') }}{{ '.xz' if image_is_xz else '' }}"
70-
image_is_xz: "{{ item.image_url.endswith('.xz') }}"
71-
when: item.image_url is defined
72-
7372
- name: Install a suitable version of diskimage-builder
74-
pip:
73+
ansible.builtin.pip:
7574
name: "{{ item.name }}"
7675
version: "{{ item.version or omit }}"
7776
state: "{{ os_images_package_state }}"
@@ -82,39 +81,35 @@
8281
version: "{{ os_images_dib_version }}"
8382

8483
- name: Git clone any additional image element repos
85-
git:
84+
ansible.builtin.git:
8685
repo: "{{ item.repo }}"
8786
dest: "{{ item.local }}"
8887
version: "{{ item.version | default('HEAD') }}"
8988
with_items: "{{ os_images_git_elements }}"
9089

9190
- name: Set a fact containing paths to DIB elements
92-
set_fact:
91+
ansible.builtin.set_fact:
9392
os_images_elements_path: "{{ os_images_elements }}"
9493

9594
- name: Incorporate git-sourced DIB elements
96-
set_fact:
95+
ansible.builtin.set_fact:
9796
os_images_elements_path: >
9897
{{ os_images_elements_path +
9998
[item.local ~ '/' ~ item.elements_path] }}
10099
with_items: "{{ os_images_git_elements }}"
101100
when: item.elements_path is defined
102101

103102
- name: Set a fact containing the default DIB environment
104-
set_fact:
103+
ansible.builtin.set_fact:
105104
os_image_dib_env_default:
106105
ELEMENTS_PATH: "{{ os_images_elements_path | join(':') }}"
107106

108107
- name: Generate diskimage-builder images
109108
vars:
110109
dib_args: >-
111-
{% if item.size is defined %}--image-size {{ item.size }}{% endif %}
112-
{% if item.type is defined %}-t {{ item.type }}{% endif %}
113-
{% if item.packages | default %}-p {{ item.packages | join(',') }}{% endif %}
114-
{{ os_images_common }}
115-
{{ item.elements | join( ' ' ) }}
116-
-o {{ item.name }}
117-
shell: . {{ os_images_dib_venv }}/bin/activate && disk-image-create {{ dib_args }} > {{ item.name }}.stdout 2> {{ item.name }}.stderr
110+
{% if item.size is defined %}--image-size {{ item.size }}{% endif %} {% if item.type is defined %}-t {{ item.type }}{% endif %} {% if item.packages | default
111+
%}-p {{ item.packages | join(',') }}{% endif %} {{ os_images_common }} {{ item.elements | join(' ') }} -o {{ item.name }}
112+
ansible.builtin.shell: . {{ os_images_dib_venv }}/bin/activate && disk-image-create {{ dib_args }} > {{ item.name }}.stdout 2> {{ item.name }}.stderr
118113
args:
119114
chdir: "{{ os_images_cache }}/{{ item.name }}"
120115
creates: "{{ os_images_cache }}/{{ item.name }}/{{ item.name }}.d/dib-manifests"
@@ -129,7 +124,7 @@
129124
when: item.elements is defined
130125

131126
- name: Fail if any images failed to build
132-
fail:
127+
ansible.builtin.fail:
133128
msg: >
134129
Image {{ item.0.name }} failed to build. See
135130
{{ item.0.name }}.stdout and {{ item.0.name }}.stderr in

roles/os_images/tasks/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
---
22
- name: Set a fact about the Ansible python interpreter
3-
set_fact:
3+
ansible.builtin.set_fact:
44
old_ansible_python_interpreter: "{{ ansible_python_interpreter | default('/usr/bin/python' + ansible_facts.python.version.major | string) }}"
55

6-
- import_tasks: images.yml
6+
- ansible.builtin.import_tasks: images.yml
77
when: os_images_build | bool
88

9-
- import_tasks: upload.yml
9+
- ansible.builtin.import_tasks: upload.yml
1010
vars:
1111
ansible_python_interpreter: "{{ os_images_venv ~ '/bin/python' if os_images_venv != None else old_ansible_python_interpreter }}"
1212
when: os_images_upload | bool
1313

14-
- import_tasks: promote.yml
14+
- ansible.builtin.import_tasks: promote.yml
1515
vars:
1616
ansible_python_interpreter: "{{ os_images_venv ~ '/bin/python' if os_images_venv != None else old_ansible_python_interpreter }}"
1717
when: os_images_promote | bool

roles/os_images/tasks/promote.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
- name: Check if image suffix is provided
3-
fail:
3+
ansible.builtin.fail:
44
msg: os_images_name_suffix is empty please provide it.
55
when: os_images_name_suffix is defined and os_images_name_suffix | length == 0
66

@@ -15,10 +15,10 @@
1515
when: item.rename_image | default(os_images_promote) | bool
1616

1717
- name: Ensure images for retirement exist
18-
assert:
18+
ansible.builtin.assert:
1919
that:
2020
- item.name in retire_list.openstack_images | map(attribute='name') | list
21-
fail_msg: The image {{ item.name[:-(os_images_name_suffix | length | int)] }} does not exist.
21+
fail_msg: "The image {{ item.name[: -(os_images_name_suffix | length | int)] }} does not exist."
2222
loop: "{{ os_images_list | list }}"
2323
when: item.rename_image | default(os_images_promote) | bool
2424

@@ -33,33 +33,33 @@
3333
when: item.rename_image | default(os_images_promote) | bool
3434

3535
- name: Ensure images for promotion exist
36-
assert:
36+
ansible.builtin.assert:
3737
that:
3838
- item.name in promote_list.openstack_images | map(attribute='name') | list
3939
fail_msg: The image {{ item.name }} does not exist.
4040
loop: "{{ os_images_list | list }}"
4141
when: item.rename_image | default(os_images_promote) | bool
4242

4343
- name: Hide retire candidate images
44-
command: "{{ os_images_venv }}/bin/openstack image set --hidden {{ promotion_name }}"
44+
ansible.builtin.command: "{{ os_images_venv }}/bin/openstack image set --hidden {{ promotion_name }}"
4545
vars:
46-
promotion_name: "{{ item.name[:-(os_images_name_suffix | length | int)] }}"
46+
promotion_name: "{{ item.name[: -(os_images_name_suffix | length | int)] }}"
4747
with_items: "{{ os_images_list | list }}"
4848
when: (item.rename_image | default(os_images_promote) | bool) and (item.hide_image | default(os_images_hide) | bool)
4949

5050
- name: Ensure old images are retired
51-
command: "{{ os_images_venv }}/bin/openstack image set {{ promotion_name }} --name {{ promotion_name }}.{{ date_suffix }}"
51+
ansible.builtin.command: "{{ os_images_venv }}/bin/openstack image set {{ promotion_name }} --name {{ promotion_name }}.{{ date_suffix }}"
5252
vars:
5353
date_suffix: "{{ ansible_date_time.date }}"
54-
promotion_name: "{{ item.name[:-(os_images_name_suffix | length | int)] }}"
54+
promotion_name: "{{ item.name[: -(os_images_name_suffix | length | int)] }}"
5555
loop: "{{ os_images_list | list }}"
5656
when: item.rename_image | default(os_images_promote) | bool
5757
environment: "{{ os_images_venv }}"
5858

5959
- name: Ensure new images are promoted
60-
command: "{{ os_images_venv }}/bin/openstack image set {{ item.name }} --name {{ promotion_name }}"
60+
ansible.builtin.command: "{{ os_images_venv }}/bin/openstack image set {{ item.name }} --name {{ promotion_name }}"
6161
vars:
62-
promotion_name: "{{ item.name[:-(os_images_name_suffix | length | int)] }}"
62+
promotion_name: "{{ item.name[: -(os_images_name_suffix | length | int)] }}"
6363
loop: "{{ os_images_list | list }}"
6464
when: item.rename_image | default(os_images_promote) | bool
6565
environment: "{{ os_images_venv }}"

roles/os_images/tasks/upload.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
- name: Ensure existing cloud tenant kernel does not exist
3-
os_image:
3+
openstack.cloud.image:
44
auth_type: "{{ os_images_auth_type }}"
55
auth: "{{ os_images_auth }}"
66
cacert: "{{ os_images_cacert | default(omit) }}"
@@ -18,7 +18,7 @@
1818
tags: clean
1919

2020
- name: Upload cloud tenant kernel for baremetal images
21-
os_image:
21+
openstack.cloud.image:
2222
auth_type: "{{ os_images_auth_type }}"
2323
auth: "{{ os_images_auth }}"
2424
cacert: "{{ os_images_cacert | default(omit) }}"
@@ -39,7 +39,7 @@
3939
register: kernel_result
4040

4141
- name: Ensure existing cloud tenant ramdisk does not exist
42-
os_image:
42+
openstack.cloud.image:
4343
auth_type: "{{ os_images_auth_type }}"
4444
auth: "{{ os_images_auth }}"
4545
cacert: "{{ os_images_cacert | default(omit) }}"
@@ -57,7 +57,7 @@
5757
tags: clean
5858

5959
- name: Upload cloud tenant ramdisk for baremetal images
60-
os_image:
60+
openstack.cloud.image:
6161
auth_type: "{{ os_images_auth_type }}"
6262
auth: "{{ os_images_auth }}"
6363
cacert: "{{ os_images_cacert | default(omit) }}"
@@ -78,7 +78,7 @@
7878
register: ramdisk_result
7979

8080
- name: Ensure existing cloud tenant image does not exist
81-
os_image:
81+
openstack.cloud.image:
8282
auth_type: "{{ os_images_auth_type }}"
8383
auth: "{{ os_images_auth }}"
8484
cacert: "{{ os_images_cacert | default(omit) }}"
@@ -93,7 +93,7 @@
9393
tags: clean
9494

9595
- name: Upload cloud tenant images
96-
os_image:
96+
openstack.cloud.image:
9797
auth_type: "{{ os_images_auth_type }}"
9898
auth: "{{ os_images_auth }}"
9999
cacert: "{{ os_images_cacert | default(omit) }}"

0 commit comments

Comments
 (0)