Closed RickWinters closed 3 months ago
Thanks for the bug report, are you able to run the following playbook under ansibug
and share the results
- hosts: localhost
gather_facts: false
tasks:
- debug:
var: lookup("config", "COLLECTIONS_PATHS")
It should contain the site-packages/ansibug
location but also the ~/.ansible/collections
dir which is where your collection is.
I have done as you asked and the result does not show the ~/.ansible/collections path. The ansibug launch configuration is on the right, pointing to the playbook. The result is the following:
/usr/bin/env /tmp/ansibug-launch-vcmkiivj /home/[user]/repo/Ansible/playbooks/test.yml -i inventories/netbox --vault-password-file /home/rick/repo/vaultkeys/DevelopmentVaultKey.txt
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
[WARNING]: No setting was provided for required configuration plugin_type: cache plugin: jsonfile setting: _uri
PLAY [Test config collections] ********************************************************************************************************************************************************************************
TASK [debug collections_paths] ********************************************************************************************************************************************************************************
ok: [localhost] =>
lookup("config", "COLLECTIONS_PATHS"):
- /home/rick/.local/lib/python3.10/site-packages/ansibug
PLAY RECAP ****************************************************************************************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
I'll see if i can try adding the ansibug path to my collections_path in ansible.cfg and have ansibug config use that file. Would that work?
Ah I see the problem, the code is calling ansible-config dump --only-changed
before setting the ANSIBLE_COLLECTIONS_PATH
env var when spawning Ansible.
If you haven't change the existing value in any case it's not going to be present in the output so the only entry is the one where ansibug
is located. I'll have to update the code to actually get the default value rather than when it's only changed.
A workaround should be explicitly setting the env var ANSIBLE_COLLECTIONS_PATH
or collection_paths
in the ansible.cfg
as you mentioned. This should work because now the value will appear in the --only-changed
output.
Ah thanks! I was in a meeting waiting to respond but i see a PR is already made. I'm looking forward to the release and i'll let you know if it works! Can i respond to this issue iven if its already closed?
Or can i download and install the build of this PR manually? i wouldn't know how though.
You can download the sdist and wheel from the run artifact
https://github.com/jborean93/ansibug/actions/runs/9953464646/artifacts/1705333343. You can pip install ansibug-0.1.2-py3-none-any.whl
the wheel directly and try again. Otherwise you can clone the branch and install it with pip install ~/path/to/ansibug-checkout
.
You can definitely respond to the issue once closed. If it's for an unrelated problem best to open a new issue though :)
Thanks! I'll try that later today when i have time and report back to you if it works or not! Thank you for responding and fixing (hopefully) the issue this quickly.
You're welcome, thanks for trying this out and reporting the issue. Great to have people test out scenarios I forget to try out :)
It works! This shows the ansible collections paths i'd expect :) And i can run playbooks and roles that include custom made collections present in /home/user/.ansible/collections paths :)
Now i'd be nice to step into the python code of a module and debug that. But i'd doubt thats a scope of this project. Thanks again and i'll happily use this project from now on
Now i'd be nice to step into the python code of a module and debug that
My dream would be to do that and for PowerShell modules but yea that's a lot harder to pull off :)
Thanks for testing the changes and letting me know it works.
0.1.2 has been published to PyPI which includes this fix https://pypi.org/project/ansibug/0.1.2/
Hello.
Using Ansibug in vscode to debug my ansible code i cant use my own ansible collections. Running the following command
cd /home/user/repo/Ansible ; /usr/bin/env /tmp/ansibug-launch-rwvs9jkh playbooks/netbox/assign_extra_phone_number_to_vm.yml -i inventories/netbox --vault-password-file /home/user/repo/vaultkeys/DevelopmentVaultKey.txt -e vm_name=Ansible-TestVM\ sbc_auth_password=testpassword
results in the error shown below. As you can see the collection is install in /home/user/.ansible/collections/ansible_collections.As soon as an ansible task file is included that contains a task using any of my modules in the collection [companyname].netbox it crashes like this.
Can you help me?