AWX cannot access its own REST API (Name or service not known)

79 views
Skip to first unread message

RedCrick

unread,
Mar 22, 2023, 2:57:34 PM3/22/23
to AWX Project

I am running awx-operator on a k3 cluster. I have a role, update_host_group, that tries to use the AWX REST API to manipulate Ansible groups.


---
- name: Update Ansible Tower inventory
  uri:
    url: https://awx.example.com/api/v2/groups/36/hosts
    user: "{{ admin_username }}"
    password: "{{ admin_password }}"
    method: 'POST'
    body: '{ "name" : "{{ update_ati_fqdn }}" }'
    force_basic_auth: yes
    status_code: 201
    body_format: json
    validate_certs: no

I created an inventory named "AWX Meta Inventory" which has just one host, localhost. I also created a job template: "Run Update Host Group Playbook" that executes a playbook that uses the role, update_host_group. When I launch this template I get this error:

TASK [update_host_group : Update Ansible Tower inventory] ********************** fatal: [localhost]: FAILED! => {"changed": false, "elapsed": 0, "msg": "Status code was -1 and not [201]: Request failed: <urlopen error [Errno -2] Name or service not known>", "redirected": false, "status": -1, "url": "https://awx.example.com"}

Note: Obvisouly don't actually use example.com. I use my real domain name.


Can someone help me out?  Thanks!


RedCrick

unread,
Mar 22, 2023, 9:14:29 PM3/22/23
to AWX Project

UPDATE: I have tried adding hostAliases to my kubernetes but I am not well versed in k* admin. I looked at the docs here: https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/

But of course that doesn't tell where in the awx deployment to add the hostAliases stanza. So I am just guessing and breaking things. Does anyone know where I need to put my hostAliases?

kurokobo

unread,
Mar 23, 2023, 3:29:12 AM3/23/23
to awx-p...@googlegroups.com
Hi,

Adding new record on your upstream DNS server is the best solution,
but if this is difficult for you, you can define new Container Group with customized pod specification and use it for your Job Template.

Regards,

--
@kurokobo

------- Original Message -------

On Thursday, March 23rd, 2023 at 10:14 AM, RedCrick <russell...@gmail.com> wrote:

UPDATE: I have tried adding hostAliases to my kubernetes but I am not well versed in k* admin. I looked at the docs here: https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/

But of course that doesn't tell where in the awx deployment to add the hostAliases stanza. So I am just guessing and breaking things. Does anyone know where I need to put my hostAliases?

--
You received this message because you are subscribed to the Google Groups "AWX Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to awx-project...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/awx-project/27b03440-97d3-4e82-a93b-639c6b69f280n%40googlegroups.com.

RedCrick

unread,
Mar 23, 2023, 10:26:07 PM3/23/23
to AWX Project
Thank you for your response.  I didn't get a chance to test it out yet but that bit of documentation does seem relevant.  It is inserting though that I do have up stream DNS records but I do not think the container that is doing to gethostbyname() has a resolver in the /etc/resolv.conf that doesn't know about my hostname. 

RedCrick

unread,
Mar 24, 2023, 11:40:57 AM3/24/23
to AWX Project
Thank you kurokobo! That did the trick!  I logged on to my awx web ui and navigated to Administration > Instance Groups, then edited the default instance group and clicked on the Customize pod specification radio button and added these line just above the `containers:` line:

hostAliases:
  - hostnames:
    ip: 10.0.3.52

On Thursday, March 23, 2023 at 12:29:12 AM UTC-7 kuro...@protonmail.com wrote:
Reply all
Reply to author
Forward
0 new messages