When conditional bug in Ansible 2.0.0.2 ?

69 views
Skip to first unread message

Mark Maas

unread,
Feb 11, 2016, 8:38:27 AM2/11/16
to Ansible Project
Hi List,

So I got this great thing here:

```
- name: Copy custom nrpe plugins
  template:
    src: "{{ item }}"
    dest: "{{ nrpe.plugins }}"
    mode: 0755
    owner: "{{ nrpe.user }}"
    group: "{{ nrpe.user }}"
  tags: update_nrpe
  notify: restart nrpe
  with_fileglob: "../templates/plugins/{{ nrpe_scripts }}/*"
  when: nrpe_scripts is defined
```

Works a treat with 1.9, it would be really easy to add service checks for special server cases.
With Ansible 2.0.0.2 this breaks, because 2.0 tries to fill the fileglob before looking at the when: conditional. And since the nrpe_scripts is not defined for most servers, it breaks!

An ugly hack would be to put a general variable in group_vars/all that just makes it look into an empty directory or something.

Is this a bug? or intended?

Thanks,
Mark

Matt Martz

unread,
Feb 11, 2016, 8:43:21 AM2/11/16
to ansible...@googlegroups.com
This is expected.  `when` statements work on each iteration of the `with_` loop, and as such the `when` statements are effectively inspected *after* `with_` loops.

Ansible 1.9 may have allowed this to pass due to a bug in logic, however 2.0 is more strict, and is properly failing.

--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/f4fc3672-c449-4b92-bb35-f72a65106919%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net

Mark Maas

unread,
Feb 11, 2016, 9:09:32 AM2/11/16
to Ansible Project
Interesting.

But people would expect a time of "deprecated but works" at the least.
And besides, I find the original way more logical. (Which will be so for more people, necessitating a deprecation warning,  not a complete failure)

I'm noticing a lot of stuff gone, sort of broken, changed behavior, between these two ansible versions. Not good for the mindset of people who I just managed to get onboard with Ansible.

Thanks,
Mark

Brian Coca

unread,
Feb 11, 2016, 10:20:33 AM2/11/16
to ansible...@googlegroups.com
The previous exception was ignored in this case, 2.0 does not ignore exceptions, that is the main difference.

​This is not a deprecated feature, it was an unreported error.​

----------
Brian Coca

Mark Maas

unread,
Feb 11, 2016, 1:51:20 PM2/11/16
to ansible...@googlegroups.com
Understood, we can call it all kinds of things, but companies and/or teams have been building playbooks with these things. They are now breaking.
One team I know is now using it as an excuse to start using puppet again as "Ansible is still a moving target".

This isn't a rant. ... ...well maybe a litte ;-)   But it's also an observation. Ansible really needs to be carefull with these sort of changes. I don't want people to turn to other things because of things like this.

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/2z3A7nGIfSw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.

To post to this group, send email to ansible...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
mark@debian:~$ cat ~/.signature
Mark Maas || Linux Engineer || DevOps

T: +31 6 215 924 05
Fastest way to my heart is via email

Brian Coca

unread,
Feb 11, 2016, 1:52:39 PM2/11/16
to ansible...@googlegroups.com
I'm not saying that it is not a problem, just that it is not as easy to mark as 'deprecated' when there was no knob to 'turn off this feature' but a general tightening on propagating and capturing errors.


----------
Brian Coca

Brian Coca

unread,
Feb 11, 2016, 2:21:31 PM2/11/16
to ansible...@googlegroups.com


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