This will always execute the role THEN fail if the condition is true. You need
a different construct that only executes the condition
when: result.user_input == "YES"
I also don't know if you can use conditions when using roles: like this. It may
only work when you use the include_role as a task.
- tasks:
- include_role:
name: add_post_patch_motd
when: result.user_input == "YES"
Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123
On Oct 19, 2022, at 1:17 AM, Neha Singh
<[email protected]<mailto:[email protected]>> wrote:
Hi Team,
I was trying to add one condition, in which if it should failed on that
particular point. So, entire playbook should stop. Below is the written
playbook.
- hosts: all
gather_facts: yes
pre_tasks:
- name: Verification Step before starting the post-patch playbook
pause:
prompt: "You are starting post patch playbook on {{ansible_hostname}}
\n To Continue, please enter 'YES'"
register: result
roles:
- role: add_post_patch_motd
failed_when: result.user_input != "YES"
- role: qradar_install/post_install/python_setup
- import_playbook: patch_cleanup.yml
- import_playbook: iso.yml
- import_playbook: post_patch_setup.yml
Here, user needs to enter interactive input for the "result" variable and if
entered result value is other than "YES" then role should not be called and
should get failed. So, as you can see I have used failed_when condition and
based on that result value, it should not call role or get failed and entire
playbook should stopped running. But now, even with failed_when condition
satisfy, the role (add_post_patch_motd) is getting called. Do let me know what
I am missing here.
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
[email protected]<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/a58aa60c-053e-45df-be40-e3afe17cc1dan%40googlegroups.com<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2Fa58aa60c-053e-45df-be40-e3afe17cc1dan%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7Cwalter.rowe%40nist.gov%7C50af6d417cad42741fcc08dab1913ea2%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638017534647175099%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=1RM4pzjAhoKs%2Bl%2FDRac6GI%2BkBPImYfpS4fNhccOE98g%3D&reserved=0>.
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/32313679-F3FE-4F7B-A053-463416E82C9B%40nist.gov.