Install Ansible AWX with Docker-Compose on CentOS 7 - CentLinux

Latest

Sunday, 15 September 2019

Install Ansible AWX with Docker-Compose on CentOS 7

Install Ansible AWX with Docker-Compose on CentOS 7

In this article, you will learn how to install Ansible AWX with docker-compose on CentOS 7.

 

Table of Contents:

     

    What is AWX Project? :

    AWX Project or AWX is a web based console for Ansible. AWX is designed to make Ansible more usable for DevOps members of different technical proficiencies and skill sets. AWX is a hub for automation tasks. Ansible Tower is a commercial product supported by Red Hat, Inc. but derived from AWX upstream project, which is open source since September 2017. This makes AWX a good alternative of Ansible Tower.

    Currently, stable version of AWX 7.0 has been released that requires a containerized environment to install and run. According to AWX Project Documentation, we can deploy AWX on following containerization platforms.

    We are using Docker-Compose here, because it is relatively easy to setup and requires less hardware resources as compare to OpenShift and Kubernetes.

    We have already installed Ansible control node on CentOS 7. Now, we are installing AWX with Docker-Compose on the same Ansible control node.

    If you want to improve your knowledge about Ansible, then you should refer to Ansible Documentation or get a copy of Ansible Quick Start Guide: Control and monitor infrastructures of any size, physical or virtual by Packt Publishing.

    Besides that, you can enroll in Ansible: Ansible Automation Masterclass: 2-in-1 at Udemy to be a master of Ansible in notime.

     

    Environment Specification:

    We are using three CentOS 7 virtual machines with following specifications.

    • CPU - 3.4 Ghz (2 Cores)
    • Memory - 4 GB
    • Storage - 60 GB
    • Hostname - ansible-01.centlinux.com
    • IP Address - 192.168.116.201 /24
    • Operating System - CentOS 7.6

     

    Installing EPEL Yum Repository on CentOS 7:

    Connect with ansible-01.centlinux.com by using ssh as root user.

    AWX requires some packages that are available in EPEL (Extra Packages for Enterprise Linux) yum repository. Therefore, we are installing epel-release package by using yum command to enable EPEL.

    [root@ansible-01 ~]# yum install -y epel-release Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.ges.net.pk * extras: mirrors.ges.net.pk * updates: mirrors.ges.net.pk Resolving Dependencies --> Running transaction check ---> Package epel-release.noarch 0:7-11 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: epel-release noarch 7-11 extras 15 k Transaction Summary ================================================================================ Install 1 Package Total download size: 15 k Installed size: 24 k Downloading packages: epel-release-7-11.noarch.rpm | 15 kB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : epel-release-7-11.noarch 1/1 Verifying : epel-release-7-11.noarch 1/1 Installed: epel-release.noarch 0:7-11 Complete!

     

    Installing Ansible AWX Prerequisites on CentOS 7:

    AWX requires some prerequisite software packages, all of these packages are available in standard and EPEL yum repositories.

    Therefore, we are Installing all prerequisite packages using a single yum command.

    [root@ansible-01 ~]# yum -y install git gcc gcc-c++ nodejs gettext device-mapper-persistent-data lvm2 bzip2 python-pip ... Installed: bzip2.x86_64 0:1.0.6-13.el7 gcc.x86_64 0:4.8.5-36.el7_6.2 gcc-c++.x86_64 0:4.8.5-36.el7_6.2 git.x86_64 0:1.8.3.1-20.el7 nodejs.x86_64 1:6.17.1-1.el7 python2-pip.noarch 0:8.1.2-10.el7 Dependency Installed: cpp.x86_64 0:4.8.5-36.el7_6.2 glibc-devel.x86_64 0:2.17-260.el7_6.6 glibc-headers.x86_64 0:2.17-260.el7_6.6 kernel-headers.x86_64 0:3.10.0-957.27.2.el7 libmpc.x86_64 0:1.0.1-3.el7 libstdc++-devel.x86_64 0:4.8.5-36.el7_6.2 libuv.x86_64 1:1.30.1-1.el7 mpfr.x86_64 0:3.1.1-4.el7 npm.x86_64 1:3.10.10-1.6.17.1.1.el7 perl.x86_64 4:5.16.3-294.el7_6 perl-Carp.noarch 0:1.26-244.el7 perl-Encode.x86_64 0:2.51-7.el7 perl-Error.noarch 1:0.17020-2.el7 perl-Exporter.noarch 0:5.68-3.el7 perl-File-Path.noarch 0:2.09-2.el7 perl-File-Temp.noarch 0:0.23.01-3.el7 perl-Filter.x86_64 0:1.49-3.el7 perl-Getopt-Long.noarch 0:2.40-3.el7 perl-Git.noarch 0:1.8.3.1-20.el7 perl-HTTP-Tiny.noarch 0:0.033-3.el7 perl-PathTools.x86_64 0:3.40-5.el7 perl-Pod-Escapes.noarch 1:1.04-294.el7_6 perl-Pod-Perldoc.noarch 0:3.20-4.el7 perl-Pod-Simple.noarch 1:3.28-4.el7 perl-Pod-Usage.noarch 0:1.63-3.el7 perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 perl-Socket.x86_64 0:2.010-4.el7 perl-Storable.x86_64 0:2.45-3.el7 perl-TermReadKey.x86_64 0:2.30-20.el7 perl-Text-ParseWords.noarch 0:3.29-4.el7 perl-Time-HiRes.x86_64 4:1.9725-3.el7 perl-Time-Local.noarch 0:1.2300-2.el7 perl-constant.noarch 0:1.27-2.el7 perl-libs.x86_64 4:5.16.3-294.el7_6 perl-macros.x86_64 4:5.16.3-294.el7_6 perl-parent.noarch 1:0.225-244.el7 perl-podlators.noarch 0:2.5.1-3.el7 perl-threads.x86_64 0:1.87-4.el7 perl-threads-shared.x86_64 0:1.43-6.el7 rsync.x86_64 0:3.1.2-6.el7_6.1 Updated: lvm2.x86_64 7:2.02.180-10.el7_6.8 Dependency Updated: device-mapper.x86_64 7:1.02.149-10.el7_6.8 device-mapper-event.x86_64 7:1.02.149-10.el7_6.8 device-mapper-event-libs.x86_64 7:1.02.149-10.el7_6.8 device-mapper-libs.x86_64 7:1.02.149-10.el7_6.8 glibc.x86_64 0:2.17-260.el7_6.6 glibc-common.x86_64 0:2.17-260.el7_6.6 libgcc.x86_64 0:4.8.5-36.el7_6.2 libgomp.x86_64 0:4.8.5-36.el7_6.2 libstdc++.x86_64 0:4.8.5-36.el7_6.2 lvm2-libs.x86_64 7:2.02.180-10.el7_6.8 Complete!

     

    Installing Docker CE on CentOS 7:

    Install Docker CE yum repository from Docker official website.

    [root@ansible-01 ~]# yum-config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo Loaded plugins: fastestmirror adding repo from: https://download.docker.com/linux/centos/docker-ce.repo grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo repo saved to /etc/yum.repos.d/docker-ce.repo

    Since the Docker CE yum repository has been added, we can now install Docker CE using yum command.

    [root@ansible-01 ~]# yum install -y docker-ce Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.ges.net.pk * epel: kartolo.sby.datautama.net.id * extras: mirrors.ges.net.pk * updates: mirrors.ges.net.pk docker-ce-nightly | 3.5 kB 00:00 docker-ce-stable | 3.5 kB 00:00 (1/4): docker-ce-stable/x86_64/updateinfo | 55 B 00:00 (2/4): docker-ce-stable/x86_64/primary_db | 34 kB 00:00 (3/4): docker-ce-nightly/x86_64/updateinfo | 55 B 00:01 (4/4): docker-ce-nightly/x86_64/primary_db | 163 kB 00:01 Resolving Dependencies --> Running transaction check ---> Package docker-ce.x86_64 3:19.03.2-3.el7 will be installed --> Processing Dependency: container-selinux >= 2:2.74 for package: 3:docker-ce-19.03.2-3.el7.x86_64 --> Processing Dependency: containerd.io >= 1.2.2-3 for package: 3:docker-ce-19.03.2-3.el7.x86_64 --> Processing Dependency: libseccomp >= 2.3 for package: 3:docker-ce-19.03.2-3.el7.x86_64 --> Processing Dependency: docker-ce-cli for package: 3:docker-ce-19.03.2-3.el7.x86_64 --> Processing Dependency: libcgroup for package: 3:docker-ce-19.03.2-3.el7.x86_64 --> Processing Dependency: libseccomp.so.2()(64bit) for package: 3:docker-ce-19.03.2-3.el7.x86_64 --> Running transaction check ---> Package container-selinux.noarch 2:2.107-1.el7_6 will be installed --> Processing Dependency: policycoreutils-python for package: 2:container-selinux-2.107-1.el7_6.noarch ---> Package containerd.io.x86_64 0:1.2.6-3.3.el7 will be installed ---> Package docker-ce-cli.x86_64 1:19.03.2-3.el7 will be installed ---> Package libcgroup.x86_64 0:0.41-20.el7 will be installed ---> Package libseccomp.x86_64 0:2.3.1-3.el7 will be installed --> Running transaction check ---> Package policycoreutils-python.x86_64 0:2.5-29.el7_6.1 will be installed --> Processing Dependency: policycoreutils = 2.5-29.el7_6.1 for package: policycoreutils-python-2.5-29.el7_6.1.x86_64 --> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-python-2.5-29.el7_6.1.x86_64 --> Processing Dependency: libsemanage-python >= 2.5-14 for package: policycoreutils-python-2.5-29.el7_6.1.x86_64 --> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-29.el7_6.1.x86_64 --> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-29.el7_6.1.x86_64 --> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-29.el7_6.1.x86_64 --> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-29.el7_6.1.x86_64 --> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-29.el7_6.1.x86_64 --> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-29.el7_6.1.x86_64 --> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-29.el7_6.1.x86_64 --> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-29.el7_6.1.x86_64 --> Running transaction check ---> Package audit-libs-python.x86_64 0:2.8.4-4.el7 will be installed ---> Package checkpolicy.x86_64 0:2.5-8.el7 will be installed ---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed ---> Package policycoreutils.x86_64 0:2.5-29.el7 will be updated ---> Package policycoreutils.x86_64 0:2.5-29.el7_6.1 will be an update ---> Package python-IPy.noarch 0:0.75-6.el7 will be installed ---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: docker-ce x86_64 3:19.03.2-3.el7 docker-ce-stable 24 M Installing for dependencies: audit-libs-python x86_64 2.8.4-4.el7 base 76 k checkpolicy x86_64 2.5-8.el7 base 295 k container-selinux noarch 2:2.107-1.el7_6 extras 39 k containerd.io x86_64 1.2.6-3.3.el7 docker-ce-nightly 26 M docker-ce-cli x86_64 1:19.03.2-3.el7 docker-ce-stable 39 M libcgroup x86_64 0.41-20.el7 base 66 k libseccomp x86_64 2.3.1-3.el7 base 56 k libsemanage-python x86_64 2.5-14.el7 base 113 k policycoreutils-python x86_64 2.5-29.el7_6.1 updates 456 k python-IPy noarch 0.75-6.el7 base 32 k setools-libs x86_64 3.3.8-4.el7 base 620 k Updating for dependencies: policycoreutils x86_64 2.5-29.el7_6.1 updates 916 k Transaction Summary ================================================================================ Install 1 Package (+11 Dependent packages) Upgrade ( 1 Dependent package) Total download size: 92 M Downloading packages: Delta RPMs disabled because /usr/bin/applydeltarpm not installed. (1/13): checkpolicy-2.5-8.el7.x86_64.rpm | 295 kB 00:01 (2/13): audit-libs-python-2.8.4-4.el7.x86_64.rpm | 76 kB 00:00 (3/13): libcgroup-0.41-20.el7.x86_64.rpm | 66 kB 00:00 (4/13): libseccomp-2.3.1-3.el7.x86_64.rpm | 56 kB 00:00 (5/13): libsemanage-python-2.5-14.el7.x86_64.rpm | 113 kB 00:00 (6/13): container-selinux-2.107-1.el7_6.noarch.rpm | 39 kB 00:02 (7/13): policycoreutils-2.5-29.el7_6.1.x86_64.rpm | 916 kB 00:06 (8/13): python-IPy-0.75-6.el7.noarch.rpm | 32 kB 00:00 (9/13): policycoreutils-python-2.5-29.el7_6.1.x86_64.rpm | 456 kB 00:07 (10/13): setools-libs-3.3.8-4.el7.x86_64.rpm | 620 kB 00:02 warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-19.03.2-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY Public key for docker-ce-19.03.2-3.el7.x86_64.rpm is not installed (11/13): docker-ce-19.03.2-3.el7.x86_64.rpm | 24 MB 03:09 Public key for containerd.io-1.2.6-3.3.el7.x86_64.rpm is not installed00:38 ETA (12/13): containerd.io-1.2.6-3.3.el7.x86_64.rpm | 26 MB 03:22 (13/13): docker-ce-cli-19.03.2-3.el7.x86_64.rpm | 39 MB 03:56 -------------------------------------------------------------------------------- Total 398 kB/s | 92 MB 03:57 Retrieving key from https://download.docker.com/linux/centos/gpg Importing GPG key 0x621E9F35: Userid : "Docker Release (CE rpm) <docker@docker.com>" Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35 From : https://download.docker.com/linux/centos/gpg Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : policycoreutils-2.5-29.el7_6.1.x86_64 1/14 Installing : libcgroup-0.41-20.el7.x86_64 2/14 Installing : setools-libs-3.3.8-4.el7.x86_64 3/14 Installing : checkpolicy-2.5-8.el7.x86_64 4/14 Installing : libseccomp-2.3.1-3.el7.x86_64 5/14 Installing : 1:docker-ce-cli-19.03.2-3.el7.x86_64 6/14 Installing : libsemanage-python-2.5-14.el7.x86_64 7/14 Installing : audit-libs-python-2.8.4-4.el7.x86_64 8/14 Installing : python-IPy-0.75-6.el7.noarch 9/14 Installing : policycoreutils-python-2.5-29.el7_6.1.x86_64 10/14 Installing : 2:container-selinux-2.107-1.el7_6.noarch 11/14 Installing : containerd.io-1.2.6-3.3.el7.x86_64 12/14 Installing : 3:docker-ce-19.03.2-3.el7.x86_64 13/14 Cleanup : policycoreutils-2.5-29.el7.x86_64 14/14 Verifying : libcgroup-0.41-20.el7.x86_64 1/14 Verifying : policycoreutils-python-2.5-29.el7_6.1.x86_64 2/14 Verifying : python-IPy-0.75-6.el7.noarch 3/14 Verifying : audit-libs-python-2.8.4-4.el7.x86_64 4/14 Verifying : libsemanage-python-2.5-14.el7.x86_64 5/14 Verifying : 2:container-selinux-2.107-1.el7_6.noarch 6/14 Verifying : 1:docker-ce-cli-19.03.2-3.el7.x86_64 7/14 Verifying : libseccomp-2.3.1-3.el7.x86_64 8/14 Verifying : checkpolicy-2.5-8.el7.x86_64 9/14 Verifying : 3:docker-ce-19.03.2-3.el7.x86_64 10/14 Verifying : containerd.io-1.2.6-3.3.el7.x86_64 11/14 Verifying : policycoreutils-2.5-29.el7_6.1.x86_64 12/14 Verifying : setools-libs-3.3.8-4.el7.x86_64 13/14 Verifying : policycoreutils-2.5-29.el7.x86_64 14/14 Installed: docker-ce.x86_64 3:19.03.2-3.el7 Dependency Installed: audit-libs-python.x86_64 0:2.8.4-4.el7 checkpolicy.x86_64 0:2.5-8.el7 container-selinux.noarch 2:2.107-1.el7_6 containerd.io.x86_64 0:1.2.6-3.3.el7 docker-ce-cli.x86_64 1:19.03.2-3.el7 libcgroup.x86_64 0:0.41-20.el7 libseccomp.x86_64 0:2.3.1-3.el7 libsemanage-python.x86_64 0:2.5-14.el7 policycoreutils-python.x86_64 0:2.5-29.el7_6.1 python-IPy.noarch 0:0.75-6.el7 setools-libs.x86_64 0:3.3.8-4.el7 Dependency Updated: policycoreutils.x86_64 0:2.5-29.el7_6.1 Complete!

    Enable and start Docker service.

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

     

    Installing Docker-Compose on CentOS 7:

    PyPI (Python Package Index) is a software package repository of software written  in Python. PyPA (Python Package Authority) recommend use of PyPI for installation of Python software packages.

    Therefore, we are installing docker-compose using pip command.

    [root@ansible-01 installer]# pip install docker-compose Collecting docker-compose Downloading https://files.pythonhosted.org/packages/dd/e6/1521d1dfd9c0da1d1863 100% |ââââââââââââââââââââââââââââââââ| 143kB 212kB/s Collecting docker[ssh]<4.0,>=3.7.0 (from docker-compose) Downloading https://files.pythonhosted.org/packages/09/da/7cc7ecdcd01145e9924a 100% |ââââââââââââââââââââââââââââââââ| 143kB 77kB/s Requirement already satisfied (use --upgrade to upgrade): backports.ssl-match-hostname>=3.5; python_version < "3.5" in /usr/lib/python2.7/site-packages (from docker-compose) Collecting requests!=2.11.0,!=2.12.2,!=2.18.0,<2.21,>=2.6.1 (from docker-compose) Downloading https://files.pythonhosted.org/packages/ff/17/5cbb026005115301a8fb2f9b0e3e8d32313142fe8b617070e7baad20554f/requests-2.20.1-py2.py3-none-any.whl (57kB) 100% |ââââââââââââââââââââââââââââââââ| 61kB 76kB/s Requirement already satisfied (use --upgrade to upgrade): six<2,>=1.3.0 in /usr/lib/python2.7/site-packages (from docker-compose) Requirement already satisfied (use --upgrade to upgrade): PyYAML<4.3,>=3.10 in /usr/lib64/python2.7/site-packages (from docker-compose) Collecting texttable<0.10,>=0.9.0 (from docker-compose) Downloading https://files.pythonhosted.org/packages/02/e1/2565e6b842de7945af0555167d33acfc8a615584ef7abd30d1eae00a4d80/texttable-0.9.1.tar.gz Collecting dockerpty<0.5,>=0.4.1 (from docker-compose) Downloading https://files.pythonhosted.org/packages/8d/ee/e9ecce4c32204a6738e0a5d5883d3413794d7498fe8b06f44becc028d3ba/dockerpty-0.4.1.tar.gz Requirement already satisfied (use --upgrade to upgrade): ipaddress>=1.0.16; python_version < "3.3" in /usr/lib/python2.7/site-packages (from docker-compose) Requirement already satisfied (use --upgrade to upgrade): websocket-client<1.0,>=0.32.0 in /usr/lib/python2.7/site-packages (from docker-compose) Requirement already satisfied (use --upgrade to upgrade): enum34<2,>=1.0.4; python_version < "3.4" in /usr/lib/python2.7/site-packages (from docker-compose) Collecting docopt<0.7,>=0.6.1 (from docker-compose) Downloading https://files.pythonhosted.org/packages/a2/55/8f8cab2afd404cf578136ef2cc5dfb50baa1761b68c9da1fb1e4eed343c9/docopt-0.6.2.tar.gz Collecting jsonschema<3,>=2.5.1 (from docker-compose) Downloading https://files.pythonhosted.org/packages/77/de/47e35a97b2b05c2fadbec67d44cfcdcd09b8086951b331d82de90d2912da/jsonschema-2.6.0-py2.py3-none-any.whl 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 Requirement already satisfied (use --upgrade to upgrade): docker-pycreds>=0.4.0 in /usr/lib/python2.7/site-packages (from docker[ssh]<4.0,>=3.7.0->docker-compose) Collecting paramiko>=2.4.2; extra == "ssh" (from docker[ssh]<4.0,>=3.7.0->docker-compose) Downloading https://files.pythonhosted.org/packages/4b/80/74dace9e48b0ef923633dfb5e48798f58a168e4734bca8ecfaf839ba051a/paramiko-2.6.0-py2.py3-none-any.whl (19 100% |ââââââââââââââââââââââââââââââââ| 204kB 72kB/s Collecting idna<2.8,>=2.5 (from requests!=2.11.0,!=2.12.2,!=2.18.0,<2.21,>=2.6.1->docker-compose) Downloading https://files.pythonhosted.org/packages/4b/2a/0276479a4b3caeb8a8c1af2f8e4355746a97fab05a372e4a2c6a6b876165/idna-2.7-py2.py3-none-any.whl (58kB) 100% |ââââââââââââââââââââââââââââââââ| 61kB 116kB/s Requirement already satisfied (use --upgrade to upgrade): chardet<3.1.0,>=3.0.2 100% |ââââââââââââââââââââââââââââââââ| 768kB 194kB/s Collecting bcrypt>=3.1.3 (from paramiko>=2.4.2; extra == "ssh"->docker[ssh]<4.0,>=3.7.0->docker-compose)ââââââââââââââ Downloading https://files.pythonhosted.org/packages/ad/36/9a0227d048e98409f012570f7bef8a8c2373b9c9c5dfbf82963cbae05ede/bcrypt-3.1.7-cp27-cp27mu-manylinux1_x86_64.whl (59kB)âââââââââââââââ 100% |ââââââââââââââââââââââââââââââââ| 61kB 92kB/s Collecting asn1crypto>=0.21.0 (from cryptography>=2.5->paramiko>=2.4.2; extra == "ssh"->docker[ssh]<4.0,>=3.7.0->docker-compose) Downloading https://files.pythonhosted.org/packages/ea/cd/35485615f45f30a510576f1a56d1e0a7ad7bd8ab5ed7cdc600ef7cd06222/asn1crypto-0.24.0-py2.py3-none-any.whl 100% |ââââââââââââââââââââââââââââââââ| 102kB 194kB/s Collecting cffi!=1.11.3,>=1.8 (from cryptography>=2.5->paramiko>=2.4.2; extra == 100% |ââââââââââââââââââââââââââââââââ| 419kB 250kB/s Requirement already satisfied (use --upgrade to upgrade): pycparser in /usr/lib/python2.7/site-packages (from cffi!=1.11.3,>=1.8->cryptography>=2.5->paramiko>=2.4.2; extra == "ssh"->docker[ssh]<4.0,>=3.7.0->docker-compose) Installing collected packages: idna, urllib3, requests, asn1crypto, cffi, cryptography, pynacl, bcrypt, paramiko, docker, texttable, dockerpty, docopt, functools32, jsonschema, cached-property, docker-compose Found existing installation: idna 2.8 Uninstalling idna-2.8: Successfully uninstalled idna-2.8 Found existing installation: urllib3 1.25.3 Uninstalling urllib3-1.25.3: Successfully uninstalled urllib3-1.25.3 Found existing installation: requests 2.22.0 Uninstalling requests-2.22.0: Successfully uninstalled requests-2.22.0 Found existing installation: cffi 1.6.0 Uninstalling cffi-1.6.0: Successfully uninstalled cffi-1.6.0 Found existing installation: cryptography 1.7.2 Uninstalling cryptography-1.7.2: Successfully uninstalled cryptography-1.7.2 Found existing installation: paramiko 2.1.1 Uninstalling paramiko-2.1.1: Successfully uninstalled paramiko-2.1.1 Running setup.py install for texttable ... done Running setup.py install for dockerpty ... done Running setup.py install for docopt ... done Running setup.py install for functools32 ... done Successfully installed asn1crypto-0.24.0 bcrypt-3.1.7 cached-property-1.5.1 cffi-1.12.3 cryptography-2.7 docker-3.7.3 docker-compose-1.24.1 dockerpty-0.4.1 docopt-0.6.2 functools32-3.2.3.post2 idna-2.7 jsonschema-2.6.0 paramiko-2.6.0 pynacl-1.3.0 requests-2.20.1 texttable-0.9.1 urllib3-1.24.3 You are using pip version 8.1.2, however version 19.2.3 is available. You should consider upgrading via the 'pip install --upgrade pip' command.

     

    Installing Ansible AWX on CentOS 7:

    Use git command to download AWX project from GitHub.

    [root@ansible-01 ~]# git clone --depth 50 https://github.com/ansible/awx.git Cloning into 'awx'... remote: Enumerating objects: 8850, done. remote: Counting objects: 100% (8850/8850), done. remote: Compressing objects: 100% (4428/4428), done. remote: Total 8850 (delta 5006), reused 6388 (delta 4234), pack-reused 0 Receiving objects: 100% (8850/8850), 11.30 MiB | 246.00 KiB/s, done. Resolving deltas: 100% (5006/5006), done.

    Go to ~/awx/installer directory and set a custom admin_password for AWX and PostgreSQL in inventory file.

    [root@ansible-01 ~]# cd awx/installer [root@ansible-01 installer]# sed -i 's|admin_password=.*|admin_password=Ahmer@1234|g' inventory

    Generate a random key to use for encryption in inventory file.

    [root@ansible-01 installer]# openssl rand -base64 30 ejv9P72oNvD4AtWLhOUTvpxfdIfKIid3skwuK+ES

    Add the generated string as secret_key in inventory file.

    [root@ansible-01 installer]# sed -i 's|secret_key=.*|secret_key=ejv9P72oNvD4AtWLhOUTvpxfdIfKIid3skwuK+ES|g' inventory

    You can also customize many directives here, according to your requirements.

    Verify the changes that we have made in inventory.

    [root@ansible-01 installer]# grep -v '^#' inventory | grep -v '^$' localhost ansible_connection=local ansible_python_interpreter="/usr/bin/env python" [all:vars] dockerhub_base=ansible awx_task_hostname=awx awx_web_hostname=awxweb postgres_data_dir=/tmp/pgdocker host_port=80 host_port_ssl=443 docker_compose_dir=/tmp/awxcompose pg_username=awx pg_password=awxpass pg_admin_password=Ahmer@1234 pg_database=awx pg_port=5432 rabbitmq_password=awxpass rabbitmq_erlang_cookie=cookiemonster admin_user=admin admin_password=Ahmer@1234 create_preload_data=True secret_key=ejv9P72oNvD4AtWLhOUTvpxfdIfKIid3skwuK+ES

    Install AWX by using ansible-playbook command.

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

    Ansible uses docker-compose to create the required containers by AWX. It will take time, according to your server's specs, therefore sit back and relax for a while.

    After successful configuration of AWX and relevant containers. You can check the list of Docker processes to the running containers that are created by docker-compose for AWX.

    [root@ansible-01 installer]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2c36037e1edf ansible/awx_task:7.0.0 "/tini -- /bin/sh -câ¦" 2 minutes ago Up 2 minutes 8052/tcp awx_task 4af8c2a57530 ansible/awx_web:7.0.0 "/tini -- /bin/sh -câ¦" 2 minutes ago Up 2 minutes 0.0.0.0:80->8052/tcp awx_web 5580f44da60a memcached:alpine "docker-entrypoint.sâ¦" 2 minutes ago Up 2 minutes 11211/tcp awx_memcached 341e0660e369 ansible/awx_rabbitmq:3.7.4 "docker-entrypoint.sâ¦" 2 minutes ago Up 2 minutes 4369/tcp, 5671-5672/tcp, 15671-15672/tcp, 25672/tcp awx_rabbitmq 6529a106ab89 postgres:10 "docker-entrypoint.sâ¦" 2 minutes ago Up 2 minutes 5432/tcp awx_postgres

    Allow HTTP service in Linux firewall, because the port 80 is mapped to the AWX container and it is used to access AWX web console.

    [root@ansible-01 installer]# firewall-cmd --permanent --add-service=http success [root@ansible-01 installer]# firewall-cmd --reload success

    Open URL http://ansible01.centlinux.com in a client's browser.

    01-ansible-awx-web-console-login

    Login as Admin User.

    02-ansible-awx-web-console-dashboard

    We are reached at the dashboard of Ansible AWX.

    We have successfully installed Ansible AWX with Docker-Compose on CentOS 7 server.

    18 comments:

    1. I don't know how you've managed to do this, but i don't believe it is that simple...

      The ansible docker-compose module only works when running with ansible python interpreter set to python3.
      But there is no libselinux-python available under python3, so docker-compose may work but then nothing else does... even the copy file module fails.

      ReplyDelete
      Replies
      1. Yes you need to install the Python3 interpreter, which also installs pip3.
        Make sure to set the python interpreter to python3, by default python2 is picked up.
        After you have installed python3, edit the first line of the inventory file and replace python by python3, see below:
        localhost ansible_connection=local ansible_python_interpreter="/usr/bin/env python3"
        Also make sure to replace all pip commands by pip3 (e.g. pip3 install ...).

        Delete
    2. Hi, after installation the login page compains abount missing license with the following message:
      "Failed to access license information. GET returned status:"

      How can I solve this?
      Thanks

      ReplyDelete
      Replies
      1. Please check the permissions on project directory.

        Delete
      2. Was trying to find the project directory at the default location (/var/lib/awx/project) which I am not able to find. I am getting the same error.

        Delete
      3. You should find the installation directory of AWX, the project directory is located therein.

        Delete
    3. Hi, after installation i got the error "This site can’t be reached192.168.1.14 refused to connect." Please help.

      ReplyDelete
      Replies
      1. Hi, Please ensure that the port 80/tcp is allowed in Linux firewall.

        Delete
      2. Hi,

        we have to allow port on container where application is running. Or on host machine where docker is installed.

        Delete
    4. Hey, I'm getting the following error when running the playbook:

      LAYBOOK: install.yml **********************************************************************************************
      1 plays in install.yml

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

      TASK [Gathering Facts] *********************************************************************************************
      task path: /root/awx/installer/install.yml:2
      fatal: [localhost]: FAILED! => {"ansible_facts": {}, "changed": false, "failed_modules": {"setup": {"failed": true, "module_stderr": "/usr/bin/env: ‘python’: 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

      ReplyDelete
    5. Hi,

      Follow all the step to install ansible awx.
      Please is there any post installation step not mention in document.

      Because i have checked log of awx_web it showing error.

      ile "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/base/base.py", line 195, in connect
      self.connection = self.get_new_connection(conn_params)
      File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/backends/postgresql/base.py", line 178, in get_new_connection
      connection = Database.connect(**conn_params)
      File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/psycopg2/__init__.py", line 126, in connect
      conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
      django.db.utils.OperationalError: could not connect to server: No route to host
      Is the server running on host "postgres" (172.18.0.2) and accepting
      TCP/IP connections on port 5432?

      [pid: 128|app: 0|req: 1/1] 172.18.0.1 () {40 vars in 594 bytes} [Fri Dec 6 12:41:58 2019] GET / => generated 3868 bytes in 60299 msecs (HTTP/1.1 500) 2 headers in 105 bytes (1 switches on core 0)

      ReplyDelete
      Replies
      1. Please ensure that network configurations are correct. Also allow the service port 5432/tcp in Linux firewall.

        Delete
    6. Trying to install this on an Azure based Redhat 7.7 Linux server I am stopped in the tracks with the Python.h not found issue during 'pip install docker-compose'. Please advise.



      # pip install docker-compose
      gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -c _posixsubprocess.c -o build/temp.linux-x86_64-2.7/_posixsubprocess.o
      _posixsubprocess.c:16:20: fatal error: Python.h: No such file or directory
      #include "Python.h"
      ^
      compilation terminated.
      error: command 'gcc' failed with exit status 1

      ----------------------------------------
      Command "/usr/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-H_YEOZ/subprocess32/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-K0G6jz-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-H_YEOZ/subprocess32/

      ReplyDelete
      Replies
      1. Install "Development Tools" group to rectify this error.

        # yum groupinstall 'Development Tools' -y

        Delete
    7. Hi Ahmer,

      I'm getting below error when checking logs by using below command.
      # docker logs -f awx_web

      [root@ansible installer]# docker logs -f awx_web
      Using /etc/ansible/ansible.cfg as config file
      Using /etc/ansible/ansible.cfg as config file
      127.0.0.1 | FAILED! => {
      "ansible_facts": {
      "discovered_interpreter_python": "/usr/libexec/platform-python"
      },
      "changed": false,
      "elapsed": 301,
      "msg": "Timeout when waiting for postgres:5432"
      }
      Using /etc/ansible/ansible.cfg as config file
      127.0.0.1 | FAILED! => {
      "ansible_facts": {
      "discovered_interpreter_python": "/usr/libexec/platform-python"
      },
      "changed": false,
      "elapsed": 301,
      "msg": "Timeout when waiting for memcached:11211"
      }
      Using /etc/ansible/ansible.cfg as config file
      127.0.0.1 | FAILED! => {
      "ansible_facts": {
      "discovered_interpreter_python": "/usr/libexec/platform-python"
      },
      "changed": false,
      "elapsed": 301,
      "msg": "Timeout when waiting for rabbitmq:5672"
      }
      Using /etc/ansible/ansible.cfg as config file
      An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TCP/IP connections on port 5432?
      127.0.0.1 | FAILED! => {
      "ansible_facts": {
      "discovered_interpreter_python": "/usr/libexec/platform-python"
      },
      "changed": false,
      "msg": "unable to connect to database: could not connect to server: No route to host\n\tIs the server running on host \"postgres\" (172.18.0.4) and accepting\n\tTCP/IP connections on port 5432?\n"

      [root@ansible installer]# docker ps
      CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
      c93de51cd98d ansible/awx_task:9.0.1 "/tini -- /bin/sh -c…" 41 minutes ago Up 38 minutes 8052/tcp awx_task
      1ec2fa798ce2 ansible/awx_web:9.0.1 "/tini -- /bin/sh -c…" 41 minutes ago Up 38 minutes 0.0.0.0:80->8052/tcp awx_web
      2fbcd374a979 ansible/awx_rabbitmq:3.7.4 "docker-entrypoint.s…" 41 minutes ago Up 38 minutes 4369/tcp, 5671-5672/tcp, 15671-15672/tcp, 25672/tcp awx_rabbitmq
      28ce2cb6254c memcached:alpine "docker-entrypoint.s…" 41 minutes ago Up 38 minutes 11211/tcp awx_memcached
      44a2c03709be postgres:10 "docker-entrypoint.s…" 41 minutes ago Up 38 minutes 5432/tcp awx_postgres


      regards,
      Rahul Rawat

      ReplyDelete
      Replies
      1. Please check you network configurations. It looks like that either your address isn't resolvable or there isn't any route defined.

        Delete