ansible
ansible copied to clipboard
`meta: end_host` returns `rc=2` when run in a rescue block
Summary
When I run meta: end_host in a rescue block, Ansible finishes with rc=2. I expect it to exit with rc=0 as usual.
Issue Type
Bug Report
Component Name
meta
Ansible Version
$ ansible --version
ansible [core 2.16.6]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/spetrosi/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/spetrosi/.local/lib/python3.11/site-packages/ansible
ansible collection location = /home/spetrosi/.ansible/collections:/usr/share/ansible/collections
executable location = /home/spetrosi/.local/bin/ansible
python version = 3.11.9 (main, Apr 17 2024, 00:00:00) [GCC 13.2.1 20240316 (Red Hat 13.2.1-7)] (/usr/bin/python3)
jinja version = 3.1.3
libyaml = True
Configuration
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = /etc/ansible/ansible.cfg
EDITOR(env: EDITOR) = vim
OS / Environment
Fedora 38
Steps to Reproduce
- Run this playbook to reproduce rc=2:
---
- name: Ensure that the role runs with default parameters
hosts: all
tasks:
- name: Run in a block to clean up afterwards
block:
- name: Fail
fail:
msg: Test fail
rescue:
- name: Assert failure
assert:
that: __str in ansible_failed_result.msg
vars:
__str: Test fail
- name: End host
meta: end_host
- Assert that
rc== 2:
$ echo $?
2
- Run this playbook that would return rc=0:
---
- name: Ensure that the role runs with default parameters
hosts: all
tasks:
- name: End host
meta: end_host
- Assert that
rc== 0:
$ echo $?
0
Expected Results
rc == 0 in both cases
Actual Results
rc == 2
Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
Files identified in the description:
If these files are incorrect, please update the component name section of the description or use the component bot command.