Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for hash_behaviour=merge to atk-show-vars #25

Open
andyrhee opened this issue Feb 27, 2016 · 0 comments
Open

Add support for hash_behaviour=merge to atk-show-vars #25

andyrhee opened this issue Feb 27, 2016 · 0 comments
Assignees
Milestone

Comments

@andyrhee
Copy link

We use hash_behaviour=merge (e.g. in ansible.cfg) in our roles heavy env. In this case, it would be helpful to show the resulting dictionary as additive instead of exclusive. For example, the show_diff function could display output showing previous items, new items, and merged items.

I can simply modify the show_diff function to suit my case, but it may be useful to other people to add this as an option.

--- /Library/Python/2.7/site-packages/ansible_toolkit/show_vars.py.orig 2016-02-26 16:59:12.000000000 -0800
+++ /Library/Python/2.7/site-packages/ansible_toolkit/show_vars.py  2016-02-26 17:07:33.000000000 -0800
@@ -9,8 +9,15 @@
         if k in old.keys() and v == old[k]:
             continue
         if k in old.keys() and v != old[k]:
-            red(" - ['{}'] = {}".format(k, old[k]))
-        green(" + ['{}'] = {}".format(k, v))
+            # as if hash_behaviour = merge
+            z = old[k].copy()
+            z.update(v)
+
+            green(" p ['{}'] = {}".format(k, old[k]))
+            red(" + ['{}'] = {}".format(k, v))
+            green(" = ['{}'] = {}".format(k, z))
+        else:
+            green(" + ['{}'] = {}".format(k, v))
@steenzout steenzout self-assigned this Apr 13, 2016
@steenzout steenzout added this to the v2.0.2 milestone Apr 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants