Installation practice of ansible UI management tool awx

Environmental Instructions:

host name os version ip docker version docker-compose version ansible version awx version Remarks
ansible-awx Centos 7.6.1810 172.27.34.50 Docker 19.03.9 1.25.5 2.9.9 10.0.0 Manage Nodes
centos01 Centos 7.6.1810 172.27.34.28 × × × × Managed Node
centos02 Centos 7.6.1810 172.27.34.35 × × × × Managed Node
centos03 Centos 7.3.1611 172.27.34.161 × × × × Managed Node

 

1. Introduction

Introduction to ansible

Ansible is a very simple IT automation platform that makes programs and systems easier to deploy.Ansible is essentially an encapsulated Shell. The advantage is that it is a de-centralized tool that enables Agent-free deployment by managing remote hosts directly through ssh.

Introduction to AWX

AWX provides a web-based user interface, REST API, and task engine built on Ansible.Graphical AWX makes it easier to organize and deploy Ansible Playbook and provides centralized logging, auditing, and system tracking.AWX is an open source version of the commercial version of Ansible Tower.

awx project address: https://github.com/ansible/awx/

2. ansible Installation

1. Install EPEL source

[root@ansible-awx ~]# yum -y install epel-release

2. Install asnible

[root@ansible-awx ~]# yum -y install ansible

Default to the latest version

[root@ansible-awx ~]# ansible --version

3. Doker Installation

1. Install dependent packages

[root@ansible-awx ~]# yum install -y yum-utils   device-mapper-persistent-data   lvm2

2. Set docker source

[root@ansible-awx ~]# yum-config-manager     --add-repo     https://download.docker.com/linux/centos/docker-ce.repo

Doker Installation Version View

3. Install docker

[root@ansible-awx ~]# yum install -y docker-ce docker-ce-cli containerd.io

No version specified, default to latest version

4. Start docker

[root@ansible-awx ~]# systemctl start docker
[root@ansible-awx ~]# systemctl enable docker

5. Command Completion

5.1 Install bash-completion

[root@ansible-awx ~]# yum -y install bash-completion

5.2 Load bash-completion

[root@ansible-awx ~]# source /etc/profile.d/bash_completion.sh

6. Mirror Acceleration

Since Docker Hub's servers are abroad, downloading mirrors is slower and mirroring accelerators can be configured.The main accelerators are: Docker officially provided China registry mirror, Ali cloud accelerator, DaoCloud accelerator. This article takes Ali accelerator configuration as an example.

6.1 Landing Ali Cloud Container Module

The landing address is: https://cr.console.aliyun.com , unregistered can register Aliyun account first

6.2 Configure Mirror Accelerator

To configureDaemon.jsonfile

[root@centos7 ~]# mkdir -p /etc/docker
[root@centos7 ~]# tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://v16stybc.mirror.aliyuncs.com"]
}
EOF

Restart Service

[root@centos7 ~]# systemctl daemon-reload
[root@centos7 ~]# systemctl restart docker


Accelerator Configuration Complete

4. Install Python modules

1. Install pip3

[root@ansible-awx ~]# yum -y install python3-pip

2. Install the Python module of docker-compose

[root@ansible-awx ~]# pip3 install docker-compose

Due to network reasons, the installation process may fail, just try twice more.

5. Install Docker Compose

1. Download binaries

Download address for each version: https://github.com/docker/compose/releases

[root@ansible-awx ~]# curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

2. Entitlement

[root@ansible-awx ~]# chmod +x /usr/local/bin/docker-compose

3. Installation verification

[root@ansible-awx ~]# docker-compose --version
docker-compose version 1.25.5, build 8a1c60f6

6. awx installation

1. Download awx

awx download address: https://github.com/ansible/awx/releases For this article, version 10.0.0 is selected

[root@ansible-awx ~]# wget https://github.com/ansible/awx/archive/10.0.0.tar.gz

decompression

[root@ansible-awx ~]# wget https://github.com/ansible/awx/archive/10.0.0.tar.gz
[root@ansible-awx ~]# ll
//Total usage 10736
-rw-r--r--   1 root root 10983696 5 21/14:36 10.0.0.tar.gz
-rw-------.  1 root root     1322 5 21/11/2:43 anaconda-ks.cfg
drwxrwxr-x  11 root root     4096 3 Month 3100:42 awx-10.0.0

2. Modify Configuration

