Giter Club home page Giter Club logo

ansible-inventory-grapher's People

Contributors

ahlinc avatar eking-go avatar jody-frankowski avatar maweki avatar srgvg avatar willthames avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-inventory-grapher's Issues

Doesn't support IP address

Hello,

I am experiencing the following problem when my hostname is an IP address :

ansible-inventory-grapher -i /etc/ansible/hosts 192.168.128.1 -d inventoryGraph --format "test-{hostname}.dot"
Traceback (most recent call last):
File "/bin/ansible-inventory-grapher", line 128, in
main()
File "/bin/ansible-inventory-grapher", line 124, in main
render_graph(arg, options)
File "/bin/ansible-inventory-grapher", line 106, in render_graph
filename = options.format.format(pattern)
KeyError: 'hostname'

whereas the a fdqn it doesn't repport the error.

Tanks

JF

Variables don't display with ansible 2.1.1rc3

it seems that host.vars and host.get_vars don't return the results we need following the move to Ansible 2.2

variable_manager.get_vars will get host_vars but not group_vars. Need a workable solution so that the graph shows the variable source too.

vars are not displayed correctly using yml-based inventory

We recently switched to a yml-based inventory file including all hosts, groups and vars in one file.
With the ini-based everything works fine and vars are shown in the groups and hosts they are defined in.
With the yml-based inventory all vars are showing in the hosts. Even when they are defined in a group.

We are using the following grapher version:
$ ansible-inventory-grapher --version ansible-inventory-grapher 2.4.5

Unable to run ansible-inventory-grapher --version after install

After installing using sudo pip install ansible-inventory-grapher on a Mac, I could not even run ansible-inventory-grapher --version or --help

I am using ansible version 1.9.4

I got the following error message. Is there some dependencies missing?

ansible-inventory-grapher --help
Traceback (most recent call last):
  File "/usr/local/bin/ansible-inventory-grapher", line 23, in 
    from ansible.cli import CLI
ImportError: No module named cli

Error parsing inventory files

Hi - i'm seeing this, not sure why...

11:26 $ ansible-inventory-grapher -i inventory/dev {group} -d gtemp --format "test-{hostname}.dot"
Traceback (most recent call last):
  File "/usr/bin/ansible-inventory-grapher", line 182, in <module>
    main()
  File "/usr/bin/ansible-inventory-grapher", line 178, in main
    render_graph(arg, options)
  File "/usr/bin/ansible-inventory-grapher", line 133, in render_graph
    inventory = ansible.inventory.Inventory(loader=loader, variable_manager=variable_manager, host_list=options.inventory)
  File "/usr/lib/python2.7/site-packages/ansible/inventory/__init__.py", line 97, in __init__
    self.parse_inventory(host_list)
  File "/usr/lib/python2.7/site-packages/ansible/inventory/__init__.py", line 150, in parse_inventory
    self.parser = get_file_parser(host_list, self.groups, self._loader)
  File "/usr/lib/python2.7/site-packages/ansible/inventory/dir.py", line 84, in get_file_parser
    raise AnsibleError('\n'.join(myerr))
ansible.errors.AnsibleError: Attempted to read "inventory/dev" as YAML: Syntax Error while loading YAML.

The error appears to have been in '/data/source/ansible/inventory/dev': line 6, column 1, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

[group-name]
xxxxxxxxxxx.zzzzz.abc.com
^ here

Attempted to read "inventory/dev" as ini file: can't add group to itself 

The inventory file (excerpt below) works file with either ansible or ansible-playbook runs.

# inventory file for development servers
# ansible-playbook -i inventory/dev <playbook>

# dev group nodes
[dev-group]
xxxxxxxxxxxxx1.abc.com
xxxxxxxxxxxxx2.abc.com
xxxxxxxxxxxxx3.abc.com

Thoughts?

cannot import name PromptVaultPass

Getting this error on Mac OS 10.13.1, with ansible 2.4.1 and python 2.7.10, when using --ask-vault-pass:

$ ansible-inventory-grapher -i /path/to/hosts --ask-vault-pass \*

Traceback (most recent call last):
  File "/usr/local/bin/ansible-inventory-grapher", line 154, in <module>
    main()
  File "/usr/local/bin/ansible-inventory-grapher", line 150, in main
    render_graph(arg, options)
  File "/usr/local/bin/ansible-inventory-grapher", line 109, in render_graph
    inventory_mgr = ansibleinventorygrapher.inventory.InventoryManager(options.inventory, options.ask_vault_pass, options.vault_password_file)
  File "/Library/Python/2.7/site-packages/ansibleinventorygrapher/inventory.py", line 158, in __init__
    self.inventory = INVENTORY(inventory, ask_vault_pass, vault_password_file)
  File "/Library/Python/2.7/site-packages/ansibleinventorygrapher/inventory.py", line 104, in __init__
    super(Inventory24, self).__init__(inventory, ask_vault_pass, vault_password_file)
  File "/Library/Python/2.7/site-packages/ansibleinventorygrapher/inventory.py", line 24, in __init__
    self.vault_pass = self.ask_vault_password()
  File "/Library/Python/2.7/site-packages/ansibleinventorygrapher/inventory.py", line 98, in ask_vault_password
    from ansible.parsing.vault import PromptVaultPass
