zuul-jobs/roles/packer/tasks/main.yaml
Ian Wienand 6d23d20f2f linters: add names to blocks
This is preparation for a later version of ansbile-lint, which finds
missing names on blocks.  This seems a reasonable rule, and the
Ansible manual says [1]

  Names for blocks have been available since Ansible 2.3. We recommend
  using names in all tasks, within blocks or elsewhere, for better
  visibility into the tasks being executed when you run the playbook.

This simply adds a name tag for blocks that are missing it.  This
should have no operational change, but allows us to update the linter
in a follow-on change.

[1] https://docs.ansible.com/ansible/latest/user_guide/playbooks_blocks.html

Change-Id: I92ed4616775650aced352bc9088a07e919f1a25f
2022-07-27 17:13:39 +10:00

39 lines
1.1 KiB
YAML

- name: Require packer executable
fail:
msg: packer_executable not defined
when: packer_executable is not defined
- name: Create packer variable tempfile
tempfile:
register: packer_variable_tempfile
when: packer_variables is defined
- name: Create packer variables file
copy:
content: |
{{ packer_variables | to_json }}
dest: "{{ packer_variable_tempfile.path }}"
mode: 0600
when: packer_variables is defined
no_log: true # We don't want to log this since credentials could be passed this way
- name: Run packer
block:
- name: Run packer
command: >-
{{ packer_executable }}
{{ packer_command }}
{% if packer_variables is defined %}
-var-file={{ packer_variable_tempfile.path }}
{% endif %}
{{ packer_extra_args }}
{{ packer_template }}
environment: "{{ packer_environment }}"
args:
chdir: "{{ packer_workdir }}"
always:
- name: Delete packer variables file
file:
state: absent
path: "{{ packer_variable_tempfile.path }}"