Skip to content

Commit

Permalink
fix: Allow numbers in ostemplate storage
Browse files Browse the repository at this point in the history
Also rename the internal variables to use two underscores instead of
one, as per Ansible good practice.
  • Loading branch information
btravouillon committed Oct 13, 2024
1 parent 364dc34 commit 67ff180
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions roles/container/tasks/install_templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
headers:
Authorization: "PVEAPIToken={{ proxmox_api_user }}!{{ proxmox_api_token_id }}={{ proxmox_api_token_secret }}"
Content-Type: application/json
register: _nodes_results
register: __nodes_results

- name: Set facts to install OS templates
ansible.builtin.set_fact:
_list_of_templates: "{{ proxmox_container | community.general.json_query('[*].ostemplate') | unique }}"
_nodes: "{{_nodes_results | community.general.json_query('json.data[*].node') }}"
_ostemplate_regex: '^([-a-z]+):([a-z]+)/(.*)'
__list_of_templates: "{{ proxmox_container | community.general.json_query('[*].ostemplate') | unique }}"
__nodes: "{{ __nodes_results | community.general.json_query('json.data[*].node') }}"
__ostemplate_regex: '^([-a-z0-9]+):([a-z]+)/(.*)'

- name: Download proxmox appliance container templates
community.general.proxmox_template:
Expand All @@ -23,9 +23,9 @@
api_token_id: "{{ proxmox_api_token_id }}"
api_token_secret: "{{ proxmox_api_token_secret }}"
node: "{{ item.0 }}"
storage: "{{ item.1 | regex_search(_ostemplate_regex, '\\1') | first }}"
content_type: "{{ item.1 | regex_search(_ostemplate_regex, '\\2') | first }}"
template: "{{ item.1 | regex_search(_ostemplate_regex, '\\3') | first }}"
storage: "{{ item.1 | regex_search(__ostemplate_regex, '\\1') | first }}"
content_type: "{{ item.1 | regex_search(__ostemplate_regex, '\\2') | first }}"
template: "{{ item.1 | regex_search(__ostemplate_regex, '\\3') | first }}"
timeout: 300
validate_certs: "{{ proxmox_api_validate_certs }}"
loop: "{{ _nodes | product(_list_of_templates) | list }}"
loop: "{{ __nodes | product(__list_of_templates) | list }}"

0 comments on commit 67ff180

Please sign in to comment.