Home / How To / How to install Ansible AWX on CentOS 8

How to install Ansible AWX on CentOS 8



AWX stands for "Ansible Web eXecutable" is a free and open source project that allows you to easily manage and control your Ansible project. It provides a web-based user interface and a task engine built on top of Ansible. It provides a powerful REST API and lets you manage or synchronize inventory with other cloud sources, control access and integrate with LDAP.

In this tutorial we will show you how to install Ansible AWX with Docker on CentOS 8. [19659003] Prerequisites

  • A server running CentOS 8 with at least 4 GB of RAM.
  • A root password is configured on your server.

Getting Started

Before you start, you must install the EPEL archive on your system. You can install it with the following command:

  dnf install epel-release -y 

Then you need to install some additional packages required to run AWX on your system. You can install all with the following command:

  dnf install git gcc gcc-c ++ ansible nodejs gettext device-mapper-persistent-data lvm2 bzip2 python3-pip-y 

Once all packages are installed, you can proceed to the next step.

Installing Docker and Docker Compose

Next, you must install Docker to run AWX inside the Docker container. By default, the latest version of Docker is not available in the CentOS 8 standard repository. So you need to add the Docker archive to your system. You can add the Docker repository with the following command:

  dnf config-manager --add-repo = https: //download.docker.com/linux/centos/docker-ce.repo 

After adding to, install the latest stable version of Docker with the following command:

  dnf install docker-ce-3: 1
8.09.1-3.el7-y

Once Docker is installed, check the installed version of Docker with the following command :

  docker - version 

You should get the following output:

  Docker version 19.03.7, build 7141c199a2

Then start the Docker service and enable it to start after system startup with the following command:

  systemctl start docker 
systemctl enable docker

You can verify the status of the Docker service with the following command:

  systemctl status docker 

You should get the following output:

? docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor setting: disabled)
Active: active (running) since Wed 2020-03-11 02:36:04 EDT; 23 mins ago
Document: https://docs.docker.com
Main PID: 5882 (docked)
Tasks: 101
Memory: 2.6 G
CGroup: /system.slice/docker.service
?? 5882 / usr / bin / dockerd -H fd: //
?? 5899 containererd --config /var/run/docker/containerd/containerd.toml - log information
?? 8815 container-shim -namespace moby -workdir /var/lib/docker/containerd/daemon/io.containerd.runtime.v1.linux/moby/4b91575d64b1b>
?? 8847 container-shim -namespace moby -workdir /var/lib/docker/containerd/daemon/io.containerd.runtime.v1.linux/moby/0f36c9784f748>
?? 8894 / usr / bin / docker-proxy -prot tcp -host-ip 0.0.0.0 -host-port 80-container-ip 172.18.0.5-container-port 8052
?? 8899 container-shim -namespace moby -workdir /var/lib/docker/containerd/daemon/io.containerd.runtime.v1.linux/moby/47300ec1c26ff>
?? 8923 container-shim -namespace moby -workdir /var/lib/docker/containerd/daemon/io.containerd.runtime.v1.linux/moby/9827b9831fa5b>
?? 9631 container-shim -namespace moby -workdir /var/lib/docker/containerd/daemon/io.containerd.runtime.v1.linux/moby/166b153faa275>

Then install the Docker composition with the following command:

  pip3 install docker-compose 

After the installation is installed, verify the Docker composition version with the following command:

  docker-compose - version 

see the following output:

  docker-compose version 1.25.4, build unknown

Finally run the following command to set python command to use python 3:

  options - set python / usr / bin / python3 

Install Ansible AWX

Download the latest version of Ansible first AWX from the Git Hub layer with the following command:

  git clone https://github.com/ansible/awx.git tu 19199009009. Next, generate a secret key for encrypting the inventory file with the following command: [19659008] openssl rand -base64 30 

You should get the following output:

  R + kbcDEUS8DlAftAbfWafVqLZ0lUy + Paqo4fEtgp

Note: Remember the above secret, you must paste it into the inventory file.

Then change the directory to awx / install / and edit the inventory file:

  cd awx / installer / 
nano-inventory

Change the following lines:

  [all:vars]
