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

Fix community.libvirt.libvirt inventory plugin #73

Merged
merged 1 commit into from
Jul 20, 2021

Conversation

L3n41c
Copy link
Contributor

@L3n41c L3n41c commented Jun 9, 2021

SUMMARY

Fix the community.libvirt.libvirt inventory plugin with the latest version of Ansible.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME
  • community.libvirt.libvirt inventory plugin
ADDITIONAL INFORMATION

I have an Ansible playbook that targets a libvirt VM.
Concretely, I have this in my $ANSIBLE_CONFIG file:

[defaults]
inventory = inventory-libvirt.yaml

[inventory]
enable_plugins = community.libvirt.libvirt

And my inventory-libvirt.yaml file contains:

plugin: community.libvirt.libvirt
uri: 'qemu:///system'

This setup used to work but is now broken with this version:

$ ansible --version
ansible [core 2.11.1] 

$ ansible-galaxy collection list | grep libvirt
community.libvirt             1.0.1  

I know get the following error:

$ ANSIBLE_CONFIG=ansible-libvirt.cfg ansible-playbook -C -D archlinux-vm.yml 
[WARNING]:  * Failed to parse /home/lenaic/doc/devel/perso/lenaic_config/inventory-libvirt.yaml with
ansible_collections.community.libvirt.plugins.inventory.libvirt plugin: Invalid value
"community.libvirt.libvirt" for configuration option "plugin_type: inventory plugin:
ansible_collections.community.libvirt.plugins.inventory.libvirt setting: plugin ", valid values are:
['libvirt']
[WARNING]: Unable to parse /home/lenaic/doc/devel/perso/lenaic_config/inventory-libvirt.yaml as an inventory
source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does
not match 'all'
[WARNING]: Could not match supplied host pattern, ignoring: archlinux-vm

PLAY [archlinux-vm] ******************************************************************************************
skipping: no hosts matched

Replacing the plugin value by the suggested value in my inventory-libvirt.cfg file like this:

--- a/inventory-libvirt.yaml
+++ b/inventory-libvirt.yaml
@@ -1,2 +1,2 @@
-plugin: community.libvirt.libvirt
+plugin: libvirt
 uri: 'qemu:///system'

didn’t help.

With this new version, I get this error:

$ ANSIBLE_CONFIG=ansible-libvirt.cfg ansible-playbook -C -D archlinux-vm.yml 
[WARNING]:  * Failed to parse /home/lenaic/doc/devel/perso/lenaic_config/inventory-libvirt.yaml with
ansible_collections.community.libvirt.plugins.inventory.libvirt plugin: Incorrect plugin name in file:
libvirt
[WARNING]: Unable to parse /home/lenaic/doc/devel/perso/lenaic_config/inventory-libvirt.yaml as an inventory
source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does
not match 'all'
[WARNING]: Could not match supplied host pattern, ignoring: archlinux-vm

PLAY [archlinux-vm] ******************************************************************************************
skipping: no hosts matched

This PR fixes this issue.
With this change, my playbook works again.

@Andersson007
Copy link
Contributor

@L3n41c hi, thanks for the PR! Could you please add a changelog fragment https://docs.ansible.com/ansible/latest/community/development_process.html#creating-a-changelog-fragment ?

After that we can merge the PR, thanks!

@L3n41c L3n41c force-pushed the fix_libvirt_inventory branch from cbf462b to df1dd80 Compare July 19, 2021 20:25
@L3n41c
Copy link
Contributor Author

L3n41c commented Jul 19, 2021

Hi @Andersson007,
Thanks for your review. I’ve just added a changelog fragment.

Copy link
Contributor

@Andersson007 Andersson007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Andersson007 Andersson007 merged commit 77a28b5 into ansible-collections:main Jul 20, 2021
@Andersson007
Copy link
Contributor

@L3n41c thanks for the contribution!

@Andersson007 Andersson007 mentioned this pull request Jul 20, 2021
@Andersson007
Copy link
Contributor

Ah, i think we should keep both the options #79

@Andersson007
Copy link
Contributor

@L3n41c FYI i've just release community.libvirt 1.0.2 which contains only your fix, thanks!

@Andersson007
Copy link
Contributor

you can install it manually using instructions from README

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants