zuul-jobs/roles/packer/tasks/main.yaml
Sorin Sbarnea 33461bbecc Enable yamllint
Adds yamllint to the linters with a minimal configuration, some
rules are disabled to allow us to fix them in follow-ups, if
we agree on them.

Fixes invalid YAML file containing characters inside block.

Fixes few minor linting issues.

Change-Id: I936fe2c997597972d884c5fc62655d28e8aaf8c5
2020-05-04 17:47:11 +01:00

37 lines
1.0 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 }}"
when: packer_variables is defined
no_log: true # We don't want to log this since credentials could be passed this way
- 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 }}"