On Thursday, June 5, 2014 2:56:23 PM UTC-7, Jason Edelman wrote: > > Hi, > > I have a single playbook using one module to gather facts about ONE device > and this works all good. Upon execution, I register a variable and display > several debug messages. All good. I added a second host to the hosts file > and I'm now getting good debug info on both devices. > > My next task is to compare, or do a diff, on particular fact data from > each device. This diff would happen by sending both variables (facts) to > another custom module to analyze. I was going to do a single host per > playbook and pass the registered variable to a 3rd playbook, but variables > are only valid within the pb. As an alternative, I suppose I can write the > contents of the registered variable to a file in the first pb and the read > from that in the second playbook, then do the needed comparisons, but that > just doesn't seem right. > > While this scenario is for custom facts, the same solution should hold > true for the off the shelf facts too. > > What would be the best approach for this? Any feedback would be greatly > appreciated. > > If you have a single play to gather facts on all hosts you can then have a second play within the same playbook that compares the facts for different hosts... This would work for runs with small numbers of hosts but might get a lot harder for larger quantities of hosts.
http://docs.ansible.com/playbooks_variables.html#magic-variables-and-how-to-access-information-about-other-hosts You could take the first host and assume that it is definitive and then walk through all of the other hosts comparing the facts that you care about and saying which ones differ. This would work for two hosts, and might work for more but if the odd one out was the first host then you would get a list of all other hosts as differing. I hope that this helps, Adam -- 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 post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/471be03a-841b-419a-a1d3-0c0a7bde972f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
