debops / ansible-ifupdown

Manage network interface configuration in /etc/network/interfaces
GNU General Public License v3.0
25 stars 14 forks source link

How to check if role changed something when using as depencendy in some other role? #55

Closed tklicki closed 8 years ago

tklicki commented 8 years ago

Hi, I'm using debops.ifupdown in some other role as dependency. I would like to know if it has changed anything on the host. I want to make some conditional check using "when:" inside other tasks I wrote myself.

What would be the best way to do this? Is there any variable that i can check like "ifupdown_var.changed" that I can use?

Regards. Tomek

drybjed commented 8 years ago

I suppose that you could check the state of any variables that the role registers. Currently there's no universal location that could be checked to see if a role changed something.

Perhaps if you would say what are you interested in, I could help more. What are you looking for?

tklicki commented 8 years ago

Thank you for very fast response and great idea. Do you think that something like this would be ok?

- name: Task name
  (...)
  when: ifupdown_register_interfaces_generator|changed
drybjed commented 8 years ago

Sure, although if you want for your role to work when debops.ifupdown isn't included, you should rather use something like:

- name: Do the thing
  when: ifupdown_register_interfaces_generator|d() and
        ifupdown_register_interfaces_generator|changed

That way if the role is not included in the playbook, your role will still work and just not run the task.

tklicki commented 8 years ago

Thank you very much!