Install Ansible AWX on CentOS, RHEL 7, 8

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. This tutorial will walk you through the steps to set up Ansible AWX in a Docker container on  CentOS/RHEL 7/8. 

Please note that these instructions are applicable for AWX version 17.x only.


Prerequisites

To follow this tutorial along, you will need one (physical or virtual) installed with CentOS/RHEL 7/8, must have root user privileges.
 
We have also created a quick video tutorial to avoid any confusion while performing these installation steps.
 

Configure SELinux

By default, SELinux is enforcing in CentOS/RHEL 7/8. It is recommended to change SELINUX=enforcing to SELINUX=disabled to run Ansible AWX error free:
nano /etc/sysconfig/selinux
 
Replace the value "enforcing" with "disabled":
SELINUX=disabled
Save and close the file.

Reboot your machine to apply changes, when reboot complete, proceed with the below.

reboot

Install EPEL Repository

You will need to install the extra packages for enterprise Linux (EPEL) repository on your CentOS/RHEL 7/8:

Type below command if you are running CentOS/RHEL 8:
dnf -y install epel-release
dnf -y update
reboot
Type below command if you are running CentOS/RHEL 7:
yum -y install epel-release
yum -y update
reboot

Install Required Packages

Type below to install these additional packages if you are running a CentOS/RHEL 8:
dnf -y install git gcc gcc-c++ ansible nodejs gettext device-mapper-persistent-data lvm2 bzip2 python3-pip wget nano libseccomp
Type below if you are running a CentOS/RHEL 7:
yum -y install git gcc gcc-c++ ansible nodejs gettext device-mapper-persistent-data lvm2 bzip2 python3-pip python-docker wget nano

Install Docker

Type below to add Docker official repository on CentOS/RHEL 8:
dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
Type below command to add Docker official repository on CentOS/RHEL 7:
wget https://download.docker.com/linux/centos/docker-ce.repo --directory-prefix /etc/yum.repos.d/

Next, type below command to install Docker on CentOS/RHEL 8:

dnf -y install docker-ce

Type below command to create python3 alias: (only on CentOS/RHEL8)

alternatives --set python /usr/bin/python3

Verify default python version:

python --version
You should see output like below:
Python 3.6.8

Type below command to install Docker on CentOS/RHEL 7:

yum -y install docker-ce
Next, start the Docker service and make it persistent even when system reboot with below command:
systemctl start docker
systemctl enable docker
Confirm that docker is active and running:
systemctl status docker
You will see similar output like below:


Type below to install Docker Compose on CentOS/RHEL 7/8:
pip3 install setuptools_rust
pip3 install wheel
pip3 install docker-compose
You will see the output like below:
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting docker-compose
  Downloading https://files.pythonhosted.org/packages/40/91/670b31a1c452cc5f3ed9e1ff905f6c4501a182551dfd8fa1981a8dca2d67/docker_compose-1.25.4-py2.py3-none-any.whl (136kB)
    100% |████████████████████████████████| 143kB 38kB/s
Collecting PyYAML<6>=3.10 (from docker-compose)
  Downloading https://files.pythonhosted.org/packages/64/c2/b80047c7ac2478f9501676c988a5411ed5572f35d1beff9cae07d321512c/PyYAML-5.3.1.tar.gz (269kB)
    100% |████████████████████████████████| 276kB 14kB/s
Collecting requests<3>=2.20.0 (from docker-compose)
  Downloading https://files.pythonhosted.org/packages/1a/70/1935c770cb3be6e3a8b78ced23d7e0f3b187f5cbfab4749523ed65d7c9b1/requests-2.23.0-py2.py3-none-any.whl (58kB)
    100% |████████████████████████████████| 61kB 8.2kB/s
Collecting six<2>=1.3.0 (from docker-compose)
  Downloading https://files.pythonhosted.org/packages/65/eb/1f97cb97bfc2390a276969c6fae16075da282f5058082d4cb10c6c5c1dba/six-1.14.0-py2.py3-none-any.whl
Collecting websocket-client<1>=0.32.0 (from docker-compose)
  Downloading https://files.pythonhosted.org/packages/4c/5f/f61b420143ed1c8dc69f9eaec5ff1ac36109d52c80de49d66e0c36c3dfdf/websocket_client-0.57.0-py2.py3-none-any.whl (200kB)
    100% |████████████████████████████████| 204kB 27kB/s
Collecting dockerpty<1>=0.4.1 (from docker-compose)
  Downloading https://files.pythonhosted.org/packages/8d/ee/e9ecce4c32204a6738e0a5d5883d3413794d7498fe8b06f44becc028d3ba/dockerpty-0.4.1.tar.gz
Collecting docker[ssh]<5>=3.7.0 (from docker-compose)
  Downloading https://files.pythonhosted.org/packages/58/74/379a9d30b1620def158c40b88c43e01c1936a287ebb97afab0699c601c57/docker-4.2.0-py2.py3-none-any.whl (143kB)
    100% |████████████████████████████████| 153kB 15kB/s
Collecting jsonschema<4>=2.5.1 (from docker-compose)
  Downloading https://files.pythonhosted.org/packages/c5/8f/51e89ce52a085483359217bc72cdbf6e75ee595d5b1d4b5ade40c7e018b8/jsonschema-3.2.0-py2.py3-none-any.whl (56kB)
    100% |████████████████████████████████| 61kB 32kB/s
Collecting cached-property<2>=1.2.0 (from docker-compose)
  Downloading https://files.pythonhosted.org/packages/3b/86/85c1be2e8db9e13ef9a350aecd6dea292bd612fa288c2f40d035bb750ded/cached_property-1.5.1-py2.py3-none-any.whl
Collecting texttable<2>=0.9.0 (from docker-compose)
  Downloading https://files.pythonhosted.org/packages/ec/b1/8a1c659ce288bf771d5b1c7cae318ada466f73bd0e16df8d86f27a2a3ee7/texttable-1.6.2-py2.py3-none-any.whl
