Create new host

Hi,

I am trying create a new host in AWX and assign it to a specific inventory as part of my VM provisioning but I cant seem to get it to work.

Anyone point me in the right direction?

Cheers

Just to add, I am not wanting to use an inventory source, I merely want to create a new host to AWX when the VM is provisioned

Use this?
https://docs.ansible.com/ansible/latest/collections/awx/awx/tower_host_module.html

Hey

Yes I used that tower_host module but I get an error:

msg": “Failed to update host: There was a network error of some kind trying to connect to Tower.\n\nThe most common reason for this is a settings issue; is your "host" value in tower-cli config correct?\nRight now it is: "hostname.domain.com".”}

That sounds like your host in the configuration is not set correctly. Have you tried to authenticate first?

I can add the host manually and everything works fine.

Can you expand on what you mean authenticate first please?

Thank you

When you use tower_host there is an option to put in username and password or config file details. Did you supply that?
https://docs.ansible.com/ansible/latest/collections/awx/awx/tower_host_module.html

yes, here is my playbook

  • name: Add new host to organisations inventory
    delegate_to: localhost
    tower_host:
    name: hostname_to_add
    description: generic description
    inventory: inventory_name
    state: present

tower_username: username
tower_password password

validate_certs: yes

Set the tower host name. You have not supplied that in the playbook.

Where is this parameter tower_host set in your playbook? That’s what it is complaining about.

Cheers, I did have that included but there was a typo, thanks for pointing that out.

All working now!