File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 101101 {%- set result = [] -%}
102102 {%- for asn in active_assignments.json -%}
103103 {%- set check_cmd = "curl -s https://{}/api/v3/assignments/{} | jq '.validated'".format(quads_api_server, asn.id) -%}
104- {%- set term_cmd = "curl -s -k -X POST -H 'Authorization: Bearer {}' https://{}/api/v3/assignments/terminate/{} | \
105- jq".format(quads_token, quads_api_server, asn.id) -%}
104+ {%- set login_cmd = "curl -s -k -X POST -u '{}:{}' https://{}/api/v3/login/ | jq -r '.auth_token'".format(
105+ quads_user_email, quads_password, quads_api_server) -%}
106+ {%- set term_cmd = 'curl -s -k -X POST -H "Authorization: Bearer $({login})" https://{server}/api/v3/assignments/terminate/{id} | jq'.format(
107+ login=login_cmd, server=quads_api_server, id=asn.id) -%}
106108 {%- set _ = asn.update({'check_status_command': check_cmd, 'terminate_command': term_cmd}) -%}
107109 {%- set _ = result.append(asn) -%}
108110 {%- endfor -%}
239241 ansible.builtin.set_fact :
240242 check_status_command : " curl -s https://{{ quads_api_server }}/api/v3/assignments/{{ assignment_id }} | jq '.validated'"
241243 terminate_command : >-
242- curl -s -k -X POST -H 'Authorization: Bearer {{ quads_token }}'
244+ curl -s -k -X POST -H "Authorization: Bearer $(curl -s -k -X POST -u '{{ quads_user_email }}:{{ quads_password }}'
245+ https://{{ quads_api_server }}/api/v3/login/ | jq -r '.auth_token')"
243246 https://{{ quads_api_server }}/api/v3/assignments/terminate/{{ assignment_id }} | jq
244247 changed_when : false
245248
You can’t perform that action at this time.
0 commit comments