Collecting docopt<1>=0.6.1 (from docker-compose)
  Downloading https://files.pythonhosted.org/packages/a2/55/8f8cab2afd404cf578136ef2cc5dfb50baa1761b68c9da1fb1e4eed343c9/docopt-0.6.2.tar.gz
Collecting idna<3>=2.5 (from requests<3>=2.20.0->docker-compose)
  Downloading https://files.pythonhosted.org/packages/89/e3/afebe61c546d18fb1709a61bee788254b40e736cff7271c7de5de2dc4128/idna-2.9-py2.py3-none-any.whl (58kB)
    100% |████████████████████████████████| 61kB 13kB/s
Collecting chardet<4>=3.0.2 (from requests<3>=2.20.0->docker-compose)
  Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
    100% |████████████████████████████████| 143kB 17kB/s
Collecting certifi>=2017.4.17 (from requests<3>=2.20.0->docker-compose)
  Downloading https://files.pythonhosted.org/packages/b9/63/df50cac98ea0d5b006c55a399c3bf1db9da7b5a24de7890bc9cfd5dd9e99/certifi-2019.11.28-py2.py3-none-any.whl (156kB)
    100% |████████████████████████████████| 163kB 5.9kB/s
Collecting urllib3!=1.25.0,!=1.25.1,<1 .26="">=1.21.1 (from requests<3>=2.20.0->docker-compose)
  Downloading https://files.pythonhosted.org/packages/e8/74/6e4f91745020f967d09332bb2b8b9b10090957334692eb88ea4afe91b77f/urllib3-1.25.8-py2.py3-none-any.whl (125kB)
    100% |████████████████████████████████| 133kB 66kB/s
Collecting paramiko>=2.4.2; extra == "ssh" (from docker[ssh]<5>=3.7.0->docker-compose)
  Downloading https://files.pythonhosted.org/packages/06/1e/1e08baaaf6c3d3df1459fd85f0e7d2d6aa916f33958f151ee1ecc9800971/paramiko-2.7.1-py2.py3-none-any.whl (206kB)
    100% |████████████████████████████████| 215kB 134kB/s
Collecting pyrsistent>=0.14.0 (from jsonschema<4>=2.5.1->docker-compose)
  Downloading https://files.pythonhosted.org/packages/9f/0d/cbca4d0bbc5671822a59f270e4ce3f2195f8a899c97d0d5abb81b191efb5/pyrsistent-0.16.0.tar.gz (108kB)
    100% |████████████████████████████████| 112kB 137kB/s
Collecting attrs>=17.4.0 (from jsonschema<4>=2.5.1->docker-compose)
  Downloading https://files.pythonhosted.org/packages/a2/db/4313ab3be961f7a763066401fb77f7748373b6094076ae2bda2806988af6/attrs-19.3.0-py2.py3-none-any.whl
Collecting importlib-metadata; python_version < "3.8" (from jsonschema<4>=2.5.1->docker-compose)
  Downloading https://files.pythonhosted.org/packages/0f/b0/3302e1a1711aaa920e82b025ef07fb5fe81f09634e4f7af0fb4695b72cab/importlib_metadata-1.5.2-py2.py3-none-any.whl
Requirement already satisfied: setuptools in /usr/lib/python3.6/site-packages (from jsonschema<4>=2.5.1->docker-compose)
Collecting pynacl>=1.0.1 (from paramiko>=2.4.2; extra == "ssh"->docker[ssh]<5>=3.7.0->docker-compose)
  Downloading https://files.pythonhosted.org/packages/27/15/2cd0a203f318c2240b42cd9dd13c931ddd61067809fee3479f44f086103e/PyNaCl-1.3.0-cp34-abi3-manylinux1_x86_64.whl (759kB)
    100% |████████████████████████████████| 768kB 126kB/s
Collecting bcrypt>=3.1.3 (from paramiko>=2.4.2; extra == "ssh"->docker[ssh]<5>=3.7.0->docker-compose)
  Downloading https://files.pythonhosted.org/packages/8b/1d/82826443777dd4a624e38a08957b975e75df859b381ae302cfd7a30783ed/bcrypt-3.1.7-cp34-abi3-manylinux1_x86_64.whl (56kB)
    100% |████████████████████████████████| 61kB 244kB/s
Collecting cryptography>=2.5 (from paramiko>=2.4.2; extra == "ssh"->docker[ssh]<5>=3.7.0->docker-compose)
  Downloading https://files.pythonhosted.org/packages/45/73/d18a8884de8bffdcda475728008b5b13be7fbef40a2acc81a0d5d524175d/cryptography-2.8-cp34-abi3-manylinux1_x86_64.whl (2.3MB)
    100% |████████████████████████████████| 2.3MB 57kB/s
Collecting zipp>=0.5 (from importlib-metadata; python_version < "3.8"->jsonschema<4>=2.5.1->docker-compose)
  Downloading https://files.pythonhosted.org/packages/b2/34/bfcb43cc0ba81f527bc4f40ef41ba2ff4080e047acb0586b56b3d017ace4/zipp-3.1.0-py3-none-any.whl
Collecting cffi>=1.4.1 (from pynacl>=1.0.1->paramiko>=2.4.2; extra == "ssh"->docker[ssh]<5>=3.7.0->docker-compose)
  Downloading https://files.pythonhosted.org/packages/f1/c7/72abda280893609e1ddfff90f8064568bd8bcb2c1770a9d5bb5edb2d1fea/cffi-1.14.0-cp36-cp36m-manylinux1_x86_64.whl (399kB)
    100% |████████████████████████████████| 399kB 41kB/s
