Ansible 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=/tmp/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]#
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!!!
The post Ansible – How to Install and configure AWX ? appeared first on UnixArena.