dockerhub_base = ansible
awx_task_hostname = AWX
awx_web_hostname = awxweb
postgres_data_dir = "/ var / lib / pgdocker"
host_port = 80
host_port_ssl = 443
docker_compose_dir = "~ / .awx / awxcompose"
pg_username = AWX
pg_password = awxpass
pg_database = AWX
pg_port = 5432
pg_admin_password = password
rabbitmq_password = awxpass
rabbitmq_erlang_cookie = Cookie
admin_user = admin
admin_password = password
create_preload_data = True
secret_key = R + kbcDEUS8DlAftAbfWafVqLZ0lUy + Paqo4fEtgp
awx_official = true
awx_alternate_dns_servers = "8.8.8.8,8.8.4.4"
project_data_dir = / var / lib / AWX / project

Save and close the file when you are done. Then create a directory for Postgres:

  mkdir / var / lib / pgdocker 

Finally, run the following command to install AWX:

  ansible-playbook-i inventore install.yml 

Once the installation has been successfully completed , you should get the following output:

  skip: [localhost]

Assignment [local_docker : Load web image] ********************************************** * ************************************************* * **********
skips: [localhost]

Assignment [local_docker : Load task image] ********************************************** * ************************************************* * *********
skips: [localhost]

Assignment [local_docker : Set full image path for local install] ********************************************** * *************************************
skips: [localhost]

Assignment [local_docker : Set DockerHub Image Paths] ********************************************** * *************************************************
ok: [localhost]

Assignment [local_docker : Create ~/.awx/awxcompose directory] ********************************************** * ****************************************
amended: [localhost]

Assignment [local_docker : Create Docker Compose Configuration] ********************************************** * ***************************************
changed: [localhost] => (article = environment.sh)
changed: [localhost] => (article = references.py)
changed: [localhost] => (item = docker-compose.yml)
changed: [localhost] => (article = nginx.conf)

Assignment [local_docker : Render SECRET_KEY file] ********************************************** * ************************************************* * **
amended: [localhost]

Assignment [local_docker : Start the containers] ********************************************** * ************************************************* * ****
amended: [localhost]

Assignment [local_docker : Update CA trust in awx_web container] ********************************************** ** **************************************
amended: [localhost]

Assignment [local_docker : Update CA trust in awx_task container] ********************************************** ** *************************************
amended: [localhost]

PLAY RECAP ************************************************ ** ************************************************ ** **********************************
localhost: ok = 14 changed = 6 cannot be reached = 0 failed = 0 jumped = 95 saved = 0 ignored = 0

The above command creates and launches all necessary Docker containers for AWX. You can verify the running containers with the following command:

  docker ps 

You should see the following output:

  CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4b91575d64b1 ansible / awx_task: 9.2.0 "/ tini - / bin / sh -c ..." One minute ago Up In one minute 8052 / tcp awx_task
9827b9831fa5 ansible / awx_web: 9.2.0 "/ tini - / bin / sh -c ..." One minute ago Up About one minute 0.0.0.0:80->8052/tcp awx_web
47300ec1c26f postgres: 10 "docker-entrypoint.s ..." One minute ago Up About one minute 5432 / tcp awx_postgres
166b153faa27 ansible / awx_rabbitmq: 3.7.4 "docker-entrypoint.s ..." About a minute ago Up 58 seconds 4369 / tcp, 5671-5672 / tcp, 15671-15672 / tcp, 25672 / tcp awx_rabbitmq
0f36c9784f74 memcached: alpine "docker-entrypoint.s ..." About a minute ago Up About a minute 11211 / tcp awx_memcached

Configuring SELinux and Firewall

By default, SELinux is enabled in CentOS 8. It is recommended to disable it to work AWX in the Docker environment. You can disable it by editing the following file:

  nano / etc / sysconfig / selinux 

Find the following line:

  SELINUX = maintain

And replace it with the following line:

  SELINUX = disabled

Save and close the file when you are done. Then restart the system to implement the changes. Next, you must allow http and https service via firewall. You can allow them with the following command:

  firewall-cmd - zone = public --add-masquerade --permanent 
firewall-cmd --permanent --add-service = http
firewall-cmd - permanent --add-service = https

Then restart the firewall service to apply the changes:

  firewall-cmd - load 

Access to AWX Web Interface

Now open your browser and type the URL http: // your-server-ip . You will be redirected to the AWX login page:

 Used AWX login

Enter your admin username and password that you defined in the inventory file and click SIGN IN button. You should see the AWX default panel on the following page:

 Ansible AWX interface

Conclusion

Congratulations! you have successfully installed AWX with Docker on CentOS 8. successfully. Now you can easily manage and control your Ansible project using the AWX web interface.


Source link