Skip to content

Commit f365a5b

Browse files
author
scrungus
committed
more linting
1 parent 4caa813 commit f365a5b

File tree

6 files changed

+26
-14
lines changed

6 files changed

+26
-14
lines changed

roles/os_images/defaults/main.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ os_images_upper_constraints_file: https://releases.openstack.org/constraints/upp
2121
os_images_dib_upper_constraints_file: ""
2222

2323
# Path to a directory in which to cache build artefacts.
24-
os_images_cache: "{{ lookup('env','HOME') }}/disk_images"
24+
os_images_cache: "{{ lookup('env', 'HOME') }}/disk_images"
2525

2626
# List of paths of site-specific diskimage-builder elements
2727
# os_images_elements: [ "{{ playbook_dir }}/stackhpc-image-elements" ]
@@ -58,11 +58,11 @@ os_images_auth_type: password
5858

5959
# OpenStack authentication credentials:
6060
# For example, take OpenStack authentication credentials from the environment
61-
#os_images_auth:
62-
# auth_url: "{{ lookup('env','OS_AUTH_URL') }}"
63-
# username: "{{ lookup('env','OS_USERNAME') }}"
64-
# password: "{{ lookup('env','OS_PASSWORD') }}"
65-
# project_name: "{{ lookup('env','OS_TENANT_NAME') }}"
61+
# os_images_auth:
62+
# auth_url: "{{ lookup('env','OS_AUTH_URL') }}"
63+
# username: "{{ lookup('env','OS_USERNAME') }}"
64+
# password: "{{ lookup('env','OS_PASSWORD') }}"
65+
# project_name: "{{ lookup('env','OS_TENANT_NAME') }}"
6666
os_images_auth:
6767
# Endpoint URL type to fetch from the service catalog. Maybe be one of:
6868
# public, admin, or internal.

roles/os_images/meta/main.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
---
22
galaxy_info:
3-
#role_name: os_images
43
author: Stig Telfer
54
description: >
65
Role to generate guest instance images and upload to OpenStack
76
company: StackHPC Ltd
87
license: Apache2
9-
min_ansible_version: 2.0
8+
min_ansible_version: "2.0"
109
platforms:
1110
- name: EL
1211
versions:
13-
- 7
12+
- "7"
1413
- name: Ubuntu
1514
versions:
1615
- all

roles/os_images/tasks/images.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
owner: "{{ ansible_facts.user_uid }}"
2727
group: "{{ ansible_facts.user_gid }}"
2828
state: directory
29+
mode: "0644"
2930
become: true
3031

3132
- name: Remove old images for force rebuild
@@ -44,12 +45,14 @@
4445
owner: "{{ ansible_facts.user_uid }}"
4546
group: "{{ ansible_facts.user_gid }}"
4647
state: directory
48+
mode: "0644"
4749
with_items: "{{ os_images_list | list }}"
4850
loop_control:
4951
label: "{{ item.name }}"
5052
become: true
5153

52-
- vars:
54+
- name: Download and unpack
55+
vars:
5356
image_dest: "{{ os_images_cache }}/{{ item.name }}/{{ item.name }}.{{ item.type | default('qcow2') }}{{ '.xz' if image_is_xz else '' }}"
5457
image_is_xz: "{{ item.image_url.endswith('.xz') }}"
5558
when: item.image_url is defined
@@ -60,15 +63,18 @@
6063
url: "{{ item.image_url }}"
6164
dest: "{{ image_dest }}"
6265
checksum: "{{ item.checksum | default(omit) }}"
66+
mode: "0644"
6367
with_items: "{{ os_images_list | list }}"
6468
loop_control:
6569
label: "{{ item.name }}"
6670
- name: Unpack the image if .xz format
6771
ansible.builtin.command: unxz --keep --force {{ image_dest }}
72+
changed_when: true
6873
when: image_is_xz
6974
with_items: "{{ os_images_list | list }}"
7075
loop_control:
7176
label: "{{ item.name }}"
77+
7278
- name: Install a suitable version of diskimage-builder
7379
ansible.builtin.pip:
7480
name: "{{ item.name }}"

roles/os_images/tasks/main.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
ansible.builtin.set_fact:
44
old_ansible_python_interpreter: "{{ ansible_python_interpreter | default('/usr/bin/python' + ansible_facts.python.version.major | string) }}"
55

6-
- ansible.builtin.import_tasks: images.yml
6+
- name: Build or download images
7+
ansible.builtin.import_tasks: images.yml
78
when: os_images_build | bool
89

9-
- ansible.builtin.import_tasks: upload.yml
10+
- name: Upload images
11+
ansible.builtin.import_tasks: upload.yml
1012
vars:
1113
ansible_python_interpreter: "{{ os_images_venv ~ '/bin/python' if os_images_venv != None else old_ansible_python_interpreter }}"
1214
when: os_images_upload | bool
1315

14-
- ansible.builtin.import_tasks: promote.yml
16+
- name: Promote or hide/retire images
17+
ansible.builtin.import_tasks: promote.yml
1518
vars:
1619
ansible_python_interpreter: "{{ os_images_venv ~ '/bin/python' if os_images_venv != None else old_ansible_python_interpreter }}"
1720
when: os_images_promote | bool

roles/os_images/tasks/promote.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
vars:
4646
promotion_name: "{{ item.name[: -(os_images_name_suffix | length | int)] }}"
4747
with_items: "{{ os_images_list | list }}"
48+
changed_when: true
4849
when: (item.rename_image | default(os_images_promote) | bool) and (item.hide_image | default(os_images_hide) | bool)
4950

5051
- name: Ensure old images are retired
@@ -54,12 +55,14 @@
5455
promotion_name: "{{ item.name[: -(os_images_name_suffix | length | int)] }}"
5556
loop: "{{ os_images_list | list }}"
5657
when: item.rename_image | default(os_images_promote) | bool
58+
changed_when: true
5759
environment: "{{ os_images_venv }}"
5860

5961
- name: Ensure new images are promoted
6062
ansible.builtin.command: "{{ os_images_venv }}/bin/openstack image set {{ item.name }} --name {{ promotion_name }}"
6163
vars:
6264
promotion_name: "{{ item.name[: -(os_images_name_suffix | length | int)] }}"
6365
loop: "{{ os_images_list | list }}"
66+
changed_when: true
6467
when: item.rename_image | default(os_images_promote) | bool
6568
environment: "{{ os_images_venv }}"

roles/os_images/tests/test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
- hosts: all
2+
- name: Os_images
3+
hosts: all
34
connection: local
45
roles:
56
- stackhpc.openstack.os_images

0 commit comments

Comments
 (0)