# Setup Ansible AWX
###### tags: `ansible` `awx`
A quick step to setup Ansible AWX in Docker containers for testing/research.
OS: Ubuntu22.04
Ansible: core 2.12.6
Python: 3.10.6
This Ansible AWX setup runs with "redis" (6379), "postgres database" (port 5432) and "awx" (port 3000, 2222, 6899, 7899-7999, 8013, 8043 and 8080).
#### Install Steps
##### 1. Git clone latest stable tag
```
$ git clone -b 21.14.0 https://github.com/ansible/awx.git
$ cd awx
```
##### 2. Configure inventory to fit your need (optional)
```
$ vim tools/docker-compose/inventory
```
##### 3. Build development image
build awx base container image
```
$ make docker-compose-build
... output omit
------
> importing cache manifest from ghcr.io/ansible/awx_devel:HEAD:
------
```
check image
```
$ docker images | grep awx
ghcr.io/ansible/awx_devel HEAD 0ecbd693fcde 52 seconds ago 1.76GB
```
##### 4. Download receptor image (optional, not pretty sure this step yet. need research...)
```
$ docker pull quay.io/ansible/receptor:devel
$ docker images quay.io/ansible/receptor:devel
REPOSITORY TAG IMAGE ID CREATED SIZE
quay.io/ansible/receptor devel e8476b04397e 19 hours ago 240MB
```
Export RECEPTOR_IMAGE
```
$ export RECEPTOR_IMAGE=quay.io/ansible/receptor:devel
```
##### 5. Start Ansible AWX, Ansible Receptor, PostgreSQL and Redis containers
Run command with "COMPOSE_UP_OPTS=-d" for detachd mode.
```
$ make docker-compose COMPOSE_UP_OPTS=-d
```
Clean and build the UI
```
$ docker exec tools_awx_1 make clean-ui ui-devel
rm -rf node_modules
rm -rf awx/ui/node_modules
rm -rf awx/ui/build
rm -rf awx/ui/src/locales/_build
rm -rf awx/ui/.ui-built
mkdir -p awx/ui/build/static
NODE_OPTIONS=--max-old-space-size=6144 npm --prefix awx/ui --loglevel warn --force ci
npm WARN using --force Recommended protections disabled.
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
added 1897 packages, and audited 1898 packages in 43s
... output omit
Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.
File sizes after gzip:
898.26 kB build/static/js/main.9996ba55.js
98.63 kB build/static/css/main.6b8c437e.css
61.87 kB build/static/js/489.3819ec1a.chunk.js
48.76 kB build/static/js/118.95d6fd59.chunk.js
45.7 kB build/static/js/138.b38e12c9.chunk.js
44.34 kB build/static/js/787.f176f441.chunk.js
44.07 kB build/static/js/896.e61dac86.chunk.js
43.21 kB build/static/js/11.02c5663e.chunk.js
42.29 kB build/static/js/418.5971f1ef.chunk.js
30.72 kB build/static/js/311.86ad5143.chunk.js
386 B build/static/js/979.f16bcc0c.chunk.js
The bundle size is significantly larger than recommended.
Consider reducing it with code splitting: https://goo.gl/9VhYWB
You can also analyze the project dependencies: https://goo.gl/LeUzfb
The project was built assuming it is hosted at ./.
You can control this with the homepage field in your package.json.
The build folder is ready to be deployed.
Find out more about deployment here:
https://cra.link/deployment
touch awx/ui/.ui-built
make[1]: Leaving directory '/awx_devel'
```
Docker containers
```
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
dd4a4fe27116 ghcr.io/ansible/awx_devel:HEAD "/entrypoint.sh laun…" 27 minutes ago Up 27 minutes 0.0.0.0:2222->2222/tcp, 0.0.0.0:6899->6899/tcp, 0.0.0.0:7899-7999->7899-7999/tcp, 0.0.0.0:8013->8013/tcp, 0.0.0.0:8043->8043/tcp, 0.0.0.0:8080->8080/tcp, 22/tcp, 0.0.0.0:8888->8888/tcp, 0.0.0.0:3000->3001/tcp tools_awx_1
371b90fb8bfe postgres:12 "docker-entrypoint.s…" 27 minutes ago Up 27 minutes 5432/tcp tools_postgres_1
9a15f697975a redis:latest "redis-server /usr/l…" 27 minutes ago Up 27 minutes 6379/tcp tools_redis_1
```
##### 6. Open Web UI
Open Web UI page

Create a admin user
```
$ docker exec -ti tools_awx_1 awx-manage createsuperuser
Username (leave blank to use 'awx'):
Email address: thisisyujungcheng@gmail.com
Password:
Password (again):
Superuser created successfully.
```
Login with admin user

##### 7. Load demo data (optional)
```
$ docker exec tools_awx_1 awx-manage create_preload_data
(changed: False)
```
#### Bug
```
https://github.com/ansible/awx/issues/13135
```
#### Reference
```
https://www.ansiblepilot.com/articles/run-the-latest-ansible-awx-in-docker-containers/
https://github.com/ansible/awx/blob/21.14.0/tools/docker-compose/README.md
https://en.euro-linux.com/docs/ansible-awx.php?p=ansible_runner_integration
https://medium.com/@wintonjkt/ansible-tower-architecture-installation-features-740518e1b577
https://chusiang.github.io/ansible-docs-translate/intro.html
https://docs.ansible.com/ansible-tower/
https://tower-cli.readthedocs.io/en/latest/index.html
```