[root@ansible-awx ~]# cd awx-10.0.0/installer/
[root@ansible-awx installer]# ll
//Total usage 16
-rw-rw-r-- 1 root root  167 3 Month 3100:42 build.yml
-rw-rw-r-- 1 root root  437 3 Month 3100:42 install.yml
-rw-rw-r-- 1 root root 6131 3 Month 3100:42 inventory
drwxrwxr-x 7 root root   99 3 Month 3100:42 roles
[root@ansible-awx installer]# sed -i.bak 's/env python/env python3/g' inventory
[root@ansible-awx installer]# ll
//Total usage 24
-rw-rw-r-- 1 root root  167 3 Month 3100:42 build.yml
-rw-rw-r-- 1 root root  437 3 Month 3100:42 install.yml
-rw-rw-r-- 1 root root 6132 5 21/14:41 inventory
-rw-rw-r-- 1 root root 6131 3 Month 3100:42 inventory.bak
drwxrwxr-x 7 root root   99 3 Month 3100:42 roles

Modify the configuration file inventory, use python3, and leave the other configuration as default.

3. Download Mirror

3.1 Mirror Download

[root@ansible-awx ~]# docker pull registry.cn-hangzhou.aliyuncs.com/loong576/awx_web:10.0.0
[root@ansible-awx ~]# docker pull registry.cn-hangzhou.aliyuncs.com/loong576/awx_task:10.0.0
[root@ansible-awx ~]# docker pull registry.cn-hangzhou.aliyuncs.com/loong576/memcached:alpine
[root@ansible-awx ~]# docker pull registry.cn-hangzhou.aliyuncs.com/loong576/postgres:10
[root@ansible-awx ~]# docker pull registry.cn-hangzhou.aliyuncs.com/loong576/redis

The components of awx are installed in containers and the corresponding version of the image is downloaded separately. The image download will take some time. Please keep the network environment stable.

3.2 tag

[root@ansible-awx ~]# docker tag registry.cn-hangzhou.aliyuncs.com/loong576/awx_task:10.0.0 ansible/awx_task:10.0.0
[root@ansible-awx ~]# docker tag registry.cn-hangzhou.aliyuncs.com/loong576/awx_web:10.0.0 ansible/awx_web:10.0.0 
[root@ansible-awx ~]# docker tag registry.cn-hangzhou.aliyuncs.com/loong576/redis redis
[root@ansible-awx ~]# docker tag registry.cn-hangzhou.aliyuncs.com/loong576/postgres:10 postgres:10 
[root@ansible-awx ~]# docker tag registry.cn-hangzhou.aliyuncs.com/loong576/memcached:alpine memcached:alpine 

3.3 Remove unwanted mirrors

[root@ansible-awx ~]# docker rmi registry.cn-hangzhou.aliyuncs.com/loong576/awx_web:10.0.0 registry.cn-hangzhou.aliyuncs.com/loong576/redis registry.cn-hangzhou.aliyuncs.com/loong576/postgres:10 registry.cn-hangzhou.aliyuncs.com/loong576/memcached:alpine

3.4 Mirror Viewing

[root@ansible-awx ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
redis               latest              987b78fc9e38        2 days ago          104MB
postgres            10                  d92854c53ed1        5 days ago          200MB
memcached           alpine              35acd9837d07        7 days ago          9.28MB
ansible/awx_task    10.0.0              a968a1c4d9fd        7 weeks ago         2GB
ansible/awx_web     10.0.0              2cc33f01ffa7        7 weeks ago         1.96GB

4.awx Installation

[root@ansible-awx installer]# pwd
/root/awx-10.0.0/installer
[root@ansible-awx installer]# ansible-playbook -i inventory install.yml

Container View

[root@ansible-awx ~]# docker ps
CONTAINER ID        IMAGE                     COMMAND                  CREATED             STATUS              PORTS                  NAMES
6cbcc91766c2        ansible/awx_task:10.0.0   "/tini -- /bin/sh -c..."   2 hours ago         Up About an hour    8052/tcp               awx_task
d5b698ef603f        ansible/awx_web:10.0.0    "/tini -- /bin/sh -c..."   2 hours ago         Up About an hour    0.0.0.0:80->8052/tcp   awx_web
20f9e95f0c1c        postgres:10               "docker-entrypoint.s..."   2 hours ago         Up About an hour    5432/tcp               awx_postgres
35133c5b8b5f        redis                     "docker-entrypoint.s..."   2 hours ago         Up About an hour    6379/tcp               awx_redis
93d2bd24b6c5        memcached:alpine          "docker-entrypoint.s..."   2 hours ago         Up About an hour    11211/tcp              awx_memcached

7. Log on to awx

Landing address: http://172.27.34.50

Enter the user name admin with password as the default password

8. awx Practice

Add List

List name is test area

Create Host

Added hosts 172.27.34.28/35/161 respectively, specifying logon user and password

Host Added Complete

Execute Command

View each hosted user

Parameters are: cat/etc/passwd|grep-v'nologin|shutdown|sync|halt'|awk-F:'{print $1}'

Command Execution Completed

 

 

All media and configuration files for this article have been uploaded: ansible-awx

Keywords: Linux ansible Docker yum github

Added by skiingguru1611 on Thu, 21 May 2020 20:34:51 +0300