Ansible : Instalando AWX / Tower

Ansible AWX é um projeto upstream do projeto oficial Ansible Tower da Redhat onde nos permite controlar melhor o uso do projeto Ansible fornecendo uma interface web e uma série de recursos para escalar o uso e produtividade.

Sobre o Ansible temos alguns exemplos de uso :

1) AWX Componentes:

  • postgres  – Database
  • rabbitmq – Message Queue
  • memcached – General-Purpose Distributed Memory Caching system
  • awx_web  – This image should be deployed together with ansible/awx_task
  • awx_task – This image should be deployed together with ansible/awx_web

No link abaixo temos o requisitos de hardware para a instalação :

https://docs.ansible.com/ansible-tower/latest/html/installandreference/requirements_refguide.html

2) Requisitos

Instale o repositório epel

yum install -y epel-release 

Instale os requisitos para o Docker CE

yum install -y yum-utils device-mapper-persistent-data lvm2 jq

Instale o Docker CE , inicie e habilite no boot.

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum -y install docker-ce
systemctl enable docker && systemctl start docker

Instale a última versão do Docker compose

export LATEST_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | jq -r '.tag_name')
curl -L "https://github.com/docker/compose/releases/download/$LATEST_VERSION/docker-compose-$(uname -s)-$(uname -m)" > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

Instale as dependências do Ansible AWX

yum update -y
yum install -y epel-release
yum install -y python-pip python-devel gcc ansible 
pip install --upgrade pip

pip install docker-compose
docker-compose --version

3) Configuração

Baixe o AWX a partir do repositório oficial

[root@awx ~]# git clone  https://github.com/ansible/awx.git
Cloning into 'awx'...
remote: Enumerating objects: 37, done.
remote: Counting objects: 100% (37/37), done.
remote: Compressing objects: 100% (35/35), done.
remote: Total 228823 (delta 16), reused 5 (delta 2), pack-reused 228786
Receiving objects: 100% (228823/228823), 222.55 MiB | 12.08 MiB/s, done.
Resolving deltas: 100% (176889/176889), done.

Entre no path abaixo.

[root@awx installer]# cd awx/installer

Na configuração abaixo descomentamos apenas a opção project_data_dir=/var/lib/awx/projects.

[root@awx installer]# cat inventory |grep -v "#" |sort -nr |grep .

secret_key=awxsecret
rabbitmq_password=awxpass
rabbitmq_erlang_cookie=cookiemonster
project_data_dir=/var/lib/awx/projects
postgres_data_dir="~/.awx/pgdocker"
pg_username=awx
pg_port=5432
pg_password=awxpass
pg_database=awx
localhost ansible_connection=local ansible_python_interpreter="/usr/bin/env pyton"
host_port_ssl=443
host_port=80
dockerhub_base=ansible
docker_compose_dir="~/.awx/awxcompose"
create_preload_data=True
awx_web_hostname=awxweb
awx_task_hostname=awx
[all:vars]
admin_user=admin
admin_password=password

Para evitarmos o erro abaixo, vamos atualizar o inventário com a linha :

#localhost ansible_connection=local ansible_python_interpreter="/usr/bin/env pyton"
localhost ansible_connection=local ansible_python_interpreter="/usr/bin/env pyton3"

Erro :

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 localhost.localdomain's Python /usr/bin/python. Pl
ease read module documentation and install in the appropriate location. If the required library is installed, but A
nsible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter, for e
xample via `pip install docker` or `pip install docker-py` (Python 2.6). The error was: No module named requests.ex
ceptions"}

Execute a instalação

 ansible-playbook -i inventory install.yml 

Após a execução podemos ver o containers ativos :

Acesse no browser o ip ou nome do host:

Nos próximos posts será criado como criar projetos , usuários , inventários e jobs.

Translate »