Vultr inventory on AWX?

I’ve used ansible CLI for some time now, and have made use of the Vultr inventory plugin.

Now I’m getting started with AWX and I’m stuck on inventory. Is there a way to get the Vultr inventory plugin working with AWX? I’m struggling to find documentation on the subject, probably because I don’t know what I don’t know, and I’m not sure what to search for.

It seems like the playbook needs to be set up similarly to running Ansible from the CLI. Just like when using the CLI, I need an ansible.cfg in the root of my SCM project as follows–

[inventory] enable_plugins=vultr

And my inventory which is created in AWX looks as follows–

`

Hi!

I was wondering if you ever had luck with this.

I’m attempting to use vultr as inventory on AWX, and am encountering a staggering number of roadblocks as you did.

Anything you managed to discover would be fantastic :slight_smile:

Yes I figured it out.

Here’s what my ansible.cfg (in the project directory) looks like–

`
Enter code here…[inventory]
enable_plugins=vultr

[ssh_connection]
ssh_common_args=-o IdentitiesOnly=yes

[defaults]
host_key_checking=False
ansible_user=root
remote_user=root
ansible_ssh_common_args="-o IdentitiesOnly=yes"
ansible_ssh_private_key_file=/home/chris/.ssh/chris
`

here’s what my vultr.ini (in the project directory) looks like–

`
[default]
key=<MY_VULTR_API_KEY_GOES_HERE_BUT_I_REMOVED_IT_FOR_THIS_EXAMPLE>

`

Here’s what my vultr.yml file (in the project directory) looks like–

`

Wow, thank you for the fast, thorough answer.

ansible_ssh_private_key_file=/home/chris/.ssh/chris

key=<MY_VULTR_API_KEY_GOES_HERE_BUT_I_REMOVED_IT_FOR_THIS_EXAMPLE>

Would there be an easy way of hiding these keys from the base configs (eg in AWX, creating a vault credential for injecting in temporarily)?
I tend to avoid placing keys in repos, or have them generally viewable by users, but the way the vultr plugin wishes to accept configs is a pain, by not accepting a yaml config.

Just a small workflow-based question.

in linux_spinup.yml do you also use tower_* tasks to place the hosts back into AWX for further provisioning using other jobs?

Shame AWX doesn’t have a proper dynamic inventory for vultr or linode, like it does for AWS or Azure.

I’m not sure about the vultr.ini file as far as hiding the keys from base configs. There might be a different way of doing this. It’s possible you can use a vultr.yml instead, or put vultr.ini in ~/ instead of the project directory. The ansible docs vultr page might have more info on this, or you could browse the source of the vultr plugin to see if there is another way.

I just re-read the docs. Apparently there are four places this config can be stored.

`

  • Environment Variables (eg. VULTR_API_KEY, VULTR_API_TIMEOUT)
  • File specified by environment variable VULTR_API_CONFIG
  • vultr.ini file located in current working directory
  • $HOME/.vultr.ini

`

https://docs.ansible.com/ansible/latest/scenario_guides/guide_vultr.html#usage

I’m not using tower or AWX but my linux_spinup.yml file does add the vultr instance to ansible inventory once it has started.

`

  • name: Add server to ansible inventory
    add_host:
    hostname: “{{ server_hostname }}”
    ansible_host: “{{ server.json.main_ip }}”
    ansible_user: root
    ansible_password: “{{ server.json.default_password }}”
    main_ip: “{{ server.json.main_ip }}”
    subid: “{{ server.json.SUBID }}”
    `

This is helpful because after I run spinup.yml playbook, I usually run a second playbook to provision the newly created server.

`