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

ansible-inventory : add an "unmerge" feature to view all variables and overwrites #60941

Open
wants to merge 11 commits into
base: devel
from

Conversation

@b-abadie
Copy link
Contributor

commented Aug 20, 2019

SUMMARY

I added a feature to ansible-inventory --host called "unmerge" where one can see all inventory variables, where they come from (host var, group var and if so which group), and most importantly if there was any overwrite (and which value overwrote which other value).

See https://asciinema.org/a/263397 for a quick overview.

It is inspired from https://github.com/Gandi/hieracles/ (for puppet) which I miss when I use Ansible.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

ansible-inventory

ADDITIONAL INFORMATION

End result looks like this (with some color) :

$ ansible-inventory -i hosts --host webserver-1.example.com --unmerge
[                    all] dns.resolvers : ['192.168.1.1', '192.168.2.1']
[                    all] dns.search : 'example.com'
[webserver-1.example.com] interfaces.eth0.address : '10.0.0.1'
[                servers] interfaces.eth0.gateway : '10.0.0.254'
[+++++++++++++++++++++++] interfaces.eth0.mtu : 1500
--------------------------|webservers : 1500
--------------------------|   servers : 9000
[                servers] interfaces.eth0.netmask : 24
[                servers] interfaces.eth0.subnet : '10.0.0.0'
[                    all] users : [{'hash': '9a266fc8b42966fb624d852bafa241d8fd05b47d36153ff6684ab344bd1ae57bba96a7de8fc12ec0bb016583735d7f5bca6dd7d9bc6482ijustneedsomethinglongc2a3ac6bf6f9thisisnotrealec323f',
                                    'home': '/home/admin',
                                    'shell': 'bash',
                                    'sudoer': True,
                                    'username': 'admin'},
                                   {'hash': 'ee4cb392d97fa38585a433563b8f97a063bb3ec466fcdb1d19e24f73f8de71e3eb5b2526d0d546a94e258cc3c3425e6def6d4f73f8de7a0cd3c5057023c117f5ofcourse5c55ethisisnotarealhash3b55',
                                    'home': '/home/user',
                                    'shell': 'zsh',
                                    'sudoer': False,
                                    'username': 'user'}]

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Aug 20, 2019

The test ansible-test sanity --test pylint [explain] failed with 9 errors:

lib/ansible/cli/inventory.py:144:0: trailing-whitespace Trailing whitespace
lib/ansible/cli/inventory.py:294:46: multiple-statements More than one statement on a single line
lib/ansible/cli/inventory.py:315:29: multiple-statements More than one statement on a single line
lib/ansible/cli/inventory.py:323:30: bad-whitespace Exactly one space required around comparison                 if len(values)==1:  # There was no override, just display "[source] path.to.variable : value"                               ^^
lib/ansible/cli/inventory.py:324:29: ansible-format-automatic-specification Format string contains automatic field numbering specification
lib/ansible/cli/inventory.py:325:37: ansible-format-automatic-specification Format string contains automatic field numbering specification
lib/ansible/cli/inventory.py:332:29: ansible-format-automatic-specification Format string contains automatic field numbering specification
lib/ansible/cli/inventory.py:340:33: ansible-format-automatic-specification Format string contains automatic field numbering specification
lib/ansible/cli/inventory.py:341:41: ansible-format-automatic-specification Format string contains automatic field numbering specification

The test ansible-test sanity --test pep8 [explain] failed with 13 errors:

lib/ansible/cli/inventory.py:144:1: W293 blank line contains whitespace
lib/ansible/cli/inventory.py:285:161: E501 line too long (174 > 160 characters)
lib/ansible/cli/inventory.py:294:45: E701 multiple statements on one line (colon)
lib/ansible/cli/inventory.py:294:161: E501 line too long (173 > 160 characters)
lib/ansible/cli/inventory.py:295:76: E114 indentation is not a multiple of four (comment)
lib/ansible/cli/inventory.py:295:76: E116 unexpected indentation (comment)
lib/ansible/cli/inventory.py:315:28: E701 multiple statements on one line (colon)
lib/ansible/cli/inventory.py:318:161: E501 line too long (166 > 160 characters)
lib/ansible/cli/inventory.py:323:31: E225 missing whitespace around operator
lib/ansible/cli/inventory.py:328:161: E501 line too long (167 > 160 characters)
lib/ansible/cli/inventory.py:331:161: E501 line too long (171 > 160 characters)
lib/ansible/cli/inventory.py:335:161: E501 line too long (167 > 160 characters)
lib/ansible/cli/inventory.py:341:161: E501 line too long (174 > 160 characters)

click here for bot help

@ansibot ansibot added needs_revision and removed core_review labels Aug 20, 2019

@jillr jillr removed the needs_triage label Aug 22, 2019

@ansibot ansibot added the stale_ci label Aug 31, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.