我试图安排一个 ansible playbook 来重新索引 Jira,我也希望我们的开发人员能够临时启动这个,他们可以通过 AWX 来做,我可以开始重新索引但是重新索引完成时希望收到通知。
这是我的 CLI 命令和输出:
[root@devjira02 ~]# curl -u admin:admin123! -X GET https://devjira.comapny.com/rest/api/2/reindex/progress
{"progressUrl":"/secure/admin/jira/IndexProgress.jspa?taskId=12720","currentProgress":35,"currentSubTask":"Currently working on: Issue index","type":"BACKGROUND","submittedTime":"2019-04-01T14:23:50.971+0100","startTime":"2019-04-01T14:23:50.973+0100","success":false}
[root@devjira02 ~]# curl -u admin:admin123! -X GET https://devjira.company.com/rest/api/2/reindex/progress
{"progressUrl":"/secure/admin/jira/IndexProgress.jspa?taskId=12720","currentProgress":100,"type":"BACKGROUND","submittedTime":"2019-04-01T14:23:50.971+0100","startTime":"2019-04-01T14:23:50.973+0100","finishTime":"2019-04-01T14:24:33.922+0100","success":true}
我的剧本:
- name: DEV Jira Re-index
become: true
become_method: sudo
become_user: root
hosts: DEVJIRA02
gather_facts: yes
tasks:
- name: Jira Re-index
uri:
url: https://devjira.company.com/rest/api/2/reindex?type=BACKGROUND_PREFERRED
method: POST
user: admin
password: admin123!
force_basic_auth: yes
status_code: [201, 202]
- name: Wait until re-index completes
uri:
url: https://devjira.company.com/rest/api/2/reindex/progress
method: GET
user: admin
password: admin123!
force_basic_auth: yes
status_code: [201, 202]
return_content: yes
body_format: json
register: result
until: result.json.success == true
retries: 180
delay: 30
我希望第二部分重试直到成功 == true,此时 AWX 可以发送通知电子邮件。手动运行 playbook 将启动重新索引,但即使重新索引已完成,重试也会重试