BUG or Operating As Designed?

11 views
Skip to first unread message

John Harmon

unread,
Feb 14, 2018, 2:48:32 PM2/14/18
to Ansible Project
I have the following playbook:
---
- hosts: "{{ host }}"

  roles
:
   
- ansible_dependencies
   
- aliases
   
- dns_update
   
- cpu_utilization
   
- role: nagios
      install
: yes
   
- password_policy
   
- role: disable_NetworkManager
      new_install
: yes
   
- ldap_users
   
- ps1_customize
   
- vim_customize
   
- sudoers
   
- grub_cmdline_oracle_tuning

- import_playbook: /playbooks/one-offs/bash_history.yml
- import_playbook: /playbooks/one-offs/dmesg_timestamps.yml
- import_playbook: /playbooks/one-offs/grub_cmdline.yml
- import_playbook: /playbooks/one-offs/update_gitlab_scripts.yml
- import_playbook: /playbooks/one-offs/grub_timeout.yml
- import_playbook: /playbooks/one-offs/update_sssd_ddns.yml
- import_playbook: /playbooks/one-offs/authconfig_cleanup.yml
- import_playbook: /playbooks/one-offs/change_timezone.yml
- import_playbook: /playbooks/one-offs/firefox_no_gui.yml
- import_playbook: /playbooks/one-offs/tcp_tuning.yml

In the middle of disable_NetworkManager I have the following.  It works perfectly stand-alone.
- meta: end_play
 
when: nm_installed.rc != 0 and new_install

When this is encountered it skips the remaining roles of my playbook (and continues on with my import_playbook sections).
The following get skipped:
    - ldap_users
   
- ps1_customize
   
- vim_customize
   
- sudoers
   
- grub_cmdline_oracle_tuning

I expected it to end the play for disable_networkManager, and then continue on with the rest of the roles.  Is this the way it is supposed to operate in this situation? is there a better approach to it?  Or does this sound like a bug?

Matt Martz

unread,
Feb 14, 2018, 3:15:00 PM2/14/18
to ansible...@googlegroups.com
A play encompasses `pre_tasks`, `roles`, `tasks`, and `post_tasks`.  You are expecting it to end the role.

Perhaps you should instead move all subsequent tasks of that role into a block or another file and use include_tasks, and then apply the `when` statement to that (but reverse the logic).

--
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 ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a114f93b-4365-48df-a3ad-79658047cb62%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net

Brian Coca

unread,
Feb 14, 2018, 3:32:34 PM2/14/18
to Ansible Project
a way to do this is having a block on whole role and a rescue that
checks for the error, which allows you to make a 'skip rest' kind
facility.



--
----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages