Ansible AWX is an upstream project of Ansible Tower. To evaluate ansible Tower, you can deploy AWX and check the functionality. AWX deployment is simple if you have an existing docker environment. AWX is an opensource project and the community is offering AWX in the form of container. AWX requires multiple components like a database, Message queue, web services etc. While deploying AWX, the following images will be installed on docker environment.
AWX Components:
- postgres – Database
- rabbitmq – Message Queue
- memcached – General-Purpose Distributed Memory Caching system
- awx_web – This image should be deployed together with ansible/awx_task
- awx_task – This image should be deployed together with ansible/awx_web
Ansible AWX project members ensured that deploying AWX should be very simple like automating other IT deployments. Here are the steps to deploy AWX on Docker environment.
- Setup the docker environment.
- Run the AWX deployment playbook.
Environment:
- CentOS 7
- SELinux Disabled
- Firewall Disabled.
- Internet connection
Deploying AWX :
1. Login to CentOS 7 server where you would like to host AWX.
2. Perform the docker test to ensure docker is functional and verify that system has internet access to pull the required images.
[root@ansible-server awx]# docker run -it hello-world Unable to find image 'hello-world:latest' locally Trying to pull repository docker.io/library/hello-world ... latest: Pulling from docker.io/library/hello-world d1725b59e92d: Pull complete Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788 Status: Downloaded newer image for docker.io/hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.
3. Cloning the AWX repo to your server.
[root@ansible-server tmp]# git clone https://github.com/ansible/awx.git Cloning into 'awx'... remote: Enumerating objects: 152, done. remote: Counting objects: 100% (152/152), done. remote: Compressing objects: 100% (106/106), done. Receiving objects: 0% (900/181415), 460.00 KiB | 94.00 KiB/s
4. Navigate to “awx” directory.
[root@ansible-server tmp]# cd [root@ansible-server ~]# cd awx [root@ansible-server awx]# ls -lrt total 156 -rw-r--r-- 1 root root 2566 Sep 12 19:20 API_STANDARDS.md -rw-r--r-- 1 root root 1620 Sep 12 19:20 DCO_1_1.md -rw-r--r-- 1 root root 2945 Sep 12 19:20 DATA_MIGRATION.md -rw-r--r-- 1 root root 17307 Sep 12 19:20 CONTRIBUTING.md -rw-r--r-- 1 root root 2442 Sep 12 19:20 README.md -rw-r--r-- 1 root root 1055 Sep 12 19:20 MANIFEST.in -rw-r--r-- 1 root root 21027 Sep 12 19:20 Makefile -rw-r--r-- 1 root root 9304 Sep 12 19:20 LICENSE.md -rw-r--r-- 1 root root 5142 Sep 12 19:20 ISSUES.md -rw-r--r-- 1 root root 29033 Sep 12 19:20 INSTALL.md drwxr-xr-x 2 root root 41 Sep 12 19:20 config drwxr-xr-x 14 root root 265 Sep 12 19:20 awx drwxr-xr-x 5 root root 4096 Sep 12 19:20 docs -rw-r--r-- 1 root root 268 Sep 12 19:20 nodemon.json -rwxr-xr-x 1 root root 149 Sep 12 19:20 manage.py -rw-r--r-- 1 root root 473 Sep 12 19:20 pytest.ini -rw-r--r-- 1 root root 870 Sep 12 19:20 shippable.yml -rwxr-xr-x 1 root root 5975 Sep 12 19:20 setup.py -rwxr-xr-x 1 root root 1195 Sep 12 19:20 setup.cfg drwxr-xr-x 2 root root 4096 Sep 12 19:20 requirements -rw-r--r-- 1 root root 1745 Sep 12 19:20 tox.ini drwxr-xr-x 10 root root 277 Sep 12 19:20 tools drwxr-xr-x 2 root root 6 Sep 13 00:21 tmp drwxr-xr-x 3 root root 72 Sep 13 02:59 installer [root@ansible-server awx]#
5. Navigate to installer directory.
[root@ansible-server awx]# cd installer/ [root@ansible-server installer]# ls -lrt total 16 -rw-r--r-- 1 root root 469 Sep 12 19:20 install.yml -rw-r--r-- 1 root root 171 Sep 12 19:20 build.yml drwxr-xr-x 7 root root 99 Sep 12 19:20 roles -rw-r--r-- 1 root root 4940 Sep 13 02:59 inventory [root@ansible-server installer]#
6. Update the “inventory” file like below.
[root@ansible-server installer]# cat inventory |grep -v "#" |sort -nr |grep . secret_key=awxsecret project_data_dir=/var/lib/awx/projects postgres_data_dir=/var/lib/pgdocker pg_username=awx pg_port=5432 pg_password=awxpass pg_database=awx localhost ansible_connection=local ansible_python_interpreter="/usr/bin/env python" host_port=80 dockerhub_version=latest dockerhub_base=ansible docker_compose_dir=/var/lib/awx awx_official=true awx_alternate_dns_servers="4.2.2.1,4.2.2.2" [all:vars] [root@ansible-server installer]#
If you do not specify “project_data_dir=/var/lib/awx/projects” during the deployment, you can’t use Manual SCM. You might face issue while creating the new project.
“WARNING: There are no available playbook directories in /var/lib/awx/projects. Either that directory is empty, or all of the contents are already assigned to other projects. Create a new directory there and make sure the playbook files can be read by the “awx” system user, or have Tower directly retrieve your playbooks from source control using the SCM Type option above.”
Note: “postgres_data_dir” path also very important where the Postgres data will be stored. By default, it has been set to /tmp. In some cases /tmp will be cleaned up across the system reboot.
7. Run the ansible playbook to deploy AWX.
[root@ansible-server installer]# ansible-playbook -i inventory install.yml -vv ansible-playbook 2.6.4 config file = /etc/ansible/ansible.cfg configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/site-packages/ansible executable location = /usr/bin/ansible-playbook python version = 2.7.5 (default, Apr 11 2018, 07:36:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] Using /etc/ansible/ansible.cfg as config file statically imported: /root/awx/installer/roles/local_docker/tasks/set_image.yml statically imported: /root/awx/installer/roles/local_docker/tasks/standalone.yml statically imported: /root/awx/installer/roles/local_docker/tasks/compose.yml PLAYBOOK: install.yml ******************************************************************************************************************************* 1 plays in install.yml PLAY [Build and deploy AWX] ************************************************************************************************************************* META: ran handlers TASK [check_vars : include_tasks] ******************************************************************************************************************* task path: /root/awx/installer/roles/check_vars/tasks/main.yml:3 skipping: [localhost] => {"changed": false, "skip_reason": "Conditional result was False"} TASK [check_vars : include_tasks] ******************************************************************************************************************* task path: /root/awx/installer/roles/check_vars/tasks/main.yml:6 included: /root/awx/installer/roles/check_vars/tasks/check_docker.yml for localhost TASK [check_vars : postgres_data_dir should be defined] ********************************************************************************************* task path: /root/awx/installer/roles/check_vars/tasks/check_docker.yml:3 ok: [localhost] => { "changed": false, "msg": "All assertions passed" } TASK [check_vars : host_port should be defined] ***************************************************************************************************** task path: /root/awx/installer/roles/check_vars/tasks/check_docker.yml:10 ok: [localhost] => { "changed": false, "msg": "All assertions passed" } TASK [image_build : Get Version from checkout if not provided] ************************************************************************************** task path: /root/awx/installer/roles/image_build/tasks/main.yml:2 skipping: [localhost] => {"changed": false, "skip_reason": "Conditional result was False"} TASK [image_build : Set global version if not provided] ********************************************************************************************* task path: /root/awx/installer/roles/image_build/tasks/main.yml:8 skipping: [localhost] => {"changed": false, "skip_reason": "Conditional result was False"} TASK [image_build : Verify awx-logos directory exists for official install] ************************************************************************* task path: /root/awx/installer/roles/image_build/tasks/main.yml:13 skipping: [localhost] => {"changed": false, "skip_reason": "Conditional result was False"} <<<<< Rmeoved lines >>>>>> TASK [local_docker : Create /var/lib/awx directory] ************************************************************************************************* task path: /root/awx/installer/roles/local_docker/tasks/compose.yml:2 skipping: [localhost] => {"changed": false, "skip_reason": "Conditional result was False"} TASK [local_docker : Create docker-compose.yml file] ************************************************************************************************ task path: /root/awx/installer/roles/local_docker/tasks/compose.yml:7 skipping: [localhost] => {"changed": false, "skip_reason": "Conditional result was False"} TASK [local_docker : Start the containers] ********************************************************************************************************** task path: /root/awx/installer/roles/local_docker/tasks/compose.yml:12 skipping: [localhost] => {"changed": false, "skip_reason": "Conditional result was False"} META: ran handlers META: ran handlers PLAY RECAP ****************************************************************************************************************************************** localhost : ok=12 changed=5 unreachable=0 failed=0 [root@ansible-server installer]#
8. Look for the new docker instances. We could see that playbook has deployed 5 docker images for AWX.
[root@ansible-server installer]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3613f7e35b9e ansible/awx_task:latest "/tini -- /bin/sh ..." About a minute ago Up About a minute 8052/tcp awx_task 1667ba7d1d55 ansible/awx_web:latest "/tini -- /bin/sh ..." About a minute ago Up About a minute 0.0.0.0:80->8052/tcp awx_web f55cf8f3f45d memcached:alpine "docker-entrypoint..." About a minute ago Up About a minute 11211/tcp memcached b6d3238433b8 ansible/awx_rabbitmq:3.7.4 "docker-entrypoint..." About a minute ago Up About a minute 4369/tcp, 5671-5672/tcp, 15671-15672/tcp, 25672/tcp rabbitmq 706f9be8f572 postgres:9.6 "docker-entrypoint..." About a minute ago Up About a minute 5432/tcp postgres [root@ansible-server installer]#
9. Open the browser and access the server IP. Here, my host IP is ‘192.168.3.151’
[root@ansible-server ~]# ip a |grep inet |egrep -v "inet6|127.0.0.1" inet 192.168.3.151/24 brd 192.168.3.255 scope global noprefixroute ens32 [root@ansible-server ~]#
AWX – Home Page
10. Login with AWX’s default credential ( admin/ password )
We have successfully deployed AWX. What’s Next? Start creating the playbook and integrate with AWX to start automating the environment.
Hope this article is informative to you. Share it! Comment it!! Be Sociable!!!
Erast Fondorin says
Is there a way to mount a volume during the deployment?
I would like to save my config backups somewhere outside of docker for backup
Vibin says
Can we have a similar documentation for installing/configuring AWX Cluster.
I’m trying the same but facing issues and coudn’t get help online.
Regards,
Vibin
MOHAMMED GAFFAR says
Hi ,
How to install AWX on CentOS 7.x / Ubuntu 18.04 LTS without docker. And how to route AWX logs to ELK stack for analysis? Could you please give me the tutorial links for the same?
Thanks,
Gaffar
MOHAMMED GAFFAR says
Hi ,
Is it possible to install AWX on CentOS 7.x and Ubuntu 18.04 LTS without docker,docker compose. If so, then please give me the tutorial link. What are the steps to send AWX logs to ELK stack? Please give tutorial link for the same.
Thanks,
Gaffar, India
MOHAMMED GAFFAR says
Hi ,
Ansible AWX can handle bare metal server, VMWare VMs and Cloud VMs? Max. how many servers it can handle. Is there any other powerful open source tool equivalent of Ansibe AWX? I am having docker installed on Open Stack Nova cloud VM Ubuntu 18.04 LTS server. Is it ok to install and use Ansible AWX on this cloud VM?
Thanks,
Gaffar
Vibin says
Creating awx_web container fails. Any idea ??
TASK [local_docker : Start the containers] **************************************************************************************************************************************************************************************************
task path: /root/awx/installer/roles/local_docker/tasks/compose.yml:25
fatal: [localhost]: FAILED! => {“changed”: false, “errors”: [], “module_stderr”: “Creating awx_memcached … \r\nCreating awx_rabbitmq … \r\nCreating awx_postgres … \r\n\r\u001b[2BCreating awx_web … \r\n\r\u001b[1B”, “module_stdout”: “”, “msg”: “Error starting project unknown cause”}
to retry, use: –limit @/root/awx/installer/install.retry
PLAY RECAP **********************************************************************************************************************************************************************************************************************************
localhost : ok=8 changed=0 unreachable=0 failed=1
Lingeswaran R says
When you have such errors, it’s better to wipe out all the containers and re-deploy using playbook.
Lingesh
Nameless says
Best AWX setup in details on google so far. I dont find better yet.
Thanks
telecodani says
You’re welcome.
https://github.com/telecodani/awx
Lingeswaran R says
Have you installed docker on the host? Docker service is up & running? Please check it.
Thank you
UnixArena Team
Tony says
ansible-playbook -i inventory install.yml is failing at TASK [local_docker : Start the containers]
Any idea ?
Lingeswaran R says
Have you installed docker on the host? Docker service is up & running? Please check it.
Thank you
UnixArena Team
Tony says
Yes, Docker is installed and running
installer]# systemctl status docker
● docker.service – Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2019-04-10 10:21:43 CDT; 50min ago
Docs: https://docs.docker.com
Main PID: 3412 (dockerd)
Tasks: 11
Memory: 35.1M
CGroup: /system.slice/docker.service
└─3412 /usr/bin/dockerd -H fd:// –containerd=/run/containerd/containerd.sock
Lingeswaran R says
You could try to deploy some test container and validate it. Ansible playbooks also try to do the same.
Thank you
Lingesh