0

I have a situation where I have the AWX repo cloned into the /tmp/ folder on a remote docker swarm container and I am already using ansible playbooks. What I am trying to do is run the playbook I have already and then run the playbook in the AWX repo I cloned. The problem is I can not find any way to run a playbook remotely. The main suggestion is:

---
- import_playbook: setup-docker-swarm-playbook.yml
- import_playbook: /tmp/awx/installer/install.yml

but this does not work because import_playbook only checks based on the directory you are in so it is not checking the remote for /tmp/awx, but just checking my project I am working in. Additionally, import_playbook does not support any other parameters past the path to the playbook. I have also tried using ansible.builtin.fetch to grab the file remote playbook and copy it to my project, but that doesn't work either because the playbook can not run any of its roles to check the rest of the AWX settings.

Any advice would be appreciated.

Sou1Aced
  • 1
  • 1

1 Answers1

0

Ansible uses an "Ansible Controller" as the machine from which you start your plays. This is normally your local PC or a Linux-VM, where you start the plays via SSH. So the "controller" is talking to the remote machine and runs there the tasks.

AWX itself is just a "replacement" for your local PC or VM. Your playbook repo is checked out there and it nows your inventory. All plays are running inside the AWX.

The problem is - the AWX guys build an Ansible script for install or upgrade the AWX instance. But if you want to use AWX it cannot update itself - during the install process it stops the AWX and so the play would never finish. You have the following options:

  • install Ansible itself on the host where you installed the AWX and use a cron job or make it manually via SSH and call the playbook there. So - you run remote via SSH a playbook that runs on localhost as the Ansible controller and that installs/updates the AWX.

  • the documentation says - you can configure the inventory inside the AWX repo and define your remote instance and paths. So your local PC is the Ansible controller for managing the AWX instance. The installer can run from your system and install/update the remote instance. You only need to change the first line in installer/inventory.

  • third option - it depends on what you installed - I'm using the docker-compose environment. I just run the installer once to generate the docker-compose.yml etc. and copy that to the remote machine. There is also a separate script (runs via cron) that just calls this script. It would be nicer to have a Playbook for that, so the first to options are "better". But at the end - that's all, what the script is actually doing.

My script

docker-compose pull
docker-compose run --rm --service-ports task awx-manage migrate --no-input
docker-compose up -d

In all cases - a selfupdate is not possible with AWX. You need at least a cron job and a different "Ansible controller". even if it is the same machine.

TRW
  • 488
  • 3
  • 16