haidaram / ansible-playbook-grapher Goto Github PK
View Code? Open in Web Editor NEWA command line tool to create a graph representing your Ansible playbook tasks and roles
License: GNU General Public License v3.0
A command line tool to create a graph representing your Ansible playbook tasks and roles
License: GNU General Public License v3.0
If a role references itself, the hover of the related nodes fails since we will end up with an infinite recursive call.
TODO: break the loop if we find a known node.
Describe the bug
After upgrading the library it started to fail with:
Done parsing Play: Run cluster deployment on prepared hypervisors (1) **********
Traceback (most recent call last):
File "/usr/local/bin/ansible-playbook-grapher", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.8/dist-packages/ansibleplaybookgrapher/cli.py", line 249, in main
cli.run()
File "/usr/local/lib/python3.8/dist-packages/ansibleplaybookgrapher/cli.py", line 71, in run
svg_path = renderer.render(
File "/usr/local/lib/python3.8/dist-packages/ansibleplaybookgrapher/renderer.py", line 114, in render
self._convert_to_graphviz()
File "/usr/local/lib/python3.8/dist-packages/ansibleplaybookgrapher/renderer.py", line 391, in _convert_to_graphviz
self.render_node(
File "/usr/local/lib/python3.8/dist-packages/ansibleplaybookgrapher/renderer.py", line 153, in render_node
self.render_block(
File "/usr/local/lib/python3.8/dist-packages/ansibleplaybookgrapher/renderer.py", line 244, in render_block
self.render_node(
File "/usr/local/lib/python3.8/dist-packages/ansibleplaybookgrapher/renderer.py", line 161, in render_node
self.render_role(
File "/usr/local/lib/python3.8/dist-packages/ansibleplaybookgrapher/renderer.py", line 295, in render_role
role_color = ":".join([c[0] for c in colors])
File "/usr/local/lib/python3.8/dist-packages/ansibleplaybookgrapher/renderer.py", line 295, in <listcomp>
role_color = ":".join([c[0] for c in colors])
TypeError: 'NoneType' object is not subscriptable
Error: Process completed with exit code 1.
Versions:
Outputs of :
ansible --version
ansible-playbook-grapher --version
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)
At this time:
include_tasks
is not representedinclude_tasks
, for example in a block
, are represented as a unique task with multiple edgesNice tool, btw... :-)
Describe the bug
It seems that graphviz has some problems with the generated tree. This is the error message:
Traceback (most recent call last):
File "/home/me/.local/bin/ansible-playbook-grapher", line 10, in <module>
sys.exit(main())
File "/home/me/.local/lib/python2.7/site-packages/ansibleplaybookgrapher/cli.py", line 168, in main
cli.run()
File "/home/me/.local/lib/python2.7/site-packages/ansibleplaybookgrapher/cli.py", line 159, in run
return grapher.post_process_svg()
File "/home/me/.local/lib/python2.7/site-packages/ansibleplaybookgrapher/grapher.py", line 258, in post_process_svg
post_processor.post_process(graph_representation=self.graph_representation)
File "/home/me/.local/lib/python2.7/site-packages/ansibleplaybookgrapher/utils.py", line 196, in post_process
self._insert_graph_representation(graph_representation)
File "/home/me/.local/lib/python2.7/site-packages/ansibleplaybookgrapher/utils.py", line 207, in _insert_graph_representation
element = self.root.xpath("ns:g/*[@id='%s']" % node, namespaces={'ns': SVG_NAMESPACE})[0]
IndexError: list index out of range
To Reproduce
Launching the command to generate a graph~/.local/bin/ansible-playbook-grapher --include-role-tasks -v site.yml
Expected behavior
Get a svg that includes roles' tasks. The command works fine if it is launched without include-role-tasks
Screenshots
If applicable, add screenshots to help explain your problem.
Versions:
ansible-playbook-grapher 0.9.1 (with ansible 2.8.2)
Is your feature request related to a problem? Please describe.
I have a folder with playbooks and roles. Some of the roles are referenced in multiple playbooks. I would like to generate a graph with all playbooks and referenced roles. When two playbooks reference the same role, I want to have only one node for that role, and edges from both playbook nodes that reference it to that node.
Describe alternatives you've considered
for playbook in playbooks/*.yaml
do
ansible-playbook-grapher --save-dot-file $playbook
done
And then manually merge the files. You can use grep roles *.dot | sed -e 's@.*playbooks/roles/\(\S\+\)".*@\1@' | sort | uniq --repeated
to extract a list of roles that are actually referenced in multiple playbooks.
Additional context
In case that's interesting, these are the playbooks/roles that I want to graph: https://github.com/magma/magma/tree/master/experimental/cloudstrapper
Describe the bug
In this new version ansible-playbook-grapher fails with:
Failure with latest: 1.2.0
ansible-playbook-grapher -t task_gather_facts --skip-tags omit_from_grapher -e kubeinit_cluster_distro=okd -e kubeinit_cluster_distro_role=kubeinit_openshift kubeinit/playbook.yml --include-role-tasks -o docs/src/static/playbook_task_gather_facts --save-dot-file
Parsing playbook kubeinit/playbook.yml
Warning: : No inventory was parsed, only implicit localhost is available
Warning: : Looping on tasks or roles are not supported for the moment. Only the
task having the loop argument will be added to the graph.
Warning: : Could not match supplied host pattern, ignoring:
kubeinit_hypervisors
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/ansible/template/__init__.py", line 1160, in do_template
res = j2_concat(rf)
File "<template>", line 12, in root
File "/usr/lib/python3/dist-packages/jinja2/runtime.py", line 639, in _fail_with_undefined_error
raise self._undefined_exception(hint)
jinja2.exceptions.UndefinedError: 'hostvars' is undefined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/ansible-playbook-grapher", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.8/dist-packages/ansibleplaybookgrapher/cli.py", line 269, in main
cli.run()
File "/usr/local/lib/python3.8/dist-packages/ansibleplaybookgrapher/cli.py", line 61, in run
grapher.parse(
File "/usr/local/lib/python3.8/dist-packages/ansibleplaybookgrapher/graphbuilder.py", line 86, in parse
playbook_node = parser.parse()
File "/usr/local/lib/python3.8/dist-packages/ansibleplaybookgrapher/parser.py", line 261, in parse
self._include_tasks_in_blocks(
File "/usr/local/lib/python3.8/dist-packages/ansibleplaybookgrapher/parser.py", line 379, in _include_tasks_in_blocks
block_list, _ = task_or_block.get_block_list(
File "/usr/local/lib/python3.8/dist-packages/ansible/playbook/role_include.py", line 80, in get_block_list
ri = RoleInclude.load(self._role_name, play=myplay, variable_manager=variable_manager, loader=loader, collection_list=self.collections)
File "/usr/local/lib/python3.8/dist-packages/ansible/playbook/role/include.py", line 60, in load
return ri.load_data(data, variable_manager=variable_manager, loader=loader)
File "/usr/local/lib/python3.8/dist-packages/ansible/playbook/base.py", line 269, in load_data
ds = self.preprocess_data(ds)
File "/usr/local/lib/python3.8/dist-packages/ansible/playbook/role/definition.py", line 95, in preprocess_data
(role_name, role_path) = self._load_role_path(role_name)
File "/usr/local/lib/python3.8/dist-packages/ansible/playbook/role/definition.py", line 153, in _load_role_path
role_name = templar.template(role_name)
File "/usr/local/lib/python3.8/dist-packages/ansible/template/__init__.py", line 886, in template
result = self.do_template(
File "/usr/local/lib/python3.8/dist-packages/ansible/template/__init__.py", line 1199, in do_template
raise AnsibleUndefinedVariable(e)
ansible.errors.AnsibleUndefinedVariable: 'hostvars' is undefined
Failure with: 1.1.3
ansible-playbook-grapher -t task_gather_facts --skip-tags omit_from_grapher -e kubeinit_cluster_distro=okd -e kubeinit_cluster_distro_role=kubeinit_openshift kubeinit/playbook.yml --include-role-tasks -o docs/src/static/playbook_task_gather_facts --save-dot-file
Warning: : No inventory was parsed, only implicit localhost is available
Parsing Play: Perform initial setup on ansible-controller host (localhost) (1) ***
Warning: : Looping on tasks or roles are not supported for the moment. Only the
task having the loop argument will be added to the graph.
Done parsing Play: Perform initial setup on ansible-controller host (localhost) (1) ***
Warning: : Could not match supplied host pattern, ignoring:
Parsing Play: Gather facts from the cluster hypervisor hosts (0) ***************
kubeinit_hypervisors
Done parsing Play: Gather facts from the cluster hypervisor hosts (0) **********
Parsing Play: Determine facts needed to prepare all hypervisor hosts (1) *******
Done parsing Play: Determine facts needed to prepare all hypervisor hosts (1) ***
Parsing Play: Prepare the infrastructure to deploy service and cluster nodes (0) ***
Done parsing Play: Prepare the infrastructure to deploy service and cluster nodes (0) ***
Parsing Play: Run the deployment on the target infrastructure (OpenStack/libvirt hypervisors) (1) ***
Done parsing Play: Run the deployment on the target infrastructure (OpenStack/libvirt hypervisors) (1) ***
Traceback (most recent call last):
File "/usr/local/bin/ansible-playbook-grapher", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.8/dist-packages/ansibleplaybookgrapher/cli.py", line 249, in main
cli.run()
File "/usr/local/lib/python3.8/dist-packages/ansibleplaybookgrapher/cli.py", line 71, in run
svg_path = renderer.render(
File "/usr/local/lib/python3.8/dist-packages/ansibleplaybookgrapher/renderer.py", line 114, in render
self._convert_to_graphviz()
File "/usr/local/lib/python3.8/dist-packages/ansibleplaybookgrapher/renderer.py", line 391, in _convert_to_graphviz
self.render_node(
File "/usr/local/lib/python3.8/dist-packages/ansibleplaybookgrapher/renderer.py", line 153, in render_node
self.render_block(
File "/usr/local/lib/python3.8/dist-packages/ansibleplaybookgrapher/renderer.py", line 244, in render_block
self.render_node(
File "/usr/local/lib/python3.8/dist-packages/ansibleplaybookgrapher/renderer.py", line 161, in render_node
self.render_role(
File "/usr/local/lib/python3.8/dist-packages/ansibleplaybookgrapher/renderer.py", line 295, in render_role
role_color = ":".join([c[0] for c in colors])
File "/usr/local/lib/python3.8/dist-packages/ansibleplaybookgrapher/renderer.py", line 295, in <listcomp>
role_color = ":".join([c[0] for c in colors])
TypeError: 'NoneType' object is not subscriptable
Adding a pin works as expected: Kubeinit/kubeinit#702
Do you know what changed that is potentially broken?
Thanks again!
Carlos.
Any playbook using tasks, does not seem to be supported. For example:
- name: My test task
import_tasks: test-tasks.yml
become: true
tags: [never, testing]
Results in:
ansible.errors.AnsibleParserError: 'import_tasks' is not a valid attribute for a Play
Since Inventory Grapher looks abandoned
it would be so amazing to have the same opportunity here.
Thanks for consideration!
Describe the bug
When trying to ask for help it fails while parsing arguments.
ansible-playbook-grapher --help
Traceback (most recent call last):
File "/home/smals-nim/venvs/ansible/bin/ansible-playbook-grapher", line 8, in
sys.exit(main())
File "/home/smals-nim/venvs/ansible/lib/python3.6/site-packages/ansibleplaybookgrapher/cli.py", line 166, in main
cli.parse()
File "/home/smals-nim/venvs/ansible/lib/python3.6/site-packages/ansible/cli/init.py", line 362, in parse
self.init_parser()
File "/home/smals-nim/venvs/ansible/lib/python3.6/site-packages/ansibleplaybookgrapher/cli.py", line 118, in init_parser
_add_my_options(self.parser)
File "/home/smals-nim/venvs/ansible/lib/python3.6/site-packages/ansibleplaybookgrapher/cli.py", line 35, in _add_my_options
parser.add_option('-i', '--inventory', dest='inventory', action="append",
AttributeError: 'ArgumentParser' object has no attribute 'add_option'
Versions:
Outputs of :
ansible --version
: ansible --versionansible-playbook-grapher --version
: doesn't work but pip give me: 0.9.1Additional context
Describe the bug
Include_role does not seem to be detected as a "role" for the graph. A flat execution structure of playbook --> tasks is created despite all of the tasks being included in roles
To Reproduce
write a playbook with include_role
instead of the roles directive.
Expected behavior
I would expect the same mapping of playbook --> role --> tasks as using the role direective
Versions:
Outputs of :
ansible-version: ansible 2.8.5
config file = /etc/ansible/ansible.cfg
configured module search path = ['/Users/cvernooy/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/Cellar/ansible/2.8.5_1/libexec/lib/python3.7/site-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.7.5 (default, Nov 1 2019, 02:16:32) [Clang 11.0.0 (clang-1100.0.33.8)]
ansible-playbook-grapher --version: ansible-playbook-grapher 0.9.1 (with ansible 2.8.4)
It will be quite helpful to visualize "block" directive in playbook.
Describe the bug
When you call sudo ansible-playbook-grapher playbook_with_something_that_includes_collection.yml
and the playbooks uses collections it fails
To Reproduce
sudo ansible-playbook-grapher playbook_with_something_that_includes_collection.yml
Expected behavior
Gerenate the svg file for the playbook
Additional context
Using macOS Big Sur version: 11.2.3
Describe the bug
When you run the ansible-playbook-grapher some_playbook.yml
and the command return a TypeError
To Reproduce
ansible-playbook-grapher some_playbook.yml
Expected behavior
Generate svg file for the playbook
Versions:
Outputs of :
ansible --version
ansible-playbook-grapher --version
ansible-playbook-grapher 0.11.1 (with ansible 2.11.6)
The grapher doesnt work with ansible 2.9.0
To Reproduce
pip install ansible=2.9.0
Hi,
I have few question than can be feature maybe :) :
Thank, br
Is your feature request related to a problem? Please describe.
I use blocks
in almost every part of a play
where a block
is allowed, including pre_tasks
, but it seems that the grapher is unable to handle those, and generates an exception
, making it unusable in most of my complex playbooks :( I wasn't sure if this was a bug, or a feature request, so pardon me if it is the former, and not the latter.
Traceback (most recent call last):
File "/Users/myUserName/.pyenv/versions/venvGraphAnsible/bin/ansible-playbook-grapher", line 8, in <module>
sys.exit(main())
File "/Users/myUserName/.pyenv/versions/3.10.0/envs/venvGraphAnsible/lib/python3.10/site-packages/ansibleplaybookgrapher/cli.py", line 126, in main
cli.run()
File "/Users/myUserName/.pyenv/versions/3.10.0/envs/venvGraphAnsible/lib/python3.10/site-packages/ansibleplaybookgrapher/cli.py", line 43, in run
playbook_node = parser.parse()
File "/Users/myUserName/.pyenv/versions/3.10.0/envs/venvGraphAnsible/lib/python3.10/site-packages/ansibleplaybookgrapher/parser.py", line 154, in parse
self._include_tasks_in_blocks(current_play=play, parent_nodes=[play_node], block=pre_task_block,
File "/Users/myUserName/.pyenv/versions/3.10.0/envs/venvGraphAnsible/lib/python3.10/site-packages/ansibleplaybookgrapher/parser.py", line 245, in _include_tasks_in_blocks
parent_nodes[-1].add_node(f"{node_type}s", EdgeNode(parent_nodes[-1], role_node,
File "/Users/myUserName/.pyenv/versions/3.10.0/envs/venvGraphAnsible/lib/python3.10/site-packages/ansibleplaybookgrapher/graph.py", line 58, in add_node
raise Exception(
Exception: The target composition 'pre_tasks' is unknown. Supported are: ['tasks']
Describe the solution you'd like
The same support as found when using blocks
in tasks
Describe alternatives you've considered
N/A
Additional context
Love the library when I can use it, but on my complex plays
where I use blocks
to keep them clean and apply conditionals on large groups of tasks
, where I would love to see the graph to explain to people what is going on, it is a no go.
When following the setup guide on MacOs 10.14 and Ubuntu 18.04 I get an abstract methods error. I installed on a new Ubuntu 18.04 machine when testing.
Tried with both Python 2.7 and Python 3.6
vagrant@ubuntu-bionic:/vagrant/provisioning$ ansible-playbook-grapher --help
Traceback (most recent call last):
File "/home/vagrant/.local/bin/ansible-playbook-grapher", line 11, in <module>
sys.exit(main())
File "/home/vagrant/.local/lib/python2.7/site-packages/ansibleplaybookgrapher/cli.py", line 85, in main
cli = PlaybookGrapherCLI(args)
TypeError: Can't instantiate abstract class PlaybookGrapherCLI with abstract methods init_parser, post_process_args
Describe the bug
A clear and concise description of what the bug is.
had a playbook with the same description but did different things in the task and thus it mapped to the same task but it was different
To Reproduce
Steps to reproduce the behavior: playbooks example, command line etc...
create playbook with 2 tasks doing different things but the same name.
Expected behavior
A clear and concise description of what you expected to happen.
would produce 2 tasks seprately denoting what actually is being done (a copy of a file, a shell script, etc)
Screenshots
If applicable, add screenshots to help explain your problem.
Versions:
Outputs of :
SC-MKEFFEL-OSX:Collierville_Football_Web mkeffele$ ansible --version ansible 2.8.4 config file = None configured module search path = [u'/Users/mkeffele/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /Library/Python/2.7/site-packages/ansible executable location = /usr/local/bin/ansible python version = 2.7.10 (default, Feb 22 2019, 21:55:15) [GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)]
ansible-playbook-grapher --version
Additional context
Add any other context about the problem here.
ansible-playbook-grapher) (2.21)
Installing collected packages: ansible-core, ansible-playbook-grapher
Attempting uninstall: ansible-core
Found existing installation: ansible-core 2.14.5
Uninstalling ansible-core-2.14.5:
Successfully uninstalled ansible-core-2.14.5
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
ansible 7.5.0 requires ansible-core~=2.14.5, but you have ansible-core 2.12.10 which is incompatible.
Thank you so much!
Can we please upgrade dependencies for this amazing plugin?
https://github.com/haidaraM/ansible-playbook-grapher/blob/master/requirements.txt
Particularly lxml
would be nice, i.e. using latest possible version.
Example: I currently use ansible vmware automation sdk and that installs lxml 4.5. Thus, there is a conflict using this plugin.
I wrote most of the grapher almost three years ago in 2017 and lot of things happened since π
Currently, the Grapher is tightly coupled to the CLI. This makes it difficult to use it as a library inside another project. Also the Grapher
is a little bit complicated: thinking of splitting it. I also want to make the graph customizable by not hardcoding the shapes, layout and make the post processor more extensible.
So this issue is here to track the related changes. The outcome of these changes will be the version v1.0.0 of the grapher?
Describe the bug
Var files are not considered relative to playbook's directory.
To Reproduce
- hosts: foo
vars_files:
- ../vars/vault.yml
ansible-playbook-grapher playbooks/foo.yml
Expected behavior
Works and takes vaults/variables from vars/
Actual behavior
Traceback (most recent call last):
File "/home/x/.local/bin/ansible-playbook-grapher", line 8, in <module>
sys.exit(main())
File "/home/x/.local/lib/python3.7/site-packages/ansibleplaybookgrapher/cli.py", line 188, in main
cli.run()
File "/home/x/.local/lib/python3.7/site-packages/ansibleplaybookgrapher/cli.py", line 175, in run
grapher.make_graph()
File "/home/x/.local/lib/python3.7/site-packages/ansibleplaybookgrapher/grapher.py", line 122, in make_graph
play_vars = self.variable_manager.get_vars(play)
File "/home/x/.local/lib/python3.7/site-packages/ansible/vars/manager.py", line 363, in get_vars
raise AnsibleFileNotFound("vars file %s was not found" % vars_file_item)
ansible.errors.AnsibleFileNotFound: vars file ../vars/vault.yml was not found
Could not find file on the Ansible Controller.
If you are using a module and expect the file to exist on the remote, see the remote_src option
Versions:
Outputs of :
ansible --version
: 2.9.4ansible-playbook-grapher --version
: 0.9.3Describe the bug
When running ansible-playbook-grapher
(without arguments), I get the exception
Traceback (most recent call last):
File "/tmp/tmp.weiU6YpNir/virtualenv/bin/ansible-playbook-grapher", line 33, in <module>
sys.exit(load_entry_point('ansible-playbook-grapher==1.1.1', 'console_scripts', 'ansible-playbook-grapher')())
File "/tmp/tmp.weiU6YpNir/virtualenv/lib/python3.9/site-packages/ansibleplaybookgrapher/cli.py", line 249, in main
cli.run()
File "/tmp/tmp.weiU6YpNir/virtualenv/lib/python3.9/site-packages/ansibleplaybookgrapher/cli.py", line 52, in run
super().run()
File "/tmp/tmp.weiU6YpNir/virtualenv/lib/python3.9/site-packages/ansible/cli/__init__.py", line 109, in run
self.parse()
File "/tmp/tmp.weiU6YpNir/virtualenv/lib/python3.9/site-packages/ansible/cli/__init__.py", line 405, in parse
self.init_parser()
File "/tmp/tmp.weiU6YpNir/virtualenv/lib/python3.9/site-packages/ansibleplaybookgrapher/cli.py", line 188, in init_parser
super().init_parser(
File "/tmp/tmp.weiU6YpNir/virtualenv/lib/python3.9/site-packages/ansible/cli/__init__.py", line 336, in init_parser
self.parser = opt_help.create_base_parser(self.name, usage=usage, desc=desc, epilog=epilog)
AttributeError: 'PlaybookGrapherCLI' object has no attribute 'name'
To Reproduce
workdir="$(mktemp -d)"
echo "Working in $workdir, you have to clean this up manually"
cd "$workdir"
python -m venv virtualenv
source virtualenv/bin/activate
git clone 'https://github.com/haidaraM/ansible-playbook-grapher'
cd ansible-playbook-grapher
pip install -r requirements.txt
pip install .
ansible-playbook-grapher
Versions:
Outputs of :
ansible --version
ansible [core 2.13.1]
config file = None
configured module search path = ['/home/jan/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /tmp/tmp.weiU6YpNir/virtualenv/lib/python3.9/site-packages/ansible
ansible collection location = /home/jan/.ansible/collections:/usr/share/ansible/collections
executable location = /tmp/tmp.weiU6YpNir/virtualenv/bin/ansible
python version = 3.9.13 (main, May 17 2022, 14:19:07) [GCC 11.3.0]
jinja version = 3.1.2
libyaml = True
ansible-playbook-grapher --version
When you hover in an old selected node, all the linked elements are selected even though you hover out.
hello,
I just try this tool but I have some issue on path file.
I have the following file mapping (for sample I have deleted some folder):
βββ 000-initialize-afs.ym
βββ tasks
βββ include_galaxy.yml
βββ loop_tasks
Β Β βββ _galaxy_resolve_role.yml
When I run : ansible-playbook-grapher 000-initialize-afs.yml
I get this error :
Traceback (most recent call last):
File "/usr/local/bin/ansible-playbook-grapher", line 10, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/ansibleplaybookgrapher/cli.py", line 84, in main
cli.run()
File "/usr/local/lib/python2.7/dist-packages/ansibleplaybookgrapher/cli.py", line 32, in run
skip_tags=self.options.skip_tags)
File "/usr/local/lib/python2.7/dist-packages/ansibleplaybookgrapher/grapher.py", line 198, in make_graph
skip_tags=skip_tags)
File "/usr/local/lib/python2.7/dist-packages/ansibleplaybookgrapher/grapher.py", line 292, in _include_tasks_in_blocks
skip_tags=skip_tags)
File "/usr/local/lib/python2.7/dist-packages/ansibleplaybookgrapher/grapher.py", line 276, in _include_tasks_in_blocks
data = self.data_loader.load_from_file(include_file)
File "/usr/local/lib/python2.7/dist-packages/ansible/parsing/dataloader.py", line 88, in load_from_file
(b_file_data, show_content) = self._get_file_contents(file_name)
File "/usr/local/lib/python2.7/dist-packages/ansible/parsing/dataloader.py", line 156, in _get_file_contents
raise AnsibleFileNotFound("Unable to retrieve file contents", file_name=file_name)
ansible.errors.AnsibleFileNotFound: Unable to retrieve file contents
Could not find or access '/home/ubuntu/AFS/142/playbook-athena-foundation-service-core-infrastructure/loop_tasks/_galaxy_resolve_role.yml'
Of course, /home/ubuntu/AFS/142/playbook-athena-foundation-service-core-infrastructure/loop_tasks/_galaxy_resolve_role.yml do not exist. I have this mapping
grep _galaxy 000-initialize-afs.yml
include_tasks: "tasks/include_galaxy.yml"
grep _galaxy tasks/include_galaxy.yml
stat_galaxy_file: none
register: stat_galaxy_file
include_tasks: "loop_tasks/_galaxy_resolve_role.yml"
when: stat_galaxy_file.stat.exists
If I summarize : 000-initialize-afs.yml call tasks/include_galaxy.yml call loop_tasks/_galaxy_resolve_role.yml
Is your feature request related to a problem? Please describe.
It would be great if there would be an opportunity to hide plays(tasks) without any role.
Describe the solution you'd like
Please consider adding a key (for example --hide-tasks-without-roles) to ansible-playbook-grapher to hide plays(tasks) without any role.
By using the CLI class provided by Ansible, we can benefit from features such as :
https://github.com/ansible/ansible/blob/devel/lib/ansible/cli/__init__.py#L99
Describe the bug
With a very large number of plays and tasks, it's almost impossible to read the graph.
To Reproduce
Run the grapher with a large number of plays, tasks, roles with --include-role-tasks
Expected behavior
The GraphvizRenderer
should render a more readable graph.
Versions:
All versions
Additional context
Related to #95 (comment)
I'm looking to document a large playbook and documenting where variables are declared, and where they're used, has been difficult.
I'd like to see an option to map where variables are defined and where in the playbook they're used. More specifically, if I know I've declared variables in <role-name>/meta/main.yml
, I want to tell the grapher to start in <role-name>/meta/main.yml
and map to where they are used within that role (or, in other roles).
Describe the solution you'd like
Currently, I'm releasing manually from my local machine. Ideally, this should be done via Github Actions that generate the release notes and push the package to PyPi.
Is your feature request related to a problem? Please describe.
No
Describe the solution you'd like
It would be nice to be able to generate mermaid instead of SVG/images, so we could embed the output directly into places that support it , like on GitHub.
quick example:
graph TD
A[Thievery] -->|Get money| B(Go shopping)
B --> C{Let me think}
C -->|One| D[Laptop]
C -->|Two| E[iPhone]
C -->|Three| F[fa:fa-car Car]
Is your feature request related to a problem? Please describe.
Sometimes when I try to understand a bunch of ansible playbooks, I want to navigate to the playbook that I am looking in the graph. Currently I do it by doing find tool but its very hectic. It would be much better If I click on the node and it should open the file corresponding to that node.
Describe the solution you'd like
It wouldn't be difficult to implement this feature. Just a hint, you could use: graph.attr("node", URL="file name")
Describe alternatives you've considered
I dont know yet, will update soon if have any
Only the first edge is highlighted. It's related to the id used for the edge.
Using version ^2.0.0 for ansible-playbook-grapher
Updating dependencies
Resolving dependencies... (1.6s)
Because no versions of ansible match >8.0.0,<8.1.0 || >8.1.0,<8.2.0 || >8.2.0,<8.3.0 || >8.3.0,<8.4.0 || >8.4.0,<9.0.0
and ansible (8.0.0) depends on ansible-core (>=2.15.0,<2.16.0), ansible (>=8.0.0,<8.1.0 || >8.1.0,<8.2.0 || >8.2.0,<8.3.0 || >8.3.0,<8.4.0 || >8.4.0,<9.0.0) requires ansible-core (>=2.15.0,<2.16.0).
And because ansible (8.1.0) depends on ansible-core (>=2.15.1,<2.16.0)
and ansible (8.2.0) depends on ansible-core (>=2.15.2,<2.16.0), ansible (>=8.0.0,<8.3.0 || >8.3.0,<8.4.0 || >8.4.0,<9.0.0) requires ansible-core (>=2.15.0,<2.16.0).
And because ansible (8.3.0) depends on ansible-core (>=2.15.3,<2.16.0)
and ansible (8.4.0) depends on ansible-core (>=2.15.4,<2.16.0), ansible (>=8.0.0,<9.0.0) requires ansible-core (>=2.15.0,<2.16.0).
Because no versions of ansible-playbook-grapher match >2.0.0,<3.0.0
and ansible-playbook-grapher (2.0.0) depends on ansible-core (>=2.12,<2.15), ansible-playbook-grapher (>=2.0.0,<3.0.0) requires ansible-core (>=2.12,<2.15).
Thus, ansible-playbook-grapher (>=2.0.0,<3.0.0) is incompatible with ansible (>=8.0.0,<9.0.0).
So, because severaln1nes depends on both ansible (^8.0.0) and ansible-playbook-grapher (^2.0.0), version solving failed.
Describe the bug
When hovering over a node, the node id is displayed instead of it's name
To Reproduce
Graph any playbook and hover over a node.
Expected behavior
The node name should be displayed.
Versions:
Outputs of :
ansible-playbook-grapher --version
: ansible-playbook-grapher 0.10.0 (with ansible 2.9.14)Add the rendered SVG files in PR so that we can easily see if the PR contains a regression or not.
Some tools to consider:
Describe the bug
When graphing a playbook with a task include_role within a loop on role name, ansible_playbook_grapher raise an execption :
To Reproduce
Assuming following playbook content snippet :
- name: 'install docker and python addons'
block:
- include_role:
name: '{{ item }}'
loop:
- certificates
- docker
- python_pip
- python_docker
ansible_playbook_grapher raises an UndefinedError exception stating item
is not defined
Expected behavior
ansible_playbook_grapher runs without exception
Screenshots
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/ansible/template/__init__.py", line 876, in do_template
res = j2_concat(rf)
File "<template>", line 11, in root
File "/usr/lib/python3.6/site-packages/jinja2/runtime.py", line 635, in _fail_with_undefined_error
raise self._undefined_exception(hint)
jinja2.exceptions.UndefinedError: 'item' is undefined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/ansible-playbook-grapher", line 8, in <module>
sys.exit(main())
File "/home/..../.local/lib/python3.6/site-packages/ansibleplaybookgrapher/cli.py", line 188, in main
cli.run()
File "/home/..../.local/lib/python3.6/site-packages/ansibleplaybookgrapher/cli.py", line 175, in run
grapher.make_graph()
File "/home/..../.local/lib/python3.6/site-packages/ansibleplaybookgrapher/grapher.py", line 214, in make_graph
play_vars=play_vars, node_name_prefix="[task] ")
File "/home/..../.local/lib/python3.6/site-packages/ansibleplaybookgrapher/grapher.py", line 311, in _include_tasks_in_blocks
variable_manager=self.variable_manager)
File "/usr/lib/python3.6/site-packages/ansible/playbook/role_include.py", line 76, in get_block_list
ri = RoleInclude.load(self._role_name, play=myplay, variable_manager=variable_manager, loader=loader, collection_list=self.collections)
File "/usr/lib/python3.6/site-packages/ansible/playbook/role/include.py", line 60, in load
return ri.load_data(data, variable_manager=variable_manager, loader=loader)
File "/usr/lib/python3.6/site-packages/ansible/playbook/base.py", line 222, in load_data
ds = self.preprocess_data(ds)
File "/usr/lib/python3.6/site-packages/ansible/playbook/role/definition.py", line 94, in preprocess_data
(role_name, role_path) = self._load_role_path(role_name)
File "/usr/lib/python3.6/site-packages/ansible/playbook/role/definition.py", line 152, in _load_role_path
role_name = templar.template(role_name)
File "/usr/lib/python3.6/site-packages/ansible/template/__init__.py", line 617, in template
disable_lookups=disable_lookups,
File "/usr/lib/python3.6/site-packages/ansible/template/__init__.py", line 910, in do_template
raise AnsibleUndefinedVariable(e)
ansible.errors.AnsibleUndefinedVariable: 'item' is undefined
Versions:
ansible 2.9.14
config file = /home/.../ansible.cfg
configured module search path = ['/home/.../.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.6/site-packages/ansible
executable location = /usr/bin/ansible
python version = 3.6.8 (default, Apr 16 2020, 01:36:27) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
ansible-playbook-grapher 0.10.0 (with ansible 2.9.14)
When running ansible-playbook-grapher --include-role-tasks on a playbook, it would be great if nodes could be collapsable. The graph can become intense and hard to consume.
It would be nice as a debugging tool if we could parse a playbook execution log and for a given host in the inventory, and colourise the tasks in the graph depending on their execution result (successful, skipped, changed, failed).
This could also be used to hide tasks that don't get run.
Suggested args --execution-log, --hostname and --hide-skipped
Hi,
I was testing the ansible-playbook-grapher on an ansible playbooks. From my understanding, the tool is meant to simply graph a playbook and provide you with a graphical overview. However, when attempting to do so, it appeared that the tool attempts to run the playbook first. Is that correct or have I misunderstood the tool's purpose?
I hope you can clarify this confusion of mine.
Thank you in advance!
Hello there,
Trying to install on Windows 10, I have this error on executing : pip install ansible-playbook-grapher :
Collecting ansible-playbook-grapher
Using cached ansible_playbook_grapher-0.10.0-py2.py3-none-any.whl (14 kB)
Collecting lxml==4.5.2
Downloading lxml-4.5.2-cp38-cp38-win32.whl (3.2 MB)
|ββββββββββββββββββββββββββββββββ| 3.2 MB 1.1 MB/s
Collecting ansible>=2.8.0
Using cached ansible-2.10.3.tar.gz (28.0 MB)
ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'C:\Users\________\AppData\Local\Temp\pip-install-gz3e9eul\ansible\ansible_collections/amazon/aws/tests/unit/modules/placebo_recordings/aws_direct_connect_link_aggregation_group/delete_lag_with_connections_without_force_delete/directconnect.DescribeVirtualInterfaces_1.json'
Any idea, thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.