Collecting pycparser (from cffi>=1.4.1->pynacl>=1.0.1->paramiko>=2.4.2; extra == "ssh"->docker[ssh]<5>=3.7.0->docker-compose)
  Downloading https://files.pythonhosted.org/packages/ae/e7/d9c3a176ca4b02024debf82342dab36efadfc5776f9c8db077e8f6e71821/pycparser-2.20-py2.py3-none-any.whl (112kB)
    100% |████████████████████████████████| 112kB 35kB/s
Installing collected packages: PyYAML, idna, chardet, certifi, urllib3, requests, six, websocket-client, dockerpty, pycparser, cffi, pynacl, bcrypt, cryptography, paramiko, docker, pyrsistent, attrs, zipp, importlib-metadata, jsonschema, cached-property, texttable, docopt, docker-compose
  Running setup.py install for PyYAML ... done
  Running setup.py install for dockerpty ... done
  Running setup.py install for pyrsistent ... done
  Running setup.py install for docopt ... done
Successfully installed PyYAML-5.3.1 attrs-19.3.0 bcrypt-3.1.7 cached-property-1.5.1 certifi-2019.11.28 cffi-1.14.0 chardet-3.0.4 cryptography-2.8 docker-4.2.0 docker-compose-1.25.4 dockerpty-0.4.1 docopt-0.6.2 idna-2.9 importlib-metadata-1.5.2 jsonschema-3.2.0 paramiko-2.7.1 pycparser-2.20 pynacl-1.3.0 pyrsistent-0.16.0 requests-2.23.0 six-1.14.0 texttable-1.6.2 urllib3-1.25.8 websocket-client-0.57.0 zipp-3.1.0

Download Ansible AWX

We generally recommend that you should view the GitHub releases page before download.

You can download Ansible AWX version 17.1.0 from the Git Hub repository using the below command:

cd ~
git clone -b 17.1.0 https://github.com/ansible/awx.git

When download complete, type below command to generate a secret key using openssl and that key will be used to encrypt inventory file:
openssl rand -base64 30
You will see the output similar to the following:


Copy your secret key and save it for later use in the inventory file.

Install Ansible AWX

You need to edit inventory file like below:
nano ~/awx/installer/inventory
Find the following directives, uncomment them by removing the #, and update the values accordingly:
admin_password=StrongPassword
secret_key=Paste_Your_Secret_Key_Here
pg_database=postgres
pg_password=StrongPassword
awx_alternate_dns_servers="8.8.8.8,8.8.4.4"
postgres_data_dir="
/var/lib/awx/pgdocker"
docker_compose_dir="
/var/lib/awx/awxcompose"
project_data_dir="/var/lib/awx/projects"
Save and close the file when you are finished.

Type the following command to install AWX:
ansible-playbook -i ~/awx/installer/inventory ~/awx/installer/install.yml -v

This will take several minutes to complete, so don't get panic rather enjoy tea or coffee. Once the process successfully complete, you will see the output on your screen similar to the following:

Turncated output:

You can verify the running containers with the following command:

docker ps





Add Firewall Rules

You will need to add following rules to allow http and https service to pass through firewalld:
firewall-cmd --zone=public --add-masquerade --permanent
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload

Access AWX Web Interface

Open up your preferred web browser and type the http://your-server-ip in the address bar, you will be redirected to the AWX login page. 

For instance, if you encountered the following "A server error has occurred" page, then you need to perform the below steps to fix it first.


Fix AWX Server Error

First, you will need to edit the pg_hba.conf file like below:
nano /var/lib/awx/pgdocker/10/data/pg_hba.conf

add the following line at the end of the file:

host    all             all             0.0.0.0/0               md5

Save and close the editor when you are finished.

Next, restart AWX docker containers using the following command:

docker restart awx_postgres
docker restart awx_redis
docker restart awx_web
docker restart awx_task

Next, refresh your browser or access http://your_server_ip again and you will see the AWX upgrading page like below:

Once the upgrading process complete, you will be redirected to AWX login page like below:

Log in with the admin and password which you have defined in the inventory file, you should see the default AWX dashboard like below:


Wrapping up

Now that you have Ansible AWX running, you can now administer and manage your Ansible project easily using the AWX web interface.

