vultr / ansible-collection-vultr

GNU General Public License v3.0
28 stars 17 forks source link

[BUG] - internal_ip no longer shows up with ansible-inventory --list #86

Closed TheSemicolons closed 1 year ago

TheSemicolons commented 1 year ago

Describe the bug When using ansible-inventory --list, the internal_ip no longer shows up in the instance data.

To Reproduce

  1. Run ansible-inventory --list
  2. Search for "internal_ip"

Expected behavior When an instance is attached to a VPC2.0, the "internal_ip" field should be populated.

Screenshots ansible.cfg:

[default]
collections_paths=/etc/ansible/collections
inventory=/etc/ansible/vultr.yml
[inventory]
enable_plugins=vultr.cloud.vultr

vultr.yml

plugin: vultr.cloud.vultr
api_key: "[redacted]"
compose:
  ansible_host: vultr_v6_main_ip or vultr_main_ip
keyed_groups:
  - key: vultr_tags | lower
    prefix: ''
    separator: ''
strict: true

Desktop (please complete the following information where applicable:

ansible [core 2.13.4]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/etc/ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  ansible collection location = /etc/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.16 (main, Dec 16 2022, 16:48:31) [Clang 13.0.0 ]
  jinja version = 3.1.2
  libyaml = True

Additional context

curl "https://api.vultr.com/v2/instances/[redacted]" -X GET -H "Authorization: Bearer [redacted]" correctly shows the "internal_ip"

resmo commented 1 year ago

@TheSemicolons thanks for reporting, investigating.

resmo commented 1 year ago

@TheSemicolons it seems that internal_ip never worked in this inventory, are you referring to the ngine_io.vultr inventory?

The function was added by PR #87

resmo commented 1 year ago

fixed by #87

TheSemicolons commented 1 year ago

@resmo

I was using https://docs.ansible.com/ansible/latest/collections/vultr/cloud/vultr_inventory.html and assumed that since the attributes parameter linked to https://www.vultr.com/api/#operation/list-instances that all those values were available for the compose parameter.

I was attempting to do:

plugin: vultr.cloud.vultr
api_key: "[redacted]"
compose:
  ansible_host: vultr_internal_ip or vultr_v6_main_ip or vultr_main_ip
keyed_groups:
  - key: vultr_tags | lower
    prefix: ''
    separator: ''
strict: true

So that Ansible would manage instances over the internal_ip instead of the v6_main_ip or main_ip.

resmo commented 1 year ago

Ok, thanks for clarification. I was wondering because you wrote "no longer shows up", but your example should be working with 1.10.0 released few hours ago.

TheSemicolons commented 1 year ago

Yup, working now with 1.10.0. I never used anything before 1.9.0, but since it was part of the API I assumed it worked at one point before.