ImportError: cannot import name PromptVaultPass

Make it work with dict variables

Need to ensure tidy_all_the_variables copes with dict merges (fun logic in there, no doubt)

Also the graph will need to be able to display dict keys

One graph per command line arg

What happens now is that for each host that matches a pattern, a separate graph is created.

This means that we can't graph a group and show its hosts. That should be fixed.

Variables not visible with new ansible(s)

Hey there,

we recently updated ansible from 2.1.0.0 to 2.3.2.0 and now the group variables are not displayed in the graphs. Generating the graphs with:

ansible-inventory-grapher -i inventories/local.ini 'all' > local.dot
dot -Tpng local.dot > local.png

Using grapher ver. 2.4.0, here's what I get for following ansible versions:

2.1.0.0:
local-2 1 0 0

2.2.0.0:
local-2 2 0 0

2.3.2.0:
local

Can anybody reproduce this, or am I the only one?

does not run on RHEL6: SyntaxError: invalid syntax

This is really simple to report :)

$ ansible-inventory-grapher -h
Traceback (most recent call last):
  File "/usr/bin/ansible-inventory-grapher", line 25, in <module>
    import ansibleinventorygrapher
  File "/usr/lib/python2.6/site-packages/ansibleinventorygrapher/__init__.py", line 107
    nodes = {Node(host.name, vars=vars[host], leaf=True)}
                                                        ^
SyntaxError: invalid syntax

Hopefully it is a simple answer. Thanks!

Error: bad label format for complex variable

Trying to output a complex (dict) variable triggers a
Error: bad label format

<table border="0" cellborder="0">
  <tr><td><b>
  <font face="Times New Roman, Bold" point-size="16">foo</font>
  </b></td></tr>
<hr/><tr><td><font face="Times New Roman, Bold" point-size="14">ansible_python_interpreter<br/>ansible_user<br/>os_servers = {'foo': {'bar': 'DE'}}<br/></font></td></tr></table>

Ansible 2.4.0 compatible?

ansible-inventory-grapher (2.4.0) seems to not work with ansible 2.4.0, for me anyway.

$ /usr/local/bin/ansible-inventory-grapher --ask-vault-pass -i production -d graphs/ -q hostname
Traceback (most recent call last):
  File "/usr/local/bin/ansible-inventory-grapher", line 182, in <module>
    main()
  File "/usr/local/bin/ansible-inventory-grapher", line 178, in main
    render_graph(arg, options)
  File "/usr/local/bin/ansible-inventory-grapher", line 125, in render_graph
    vault_pass = ask_vault_pass()
  File "/usr/local/bin/ansible-inventory-grapher", line 36, in ask_vault_pass
    return utils.ask_passwords(ask_vault_pass=True)[2]
NameError: global name 'utils' is not defined

Can anyone reproduce this issue?

$ pip list | grep ansible
ansible (2.4.0.0)
ansible-inventory-grapher (2.4.0)

Couldn't find a secret to decrypt vaulted file(s)

Using Ansible 2.2 and ansible-inventory-grapher 2.4.4, when I enter a vault password (using either --ask-vault-pass or --vault-password-file), I get the following error:

$ ansible-inventory-grapher -i /path/to/hosts --ask-vault-pass \*
Vault password: 
Couldn't find a secret to decrypt vaulted file(s)

set literal syntax invalid in python 2.6.6

Hi you've used the new set literal syntax in line 108 but that is not supported until python 2.7.3 something.

Poor old rhel6 and centos6 still have the base/default python version 2.6.x

A fix would be to do:

    nodes = set()
    nodes.add(....)

TypeError on run with ansible 2.0.2.0

# ansible-inventory-grapher webserver
Traceback (most recent call last):
  File "/bin/ansible-inventory-grapher", line 128, in <module>
    main()
  File "/bin/ansible-inventory-grapher", line 124, in main
    render_graph(arg, options)
  File "/bin/ansible-inventory-grapher", line 88, in render_graph
    inventory = ansible.inventory.Inventory(options.inventory)
TypeError: __init__() takes at least 3 arguments (2 given)

variables with value?

Hi,
the graphing tool is nice,
I am trying to get the values of variables too, is it that something easy to achieve?
Thanks!

unbound method _read_file() must be called with FileVaultSecret instance as first argument

Getting this error on Mac OS 10.13.1, with ansible 2.4.1 and python 2.7.10, when using --vault-password-file:

$ ansible-inventory-grapher -i /path/to/hosts --vault-password-file=pass.txt \*

Traceback (most recent call last):
  File "/usr/local/bin/ansible-inventory-grapher", line 154, in <module>
    main()
  File "/usr/local/bin/ansible-inventory-grapher", line 150, in main
    render_graph(arg, options)
  File "/usr/local/bin/ansible-inventory-grapher", line 109, in render_graph
    inventory_mgr = ansibleinventorygrapher.inventory.InventoryManager(options.inventory, options.ask_vault_pass, options.vault_password_file)
  File "/Library/Python/2.7/site-packages/ansibleinventorygrapher/inventory.py", line 158, in __init__
    self.inventory = INVENTORY(inventory, ask_vault_pass, vault_password_file)
  File "/Library/Python/2.7/site-packages/ansibleinventorygrapher/inventory.py", line 104, in __init__
    super(Inventory24, self).__init__(inventory, ask_vault_pass, vault_password_file)
  File "/Library/Python/2.7/site-packages/ansibleinventorygrapher/inventory.py", line 26, in __init__
    self.vault_pass = self.read_vault_password_file(vault_password_file)
TypeError: unbound method _read_file() must be called with FileVaultSecret instance as first argument (got str instance instead)

Suggestion: exclude groups

If you have multiple overlapping groups in your inventory, the graph output can be confusing. It might be useful if we could specify a list of groups (or group patterns) to exclude from the graph.

I'm not talking about the host patterns, which would change the hosts that appear in the graph. Just hiding some of their parent groups.

Include role dependencies in graph

It would be great if the graph would include role dependencies (from meta/main.yml of each roles, including the one imported from ansible Galaxy)

Stéphane

Please release/tag source

Hi,
I see PyPi released tarball do not have test directory but upstream have it in git. Can it be possible to release tarballs on github that will give complete tarball including test directory?

ansible requirement should be ansible-core

The checks for "ansible" versions should now be for "ansible-core", since ansible was factored into all the actual working code being in "ansible-core" and the "ansible" pypi.org not actually containing any of ansible, only 100 ansible collection modules and "including" ansible-core, which it does not. ansible-core is the relevent requirement from pypi.org, even though it actually installs the modules named "ansible" in the python module directories.

Yes, it's silly and confusing, but the authors show no hint of revising the packaging. Please point to "ansible-core" as the modern dependency, to avoid introducing an unwelcome and unnecessary half a Gig of local disk used for the contemporary "ansible" package.

Decryption failed on vault file

I tried downgrading from Ansible 2.4 to 2.2, since I was having issues with the vault command (#31, #32). I got past those errors, but now it's unable to decrypt the vault file. This is on Mac OS 10.13.1, with ansible 2.2.0.0 and python 2.7.10, when using --ask-vault-pass:

$ ansible-inventory-grapher -i /path/to/hosts --ask-vault-pass \*

Vault password: <entered password>
Traceback (most recent call last):
  File "/usr/local/bin/ansible-inventory-grapher", line 154, in <module>
    main()
  File "/usr/local/bin/ansible-inventory-grapher", line 150, in main
    render_graph(arg, options)
  File "/usr/local/bin/ansible-inventory-grapher", line 109, in render_graph
    inventory_mgr = ansibleinventorygrapher.inventory.InventoryManager(options.inventory, options.ask_vault_pass, options.vault_password_file)
  File "/Library/Python/2.7/site-packages/ansibleinventorygrapher/inventory.py", line 158, in __init__
    self.inventory = INVENTORY(inventory, ask_vault_pass, vault_password_file)
  File "/Library/Python/2.7/site-packages/ansibleinventorygrapher/inventory.py", line 73, in __init__
    host_list=inventory)
  File "/Library/Python/2.7/site-packages/ansible/inventory/__init__.py", line 97, in __init__
    self.parse_inventory(host_list)
  File "/Library/Python/2.7/site-packages/ansible/inventory/__init__.py", line 164, in parse_inventory
    group.vars = combine_vars(group.vars, self.get_group_variables(group.name))
  File "/Library/Python/2.7/site-packages/ansible/inventory/__init__.py", line 554, in get_group_variables
    self._vars_per_group[groupname] = self._get_group_variables(groupname, vault_password=vault_password)
  File "/Library/Python/2.7/site-packages/ansible/inventory/__init__.py", line 572, in _get_group_variables
    vars = combine_vars(vars, self.get_group_vars(group))
  File "/Library/Python/2.7/site-packages/ansible/inventory/__init__.py", line 774, in get_group_vars
    return self._get_hostgroup_vars(host=None, group=group, new_pb_basedir=new_pb_basedir, return_results=return_results)
  File "/Library/Python/2.7/site-packages/ansible/inventory/__init__.py", line 835, in _get_hostgroup_vars
    host_results = self._variable_manager.add_group_vars_file(base_path, self._loader)
  File "/Library/Python/2.7/site-packages/ansible/vars/__init__.py", line 615, in add_group_vars_file
    data = self._load_inventory_file(path, loader)
  File "/Library/Python/2.7/site-packages/ansible/vars/__init__.py", line 553, in _load_inventory_file
    results = self._load_inventory_file(path=p, loader=loader)
  File "/Library/Python/2.7/site-packages/ansible/vars/__init__.py", line 568, in _load_inventory_file
    data = loader.load_from_file(path)
  File "/Library/Python/2.7/site-packages/ansible/parsing/dataloader.py", line 119, in load_from_file
    (file_data, show_content) = self._get_file_contents(file_name)
  File "/Library/Python/2.7/site-packages/ansible/parsing/dataloader.py", line 178, in _get_file_contents
    data = self._vault.decrypt(data, filename=b_file_name)
  File "/Library/Python/2.7/site-packages/ansible/parsing/vault/__init__.py", line 264, in decrypt
    raise AnsibleError(msg)
