Closed djdanielsson closed 2 years ago
I am looking into a fix, I tried changing the defaults to tower_ah_url: "https://{{ tower_ah_nodes[0] | default('localhost') }}"
but it didn't seem to work. It works when I put it in my main vars but I thought you might want to avoid that. What do you think?
The obvious solution is to just set the value of tower_ah_url in your playbook. I do, however, like the idea of setting it to be related to tower_ah_nodes, although that might not work in all circumstances (e.g. if you defined some host specific vars under tower_ah_hosts - bit of a hack but can be done).
I'm not entirely sure why your example does not work. When i put together a simple debugging playbook it does seem to:
---
- hosts: localhost
vars:
tower_ah_nodes:
- ahnode.example.com
tasks:
- debug:
msg: "https://{{ tower_ah_nodes[0] | default('localhost') }}"
results in
TASK [debug] *************************************************************************************
ok: [localhost] => {
"msg": "https://ah-node-dc1.example.com"
and setting tower_ah_nodes: []
(as per default) you get
ok: [localhost] => {
"msg": "https://localhost"
}
So seemingly working?
I might not have been clear, it does work when I have it in my vars file with everything else, it does not however work when I modified the defaults file to that instead of directly setting it to localhost. I will test again to confirm that it does not work in defaults or if it was some oversight on my part that caused it to not work when I first tried it.
Ok I figured it out I was being stupid and modified the wrong defaults/main.yml which is why it didn't work for me. But you said you didn't like this as a full on fix?
No, I'm happy for the default to be set as tower_ah_nodes[0]
. For instances where tower_ah_nodes is set as something where this just wouldnt work, the user can just use their own value for tower_ah_url
https://github.com/redhat-cop/tower_utilities/blob/dfe8f4a316f7dfc2fe339f41c42dcc949ec8bbe5/roles/install/tasks/tower_install.yml#L51
install fails because this is trying to hit localhost when checking if AH is up and running and not the host that AH is installed on. This value is set in defaults here https://github.com/redhat-cop/tower_utilities/blob/dfe8f4a316f7dfc2fe339f41c42dcc949ec8bbe5/roles/install/defaults/main.yml#L9