54 comments:

  1. Awesome job and well explained!
    A novice with no linux expertise could do it.

    ReplyDelete
  2. could you please help me with this error?

    [root@centos7 installer]# ansible-playbook -i inventory install.yml

    PLAY [Build and deploy AWX] ********************************************************************************************************

    TASK [Gathering Facts] *************************************************************************************************************
    fatal: [localhost]: FAILED! => {"ansible_facts": {}, "changed": false, "failed_modules": {"setup": {"failed": true, "module_stderr": "/usr/bin/env: python3: No such file or directory\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 127}}, "msg": "The following modules failed to execute: setup\n"}

    PLAY RECAP *************************************************************************************************************************
    localhost : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

    [root@centos7 installer]#

    -Docker is Running.

    [root@centos7 ~]# systemctl enable docker
    Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

    [root@centos7 ~]# 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 Sun 2020-09-06 04:45:20 UTC; 44s ago
    Docs: http://docs.docker.com
    Main PID: 1532 (dockerd-current)
    CGroup: /system.slice/docker.service
    â”ω”€1532 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=do...
    └─1545 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-int...

    Sep 06 04:45:19 centos7 dockerd-current[1532]: time="2020-09-06T04:45:19.906672982Z" level=warning msg="Docker could not en...ystem"
    Sep 06 04:45:19 centos7 dockerd-current[1532]: time="2020-09-06T04:45:19.935201401Z" level=info msg="Graph migration to con...conds"
    Sep 06 04:45:19 centos7 dockerd-current[1532]: time="2020-09-06T04:45:19.936058581Z" level=info msg="Loading containers: start."
    Sep 06 04:45:20 centos7 dockerd-current[1532]: time="2020-09-06T04:45:20.077597010Z" level=info msg="Firewalld running: false"
    Sep 06 04:45:20 centos7 dockerd-current[1532]: time="2020-09-06T04:45:20.246261411Z" level=info msg="Default bridge (docker...dress"
    Sep 06 04:45:20 centos7 dockerd-current[1532]: time="2020-09-06T04:45:20.307628249Z" level=info msg="Loading containers: done."
    Sep 06 04:45:20 centos7 dockerd-current[1532]: time="2020-09-06T04:45:20.324019711Z" level=info msg="Daemon has completed i...ation"
    Sep 06 04:45:20 centos7 dockerd-current[1532]: time="2020-09-06T04:45:20.324139460Z" level=info msg="Docker daemon" commit=...1.13.1
    Sep 06 04:45:20 centos7 dockerd-current[1532]: time="2020-09-06T04:45:20.330828761Z" level=info msg="API listen on /var/run....sock"
    Sep 06 04:45:20 centos7 systemd[1]: Started Docker Application Container Engine.
    Hint: Some lines were ellipsized, use -l to show in full

    -Ansible Version,

    [root@centos7 installer]# ansible --version
    ansible 2.9.10
    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
    python version = 2.7.5 (default, Apr 2 2020, 13:16:51) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]

    ReplyDelete
    Replies
    1. You need to Install python3 to fix this issue.

      Delete
    2. I understand, but if I have it installed but not as the main language in my OS CentOs. I'm going to make a new attempt and share my results with you, thanks for the contribution.

      Delete
    3. Hi Friend.

      Thanks for your valuable input, I have installed Python 3 with SCL to start the download and installation of ansible. now I see the containers in Docker and load the Ansible web page. but what happens is that it stays loading and never finishes updating. analyzing the log I see the following. I appreciate you can help me.

      -log: ^
      2020-09-07 08:56:41,654 INFO exited: dispatcher (exit status 1; not expected)
      2020-09-07 08:56:41,654 INFO exited: dispatcher (exit status 1; not expected)
      2020-09-07 08:56:42,657 INFO spawned: 'dispatcher' with pid 15325
      2020-09-07 08:56:42,657 INFO spawned: 'dispatcher' with pid 15325
      2020-09-07 08:56:43,659 INFO success: dispatcher entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
      2020-09-07 08:56:43,659 INFO success: dispatcher entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
      2020-09-07 08:56:45,417 WARNING awx.main.dispatch.periodic periodic beat started
      Traceback (most recent call last):
      File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
      return self.cursor.execute(sql, params)
      psycopg2.errors.UndefinedTable: relation "main_instance" does not exist
      LINE 1: SELECT (1) AS "a" FROM "main_instance" WHERE "main_instance"...
      ^
      The above exception was the direct cause of the following exception:


      Thanks for your valuable input, I have installed Python 3 with SCL to start the download and installation of ansible. now I see the containers in Docker and load the Ansible web page. but what happens is that it stays loading and never finishes updating. analyzing the log I see the following. I appreciate you can help me.

      Thank you.

      Delete
    4. Pay attention to this (psycopg2.error) and try to fix it. Most probably you are missing psycopg2 package.

      Delete
  3. Thank you very much friend. now AWX is running without problem. it's time to automate some things.

    Follow this link to solve:

    https://stackoverflow.com/questions/41611551/python-cant-install-psycopg2-on-centos-7

    ReplyDelete
  4. hi, is there any solution for this error?
    TASK [local_docker : Start the containers] **************************************************************************************************************************************************
    fatal: [localhost]: FAILED! => {"changed": false, "msg": "Configuration error - Named volume \"var/lib/pgdocker/10/data:/var/lib/postgresql/data:Z\" is used in service \"postgres\" but no declaration was found in the volumes section."}

    ReplyDelete
    Replies
    1. You have to declare ./var/lib/pgdocker/10/data in .yml file under volume section. Follow the link for reference:

      https://docs.docker.com/compose/compose-file/#volume-configuration-reference

      Delete
  5. did you run this command? alternatives --set python /usr/bin/python3

    ReplyDelete
  6. TASK [local_docker : Start the containers] ******************************************************************************************************************
    fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6)) on imp02test's Python /usr/local/bin/python3. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter, for example via `pip install docker` or `pip install docker-py` (Python 2.6). The error was: No module named 'requests'"}

    PLAY RECAP **************************************************************************************************************************************************
    localhost : ok=12 changed=2 unreachable=0 failed=1 skipped=91 rescued=0 ignored=0

    ReplyDelete
    Replies
    1. It appears that you don't have the docker module installed.

      You will need to install it via your system package manager (apt install python-docker, for example), or using pip.

      If you have multiple Python versions, make sure that you've installed the docker module into the version that Ansible is using.

      pip3 install docker

      OR

      pip install docker

      Delete
  7. Good job my friend. Can you help with this error

    TASK [local_docker : Start the containers] ******************************************************************************************************************
    fatal: [localhost]: FAILED! => {"changed": false, "msg": "Configuration error - yaml.scanner.ScannerError: while scanning for the next token\nfound character '@' that cannot start any token\n in \"/var/lib/awxcompose/docker-compose.yml\" line 83, column 26"

    PLAY RECAP **************************************************************************************************************************************************
    localhost : ok=12 changed=4 unreachable=0 failed=1 skipped=91 rescued=0 ignored=0

    ReplyDelete
    Replies
    1. Verify your inventory file changes you made and correct if you mistyped anything. For example, error shows /var/lib/awxcompose which should be /var/lib/awx/awxcompose

      After modification, rerun the process

      Delete
  8. TASK [local_docker : Create Preload data] this step failed what happen bro plz ?

    ReplyDelete
  9. Hi Guys,

    My first question is

    Can i install AWX on RHEL 7.9 on OS layer not in docker containers ?

    I tried on a server before and i was stuck with awx-migrate command in some django python packages although AWX is installed on OS. but could not migrate database to postgres

    So i had to go to Docker approach for AWX

    So I have AWX running on RHEL 7.9 i have the four containers awx_web, awx_task, awx_postgres and awx_redis and awx web interface is accessible on host OS

    Im already running ansible and rundeck from another server and i am automating windows 2003,2008,2012,2016 servers and and this is with kerberos

    on awx i tried to execute agaisnt kerberos A.D but my container does not have KRB LIB, KRB workstation packages and also i need to register to satellite with subscription-manager.

    Is there anyway to run my awx playbooks from HOST OS or i have to get awx_web and awx_tasks public IP to the network and issue kerberos tickets from the container itself ?

    Thanks for the time guys and i would appreciate the valuable responses.

    A.T

    ReplyDelete
    Replies
    1. Did anyone ever reply to this? I am having the same issue

      Delete
    2. I would suggest you to post your query on AWX GitHUb page to let the community answer/suggest you a solution.

      Delete
  10. AnonymousMay 21, 2021

    while i'm trying to install 17.1.0 on rhel8.3 got the following error messages while running ansible-playbook. Any idea what could be wrong? Thanks in advance.

    TASK [local_docker : Register temporary docker container] *******************************************************************************************************************************
    ok: [localhost] => {"ansible_facts": {"container_command": "docker run --rm -v '/var/lib/awx/pgdocker:/var/lib/postgresql' centos:8 bash -c "}, "changed": false}

    TASK [local_docker : Check for existing Postgres data (run from inside the container for access to file)] *******************************************************************************
    fatal: [localhost]: FAILED! => {"changed": true, "cmd": "docker run --rm -v '/var/lib/awx/pgdocker:/var/lib/postgresql' centos:8 bash -c \"[[ -f /var/lib/postgresql/10/data/PG_VERSION ]] && echo 'exists'\"\n", "delta": "0:00:01.258900", "end": "2021-05-20 17:34:46.588540", "msg": "non-zero return code", "rc": 1, "start": "2021-05-20 17:34:45.329640", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
    ...ignoring
    ...
    .
    TASK [local_docker : Run migrations in task container] **********************************************************************************************************************************
    fatal: [localhost]: FAILED! => {"changed": true, "cmd": "docker-compose run --rm --service-ports task awx-manage migrate --no-input", "delta": "0:00:00.003101", "end": "2021-05-20 17:34:51.913194", "msg": "non-zero return code", "rc": 127, "start": "2021-05-20 17:34:51.910093", "stderr": "/bin/sh: docker-compose: command not found", "stderr_lines": ["/bin/sh: docker-compose: command not found"], "stdout": "", "stdout_lines": []}

    PLAY RECAP ******************************************************************************************************************************************************************************
    localhost : ok=15 changed=3 unreachable=0 failed=1 skipped=73 rescued=0 ignored=1

    ReplyDelete
    Replies
    1. you are missing docker-compose, install it with below command:

      pip3 install docker-compose

      Delete
    2. AnonymousMay 28, 2021

      Thanks! it's working now.

      Delete
    3. i did this again iam getting this same error can you please help

      fatal: [localhost]: FAILED! => {"changed": true, "cmd": "docker-compose run --rm --service-ports task awx-manage migrate --no-input", "delta": "0:00:00.004451", "end": "2022-04-27 12:38:36.755175", "msg": "non-zero return code", "rc": 127, "start": "2022-04-27 12:38:36.750724", "stderr": "/bin/sh: docker-compose: command not found", "stderr_lines": ["/bin/sh: docker-compose: command not found"], "stdout": "", "stdout_lines": []}

      Delete
  11. AnonymousMay 28, 2021

    After awx installation there's no https. Any quick guide to turn on ssl on awx 17.1.0? Thanks

    ReplyDelete
  12. AnonymousJune 23, 2021

    I tried installing the same on Amazon Linux 2 and getting below error while browsing

    ReplyDelete
  13. Hello,

    i follow your instructions but when i run ansible-plabook igot error:

    [root@ansible-controller ~]# ansible-playbook -i awx/installer/inventory awx/installer/install.yml -v
    Using /etc/ansible/ansible.cfg as config file
    ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.

    The error appears to have been in '/root/awx/installer/roles/local_docker/tasks/upgrade_postgres.yml': line 39, column 3, but may
    be elsewhere in the file depending on the exact syntax problem.

    The offending line appears to be:


    - name: Stop AWX before upgrading postgres
    ^ here


    The error appears to have been in '/root/awx/installer/roles/local_docker/tasks/upgrade_postgres.yml': line 39, column 3, but may
    be elsewhere in the file depending on the exact syntax problem.

    The offending line appears to be:


    - name: Stop AWX before upgrading postgres
    ^ here

    exception type:
    exception: no action detected in task. This often indicates a misspelled module name, or incorrect module path.

    The error appears to have been in '/root/awx/installer/roles/local_docker/tasks/upgrade_postgres.yml': line 39, column 3, but may
    be elsewhere in the file depending on the exact syntax problem.

    The offending line appears to be:


    - name: Stop AWX before upgrading postgres
    ^ here

    ReplyDelete
  14. Seems you incorrectly modified awx/installer/inventory and it cases indentation errors...

    ReplyDelete
  15. that is not a indentation error since the file has not been modified at all

    ReplyDelete
  16. Please how to upgrade Ansible AWS to the latest version

    ReplyDelete
    Replies
    1. You can not upgrade from 17.x version to latest but you can migrate existing data to latest one.

      Delete
  17. Can you please help on below error.?


    TASK [Gathering Facts] *********************************************************************************************************************
    ok: [localhost]

    TASK [check_vars : admin_password should be defined] ***************************************************************************************
    fatal: [localhost]: FAILED! => {
    "assertion": "admin_password is defined and admin_password != ''",
    "changed": false,
    "evaluated_to": false,
    "msg": "Set the value of 'admin_password' in the inventory file."
    }



    admin_password is already set

    # containerized postgres deployment on OpenShift
    pg_admin_password=Password#123

    # This will create or update a default admin (superuser) account in AWX, if not provided
    # then these default values are used
    admin_user=admin
    admin_password=Password#123

    ReplyDelete
    Replies
    1. Make sure you uncomment the line and define strong password, not some random password

      Delete
    2. Thanks for your quick response.
      However, issue is yet not resolved.
      I have it uncommented and tried multiple strong passwords.

      Any other thoughts.?

      Delete
    3. Post it at Ansible github page if you are done playing around.

      Delete
  18. Hello @muhammad anwar, thanks alot brother for your help, when installed, I can't find the installer directory under awx, any suggestions?

    ReplyDelete
    Replies
    1. Please note that, these instructions works with AWX 17.x version only. AWX 18.x or later release comes with different installation method. Probably you have AWX version other than 17.x and that is why installer directory is missing.

      Delete
    2. AnonymousJune 15, 2022

      Hello @muhammad, I have the same issue that I cant find an installation directory. So I safely presume that I have somehow installed a new AWX after following your procedure. I have some questions.
      1. Is there a way to install a new Ansible with the same procedure you've provided up to this point?
      2. if not what would be the way to uninstall the current config and reinstall the new one?
      3. Do you have an article/video on the procedure of new Ansible installation?

      Thank you. _/\_

      Delete
  19. I am getting this error:
    fatal: [localhost]: FAILED! => {"changed": false, "msg": "Unable to load docker-compose. Try `pip install docker-compose`. Error: Traceback (most recent call last):\n File \"/tmp/ansible_docker _compose_payload_lu_ionz3/ansible_docker_compose_payload.zip/ansible/modules/cloud/docker/docker_ compose.py\", line 482, in \nModuleNotFoundError: No module named 'compose'\n"}


    But I have docker composed installed:
    docker-compose version
    docker-compose version 1.29.2, build 5becea4c
    docker-py version: 5.0.0
    CPython version: 3.7.10
    OpenSSL version: OpenSSL 1.1.0l 10 Sep 2019

    Has anyone run into this issue?

    ReplyDelete
    Replies
    1. You need to install compose module with below command:

      pip install compose

      Delete
    2. Thank you for your rely, I installed compose as you suggested now it telling that docker-compose is not installed.

      fatal: [localhost]: FAILED! => {"changed": false, "msg": "Unable to load docker-compose. Try `pip install docker-compose`. Error: Traceback (most recent call last):\n File \"/tmp/ansible_docker_compose_payload_bronmzhf/ansible_docker_compose_payload.zip/ansible/modules/cloud/docker/docker_compose.py\", line 483, in \nModuleNotFoundError: No module named 'compose.cli'; 'compose' is not a package\n"}


      I tried a fresh install still get this error i also tried to install docker-compose without pip, any suggestions?

      Delete
    3. Hey so I figured out the issue once you install docker-compose you need to run
      ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

      Thanks for your help!

      Delete
  20. Hi Neend your help, we tried to install AWX on CentOS 7.7 multiple times but it is failing at below task, can you suggest what needs to be done.

    TASK [local_docker : Run migrations in task container] ***************************************************************************************************************************
    fatal: [localhost]: FAILED! => {"changed": true, "cmd": "docker-compose run --rm --service-ports task awx-manage migrate --no-input", "delta": "0:00:00.227195", "end": "2022-03-15 02:54:06.004376", "msg": "non-zero return code", "rc": 1, "start": "2022-03-15 02:54:05.777181", "stderr": "Traceback (most recent call last):\n File \"/usr/bin/docker-compose\", line 11, in \n sys.exit(main())\n File \"/usr/lib/python2.7/site-packages/compose/cli/main.py\", line 71, in main\n command()\n File \"/usr/lib/python2.7/site-packages/compose/cli/main.py\", line 124, in perform_command\n project = project_from_options('.', options)\n File \"/usr/lib/python2.7/site-packages/compose/cli/command.py\", line 42, in project_from_options\n compatibility=options.get('--compatibility'),\n File \"/usr/lib/python2.7/site-packages/compose/cli/command.py\", line 123, in get_project\n host=host, environment=environment\n File \"/usr/lib/python2.7/site-packages/compose/cli/command.py\", line 94, in get_client\n environment=environment, tls_version=get_tls_version(environment)\n File \"/usr/lib/python2.7/site-packages/compose/cli/docker_client.py\", line 127, in docker_client\n client = APIClient(**kwargs)\n File \"/usr/lib/python2.7/site-packages/docker/api/client.py\", line 128, in __init__\n config_dict=self._general_configs, credstore_env=credstore_env,\nTypeError: load_config() got an unexpected keyword argument 'config_dict'", "stderr_lines": ["Traceback (most recent call last):", " File \"/usr/bin/docker-compose\", line 11, in ", " sys.exit(main())", " File \"/usr/lib/python2.7/site-packages/compose/cli/main.py\", line 71, in main", " command()", " File \"/usr/lib/python2.7/site-packages/compose/cli/main.py\", line 124, in perform_command", " project = project_from_options('.', options)", " File \"/usr/lib/python2.7/site-packages/compose/cli/command.py\", line 42, in project_from_options", " compatibility=options.get('--compatibility'),", " File \"/usr/lib/python2.7/site-packages/compose/cli/command.py\", line 123, in get_project", " host=host, environment=environment", " File \"/usr/lib/python2.7/site-packages/compose/cli/command.py\", line 94, in get_client", " environment=environment, tls_version=get_tls_version(environment)", " File \"/usr/lib/python2.7/site-packages/compose/cli/docker_client.py\", line 127, in docker_client", " client = APIClient(**kwargs)", " File \"/usr/lib/python2.7/site-packages/docker/api/client.py\", line 128, in __init__", " config_dict=self._general_configs, credstore_env=credstore_env,", "TypeError: load_config() got an unexpected keyword argument 'config_dict'"], "stdout": "", "stdout_lines": []}

    PLAY RECAP ***********************************************************************************************************************************************************************
    localhost : ok=15 changed=3 unreachable=0 failed=1 skipped=73 rescued=0 ignored=2

    ReplyDelete
    Replies
    1. Make sure docker-compose exist in /usr/bin and /usr/sbin

      Delete
  21. Great doc, i could install successfully after upgrading the pip.

    ReplyDelete
  22. I'm getting below error in another server. can you suggest.

    prdansible ~]# ansible-playbook -i ~/awx/installer/inventory ~/awx/installer/install.yml -v
    Using /etc/ansible/ansible.cfg as config file
    ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.

    The error appears to have been in '/root/awx/installer/roles/local_docker/tasks/upgrade_postgres.yml': line 39, column 3, but may
    be elsewhere in the file depending on the exact syntax problem.

    The offending line appears to be:


    - name: Stop AWX before upgrading postgres
    ^ here


    The error appears to have been in '/root/awx/installer/roles/local_docker/tasks/upgrade_postgres.yml': line 39, column 3, but may
    be elsewhere in the file depending on the exact syntax problem.

    The offending line appears to be:


    - name: Stop AWX before upgrading postgres
    ^ here

    exception type:
    exception: no action detected in task. This often indicates a misspelled module name, or incorrect module path.

    The error appears to have been in '/root/awx/installer/roles/local_docker/tasks/upgrade_postgres.yml': line 39, column 3, but may
    be elsewhere in the file depending on the exact syntax problem.

    The offending line appears to be:


    - name: Stop AWX before upgrading postgres
    ^ here

    ReplyDelete
  23. Hi I'm getting bellow error, seems python version issue, i have pytho3 installed. how can I mitigate this error.

    TASK [local_docker : Remove AWX containers before migrating postgres so that the old postgres container does not get used] ********************************************************
    fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6)) on stgansible's Python /usr/bin/python3. Please read module documentation and install in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter, for example via `pip install docker` or `pip install docker-py` (Python 2.6). The error was: No module named 'docker'"}
    ...ignoring

    TASK [local_docker : Run migrations in task container] ****************************************************************************************************************************
    fatal: [localhost]: FAILED! => {"changed": true, "cmd": "docker-compose run --rm --service-ports task awx-manage migrate --no-input", "delta": "0:00:00.005780", "end": "2022-04-01 16:44:05.770280", "msg": "non-zero return code", "rc": 127, "start": "2022-04-01 16:44:05.764500", "stderr": "/bin/sh: docker-compose: command not found", "stderr_lines": ["/bin/sh: docker-compose: command not found"], "stdout": "", "stdout_lines": []}

    PLAY RECAP ************************************************************************************************************************************************************************
    localhost : ok=15 changed=3 unreachable=0 failed=1 skipped=73 rescued=0 ignored=2

    ReplyDelete
    Replies
    1. Its not python issue, it says “docker-compose: command not found” in the output.

      Make sure docker-compose binary is available within /usr/bin/ and /usr/sbin/

      Delete
  24. Thank you!, it was resolved but, I could not connect to server using http:ip:port8052 says not able to connect some times does not exist.

    only error I encountered while installing ansible was git clone.


    Git clone error:
    ------------------
    Note: checking out 'c1ab815c80cac96508d9779d92bc1280d0347627'.

    You are in 'detached HEAD' state. You can look around, make experimental
    changes and commit them, and you can discard any commits you make in this
    state without impacting any branches by performing another checkout.

    If you want to create a new branch to retain commits you create, you may
    do so (now or later) by using -b with the checkout command again. Example:

    git checkout -b new_branch_name


    However, I did modified inventory file , but no luck.

    can you suggest.

    here is docker status.

    ----------------------------
    Docker Application Container Engine
    Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
    Active: [1;32mactive (running) [0m since Fri 2022-04-01 17:29:27 GMT; 1min 19s ago
    Docs: https://docs.docker.com
    Main PID: 1434 (dockerd)
    Tasks: 27
    Memory: 116.2M
    CGroup: /system.slice/docker.service
    ├─1434 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
    └─2163 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8052 -container-ip 172.18.0.5 -container-port 8052

    Apr 01 17:29:25 stgansible dockerd[1434]: time="2022-04-01T17:29:25.707407462Z" level=error msg="failed to start container" container=58d96c02b8dd2428fb386f2982688124c18cb9fba0...
    Apr 01 17:29:26 stgansible dockerd[1434]: time="2022-04-01T17:29:26Z" level=warning msg="file does not exist: /proc/sys/net/ipv6/conf/all/disable_ipv6 : stat /proc/s...'s kernel?"
    Apr 01 17:29:26 stgansible dockerd[1434]: time="2022-04-01T17:29:26Z" level=warning msg="file does not exist: /proc/sys/net/ipv6/conf/all/disable_ipv6 : stat /proc/s...'s kernel?"
    Apr 01 17:29:26 stgansible dockerd[1434]: time="2022-04-01T17:29:26Z" level=warning msg="file does not exist: /proc/sys/net/ipv6/conf/all/disable_ipv6 : stat /proc/s...'s kernel?"
    Apr 01 17:29:27 stgansible dockerd[1434]: time="2022-04-01T17:29:27Z" level=warning msg="file does not exist: /proc/sys/net/ipv6/conf/all/disable_ipv6 : stat /proc/s...'s kernel?"
    Apr 01 17:29:27 stgansible dockerd[1434]: time="2022-04-01T17:29:27.656685817Z" level=info msg="Loading containers: done."
    Apr 01 17:29:27 stgansible dockerd[1434]: time="2022-04-01T17:29:27.732888198Z" level=info msg="Docker daemon" commit=87a90dc graphdriver(s)=overlay2 version=20.10.14
    Apr 01 17:29:27 stgansible dockerd[1434]: time="2022-04-01T17:29:27.736775329Z" level=info msg="Daemon has completed initialization"
    Apr 01 17:29:27 stgansible systemd[1]: Started Docker Application Container Engine.
    Apr 01 17:29:27 stgansible dockerd[1434]: time="2022-04-01T17:29:27.914319854Z" level=info msg="API listen on /var/run/docker.sock"

    ReplyDelete
  25. AnonymousMay 07, 2022

    Hi these all steps works for centos 7.9 or not...I am having centos7.9

    ReplyDelete
  26. AnonymousJune 10, 2022

    TASK [local_docker : Check for existing Postgres data (run from inside the container for access to file)] **************************************************************
    fatal: [localhost]: FAILED! => {"changed": true, "cmd": "docker run --rm -v '/var/lib/awx/pgdocker:/var/lib/postgresql' centos:8 bash -c \"[[ -f /var/lib/postgresql/10/data/PG_VERSION ]] && echo 'exists'\"\n", "delta": "0:00:08.637637", "end": "2022-06-10 12:32:36.107230", "msg": "non-zero return code", "rc": 125, "start": "2022-06-10 12:32:27.469593", "stderr": "Unable to find image 'centos:8' locally\ndocker: Error response from daemon: Get \"https://registry-1.docker.io/v2/\": dial tcp: lookup registry-1.docker.io on 10.78.28.82:53: server misbehaving.\nSee 'docker run --help'.", "stderr_lines": ["Unable to find image 'centos:8' locally", "docker: Error response from daemon: Get \"https://registry-1.docker.io/v2/\": dial tcp: lookup registry-1.docker.io on 10.78.28.82:53: server misbehaving.", "See 'docker run --help'."], "stdout": "", "stdout_lines": []}

    Kindly help to resolve the issue

    ReplyDelete
  27. My AWX UI is getting up but I cannot access it, username or password incorrect and also I am getting the following error! Any idea? how to fix it?

    TASK [local_docker : Check for existing Postgres data (run from inside the container for access to file)] ****************************************************************************************************
    fatal: [localhost]: FAILED! => {"changed": true, "cmd": "docker run --rm -v '/var/lib/awx/pgdocker:/var/lib/postgresql' centos:8 bash -c \"[[ -f /var/lib/postgresql/10/data/PG_VERSION ]] && echo 'exists'\"\n", "delta": "0:00:01.202883", "end": "2023-08-14 00:44:46.245625", "msg": "non-zero return code", "rc": 1, "start": "2023-08-14 00:44:45.042742", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
    ...ignoring


    TASK [local_docker : Remove AWX containers before migrating postgres so that the old postgres container does not get used] ***********************************************************************************
    fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6)) on master's Python /usr/bin/python3. Please read module documentation and install in the appropriate location, for example via `pip install docker` or `pip install docker-py` (Python 2.6). The error was: No module named 'docker'"}
    ...ignoring

    TASK [local_docker : Run migrations in task container] *******************************************************************************************************************************************************
    changed: [localhost] => {"changed": true, "cmd": "docker-compose run --rm --service-ports task awx-manage migrate --no-input", "delta": "0:00:07.483128", "end": "2023-08-14 00:45:02.051101", "rc": 0, "start": "2023-08-14 00:44:54.567973", "stderr": "Creating awxcompose_task_run ... \r\nCreating awxcompose_task_run ... done", "stderr_lines": ["Creating awxcompose_task_run ... ", "Creating awxcompose_task_run ... done"], "stdout": "Operations to perform:\n Apply all migrations: auth, conf, contenttypes, main, oauth2_provider, sessions, sites, social_django, sso, taggit\nRunning migrations:\n No migrations to apply.", "stdout_lines": ["Operations to perform:", " Apply all migrations: auth, conf, contenttypes, main, oauth2_provider, sessions, sites, social_django, sso, taggit", "Running migrations:", " No migrations to apply."]}

    TASK [local_docker : Start the containers] *******************************************************************************************************************************************************************
    fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6)) on master's Python /usr/bin/python3. Please read module documentation and install in the appropriate location, for example via `pip install docker` or `pip install docker-py` (Python 2.6). The error was: No module named 'docker'"}

    PLAY RECAP ***************************************************************************************************************************************************************************************************
    localhost : ok=16 changed=8 unreachable=0 failed=1 skipped=73 rescued=0 ignored=2

    [root@master ~]# docker ps
    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
    5ce2a8a26291 ansible/awx:17.1.0 "/usr/bin/tini -- /b…" 11 hours ago Up 24 minutes 0.0.0.0:80->8052/tcp, :::80->8052/tcp awx_web
    1a0896f794bb postgres:12 "docker-entrypoint.s…" 11 hours ago Up 24 minutes 5432/tcp awx_postgres
    6742cc91f2bd redis "docker-entrypoint.s…" 11 hours ago Up 24 minutes 6379/tcp awx_redis

    ReplyDelete
  28. Still I am getting server error as I have followd all stedps, docker are running perfectly

    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
    1f7a451a04b8 ansible/awx:17.1.0 "/usr/bin/tini -- /b…" 7 minutes ago Up 2 minutes 0.0.0.0:80->8052/tcp, :::80->8052/tcp awx_web
    9e9f354dd0de postgres:12 "docker-entrypoint.s…" 7 minutes ago Up 2 minutes 5432/tcp awx_postgres
    c7fe1d40f30b redis "docker-entrypoint.s…" 7 minutes ago Up 2 minutes 6379/tcp awx_redis
    [root@controller ~]#

    ReplyDelete

Powered by Blogger.