3

Standard CLI Ansible looks for the group_vars and host_vars directory in the same location as the host file. See for example How can I change the path of group_vars and host_vars?.

Ansible AWX / Tower has the option of using an "external source" for inventory. When I add the URL of my Git repo I can select the host file or root.

I tried a configuration with a host file in the root and a configuration with the host file in a sub directory. With both options the directories group_vars and host_vars are ignored as far as I can tell.

The documentation is a bit vague on the issue.

Keeping variable data along with the objects in Tower (see the inventory editor) is encouraged, rather than using group_vars/ and host_vars/. If you use dynamic inventory sources, Tower can sync such variables with the database as long as the Overwrite Variables option is not set. 26. Best Practices — Ansible Tower User Guide v3.7.0

Can Tower / AWX sync those variables? Variables in group_vars and / or host_vars? Or is this sync ability limited to the host file?

If it is possible, how should this work?

It seems that Ansible AWX / Tower is a one way street. If you want to use AWX you have to migrate the group_vars and host_vars directories to AWX / Tower and after that there is no way back?

An Ansible project can work with standard CLI Ansible or AWX / Tower - not both!?

onknows
  • 6,151
  • 12
  • 65
  • 109

1 Answers1

2

If you are using a static inventory file within your GitHub repo (in the root folder or a sub-folder), you can place vars within this file. In my experience, this is the way I had to go in order to get TOWER to "see" these vars (does not appear to read the separate "vars" folders as you pointed out).

I setup a TOWER PROJECT as I normally would, sync. Then, I setup an INVENTORY within TOWER, and define my GitHub repo based inventory file under SOURCE, and sync the SOURCE.

This will result in the host_vars & group_vars being sync'ed over, and tied to the hosts & groups created on TOWER (from your defined INVENTORY.)

EG:

[ans-poc-tower]
towernode.fqdn https_port=443

[ans-poc-tower:vars]
role=TOWER
loc=RemoteDC

Reference: adding-variables-to-inventory

inversecow
  • 33
  • 7