Skip to content

Commit

Permalink
Updated main lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiol committed Aug 29, 2024
1 parent fc6b857 commit a3c4d18
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions roles/builder/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@

- name: Create a blueprint
infra.osbuild.create_blueprint: # noqa only-builtins
dest: "{{ builder_blueprint_src_path }}"
dest: "{{ builder_blueprint_src_path }}" # noqa jinja[spacing]
name: "{{ builder_blueprint_name }}"
distro: "{{ builder_blueprint_distro | default(omit) }}"
packages: "{{ builder_compose_pkgs | default(omit) }}"
Expand All @@ -99,32 +99,39 @@
register: builder_blueprint_output
when: builder_blueprint_import_file is not defined

- block:
- name: Create a blueprint TOML Tasks Block
when: builder_blueprint_import_file is defined
block:
- name: Copy the blueprint file
copy:
ansible.builtin.copy:
src: "{{ builder_blueprint_import_file }}"
dest: "{{ builder_blueprint_src_path }}"
mode: '0644'

## TODO: Check the imported file TOML format
- name: Read the content of the TOML file
slurp:
ansible.builtin.slurp:
src: "{{ builder_blueprint_src_path }}"
register: toml_file_content

- name: Parse TOML content
shell: "echo '{{ toml_file_content.content | b64decode }}' | python -c 'import sys, toml; print(toml.loads(sys.stdin.read())[\"version\"])'"
ansible.builtin.shell: |
set -o pipefail
echo '{{ toml_file_content.content | b64decode }}' | python -c 'import sys, toml; print(toml.loads(sys.stdin.read())[\"version\"])'
register: _imported_blueprint_version
changed_when: _imported_blueprint_version.rc != 0 # <- Uses the return code to define when the task has changed.

- name: Set blueprint name in the imported TOML file
shell: "sed -i '0,/name =/ s/name =.*/name = \"{{ builder_blueprint_name }}\"/' {{ builder_blueprint_src_path }}"
ansible.builtin.shell: "sed -i '0,/name =/ s/name =.*/name = \"{{ builder_blueprint_name }}\"/' {{ builder_blueprint_src_path }}" # noqa command-instead-of-module yaml[line-length]
register: _sed_rc
changed_when: _sed_rc.rc != 0 # <- Uses the return code to define when the task has changed.

- name: Set expected var output with current_version from TOML
set_fact:
ansible.builtin.set_fact:
builder_blueprint_output:
msg: "Blueprint file written to location: {{ builder_blueprint_src_path }}"
changed: true
current_version: "{{ _imported_blueprint_version.stdout }}"
when: builder_blueprint_import_file is defined

- name: Push the blueprint into image builder
infra.osbuild.push_blueprint: # noqa only-builtins
Expand Down Expand Up @@ -248,22 +255,11 @@
- builder_compose_type is defined
- "'installer' in builder_compose_type or 'raw' in builder_compose_type"
block:
- name: Create __edge_insaller_customizations var
ansible.builtin.set_fact:
__edge_insaller_customizations: {}

- name: Set _edge_insaller_customizations value including only fdo and installation_device customizations
ansible.builtin.set_fact:
__edge_insaller_customizations: "{{ __edge_insaller_customizations | combine({item.key: item.value}) }}"
when: "item.key in ['fips']"
with_dict: "{{ builder_compose_customizations }}"

- name: Create blank blueprint
infra.osbuild.create_blueprint: # noqa only-builtins
dest: "{{ builder_blueprint_src_path }}"
name: "{{ builder_blueprint_name }}-empty"
distro: "{{ builder_blueprint_distro | default(omit) }}"
customizations: "{{ __edge_insaller_customizations }}"
register: __builder_blueprint_output # noqa var-naming[no-role-prefix]
when:
- "'simplified' not in builder_compose_type and 'edge' in builder_compose_type or 'iot' in builder_compose_type"
Expand Down

0 comments on commit a3c4d18

Please sign in to comment.