Skip to content

Commit d619b49

Browse files
pablintinofrenzyfriday
authored andcommitted
[autoholds] Use the krb_requests module to fetch holds
Since the zuul API may be behind a kerberos secured gateway let's consume the endpoint with the module to allow automatic authentication if a kerberos token was already been issued.
1 parent 347b5c2 commit d619b49

File tree

2 files changed

+11
-29
lines changed

2 files changed

+11
-29
lines changed

ci/playbooks/multinode-autohold.yml

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
- name: "Run ci/playbooks/multinode-autohold.yml"
3-
hosts: "{{ cifmw_zuul_target_host | default('all') }}"
3+
hosts: controller, primary
44
gather_facts: true
55
tasks:
66
- name: Verify if "success" flag exists after successful tests execution
@@ -37,38 +37,20 @@
3737
'autohold'
3838
] | join('/')
3939
}}
40-
ansible.builtin.uri:
41-
url: "{{ zuul_autohold_endpoint | default(_zuul_api_url) }}"
42-
method: GET
43-
headers:
44-
Content-Type: "application/json"
45-
Accept: "application/json"
46-
return_content: yes
47-
status_code: 200
48-
body_format: json
49-
register: autoholds_response
50-
retries: 2
51-
delay: 10
52-
until:
53-
- autoholds_response.status is defined
54-
- autoholds_response.content_type is defined
55-
- autoholds_response.status == 200
56-
- "autoholds_response.content_type.startswith('application/json')"
57-
ignore_errors: true
40+
cifmw_krb_request_url: "{{ zuul_autohold_endpoint | default(_zuul_api_url) }}"
41+
ansible.builtin.include_role:
42+
name: krb_request
43+
apply:
44+
ignore_errors: true # noqa: ignore-errors
5845

5946
- name: Check if any autohold matches
6047
vars:
6148
autoholds_returned_data: >-
6249
{{
6350
(
64-
autoholds_response.content |
65-
default('[]') |
66-
from_json
67-
) if
68-
(
69-
(not autoholds_response.failed) and
70-
autoholds_response.content_type.startswith('application/json')
71-
)
51+
cifmw_krb_request_out.response_json |
52+
default([])
53+
) if (not cifmw_krb_request_out.failed)
7254
else []
7355
}}
7456
autohold_candidates: >-

plugins/modules/krb_request.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ def main():
201201
except ValueError as e:
202202
module.fail_json(msg=f"Error with the JSON response: {str(e)}")
203203

204-
if "dest" in module.params:
205-
dest = module.params["dest"]
204+
dest = module.params.get("dest", None)
205+
if dest:
206206
if (
207207
os.path.exists(dest)
208208
and os.path.isdir(dest)

0 commit comments

Comments
 (0)