ansible.errors.AnsibleError: Decryption failed on /path/to/secret.yml

However, when I ran this on the same file, and entered the same password, it was able to display the file:

ansible-vault view --ask-vault-pass /path/to/secret.yml

different colours for custom groups

Hi, again we find it very useful to toy around, in order to see some production use we could have different groups represented with different colours.
EG: Ansible reserved groups with grey and our defined groups with other colour, maybe even the children with specific colours.
Thanks!

group_vars with encrypted values embedded in yml require "--ask-vault-pass"

A group_vars file containing embedded encrypted values, requires a password to be given for the vault, but the parameter is available in plain text.

For example:

admin_password: !vault |
          $ANSIBLE_VAULT;1.1;AES256
 1234567890abc...

When processing an inventory, an error is displayed:

$ ansible-inventory-grapher -i inventory/hosts all > inventory/hosts.dot

The error:

Traceback (most recent call last):
  File "/usr/local/bin/ansible-inventory-grapher", line 167, in <module>
    main()
  File "/usr/local/bin/ansible-inventory-grapher", line 163, in main
    render_graph(arg, options)
  File "/usr/local/bin/ansible-inventory-grapher", line 136, in render_graph
    (host_edges, host_nodes) = ansibleinventorygrapher.generate_graph_for_host(host, inventory_mgr)
  File "/usr/local/lib/python2.7/site-packages/ansibleinventorygrapher/__init__.py", line 105, in generate_graph_for_host
    vars = tidy_all_the_variables(host, inventory_mgr)
  File "/usr/local/lib/python2.7/site-packages/ansibleinventorygrapher/__init__.py", line 97, in tidy_all_the_variables
    remove_inherited_and_overridden_vars(_vars[host], group, inventory_mgr)
  File "/usr/local/lib/python2.7/site-packages/ansibleinventorygrapher/__init__.py", line 77, in remove_inherited_and_overridden_vars
    if gv[k] == v:
  File "/usr/local/lib/python2.7/site-packages/ansible/parsing/yaml/objects.py", line 119, in __eq__
    return other == self.data
  File "/usr/local/lib/python2.7/site-packages/ansible/parsing/yaml/objects.py", line 107, in data
    return to_text(self.vault.decrypt(self._ciphertext))
  File "/usr/local/lib/python2.7/site-packages/ansible/parsing/vault/__init__.py", line 658, in decrypt
    plaintext, vault_id, vault_secret = self.decrypt_and_get_vault_id(vaulttext, filename=filename)
  File "/usr/local/lib/python2.7/site-packages/ansible/parsing/vault/__init__.py", line 696, in decrypt_and_get_vault_id
    raise AnsibleVaultError('Attempting to decrypt but no vault secrets found')
ansible.parsing.vault.AnsibleVaultError: Attempting to decrypt but no vault secrets found

This can be solved by adding --ask-vault-pass, but I think it's not required to give a password.

Graph should be nicer

Add row separation between top and variables

(Basically make it a table with two rows, and the second row split by br tags).

Use th for top row (or b if that doesn't work)

Support vault_identity_list

I've various vault from various identities in my inventory. My typical ansible.cfg contains:
vault_identity_list = prod@./vault-client.sh , preprod@./vault-client.sh , foo@./vault-client.sh

But it does not seem supported by ansible-inventory-grapher
export ANSIBLE_VAULT_IDENTITY_LIST didn't make it either.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.