В моей пьесе ansible я пытаюсь закрыть билеты jira на основе условия - если значение моего set_fact = = 0, l oop в списке ключей билетов Jira и закрыть их все. Задача выполняется на моем указанном хосте в моем инвентаре (не localhost).
Вот моя книга игр:
# Get the length of x
- name: Find the length of x
set_fact:
length_of_x: "{{ x | length }}"
- name: Printing the length of x
debug:
var: length_of_x
# If x is an empty list, move JIRA tickets to "Closed" status and skip next steps
- name: Close JIRA ticket
jira:
uri: 'https://ip.ip.ip.ip'
username: 'foo'
password: 'foo'
validate_certs: false
project: test
issue: "{{ item.ticket_key }}"
operation: transition
status: Closed
loop: "{{ ticket_key }}"
when: **length_of_x == 0**
run_once: true
register: jira_close_results
- name: Print the complete response
debug: var=jira_close_results
Я ожидаю, что, поскольку у меня есть x в качестве пустого списка, length_of_x == 0, поэтому билет на jira будет закрыт. Вместо этого я получаю следующее:
TASK [Printing x] ******************************************
ok: [host] => {
"x": []
}
TASK [Find the length of x] **********************************
ok: [host]
TASK [Printing the length of x] **********************************
ok: [host] => {
**"length_of_x": "0"**
}
TASK [Close JIRA ticket] *****************************
skipping: [host] => (item=test-100)
TASK [Print the complete response] *********************************************
ok: [host] => {
"jira_close_results": {
"changed": false,
"msg": "All items completed",
"results": [
{
"ansible_loop_var": "item",
"changed": false,
"item": "test-100",
"skip_reason": "Conditional result was False",
"skipped": true
}
]
}
}
Я пробовал много разных способов определения условия когда, но ничего не работает, оно пропускается каждый раз. Заранее благодарю за помощь.