Howto awx

From Vidalinux Wiki
Jump to navigation Jump to search

setup centos7 vm

install virt-customize:

yum -y install /usr/bin/virt-customize

download centos7 cloud image:

wget https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2.xz

resize image:

qemu-img resize CentOS-7-x86_64-GenericCloud.qcow2 20G

change root password on image:

virt-customize -a CentOS-7-x86_64-GenericCloud.qcow2 --root-password password:mypassword

remove cloud-init package from image:

virt-customize -a CentOS-7-x86_64-GenericCloud.qcow2 --uninstall cloud-init

convert image to vmware:

qemu-img convert -f qcow2 -O vmdk CentOS-7-x86_64-GenericCloud.qcow2 CentOS-7-x86_64-GenericCloud.vmdk -p

install docker

update your os to latest:

yum -y update

install epel repo:

yum -y install epel-release

install packages:

yum -y install yum-utils device-mapper-persistent-data lvm2 git wget ansible

configure the docker-ce repo:

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

install docker-ce:

yum -y install docker-ce

add your user to the docker group with the following command.

usermod -aG docker $(whoami)

set docker to start automatically at boot time:

systemctl enable docker.service

start the docker service:

systemctl start docker.service

install docker compose:

pip install docker-compose==1.23

install awx

git clone awx repository:

git clone https://github.com/ansible/awx.git

generate the new secret key for the awx using the openssl:

openssl rand -hex 32

results should be something like this:

5544f492ba3708caeb58e0d34d67c4a8b429efb9fa0c54e2fa1798d03dc44127

edit intentory:

cd awx/installer/
vi inventory

change the following settings:

secret_key=5544f492ba3708caeb58e0d34d67c4a8b429efb9fa0c54e2fa1798d03dc44127
pg_password=awxpass
pg_database=awx
pg_port=5432
rabbitmq_password=awxpass
admin_user=admin
admin_password="password"
project_data_dir=/var/lib/awx/projects

use ansible to complete installation:

ansible-playbook -i inventory install.yml

backup and restore

backup postgres database:

docker exec -i awx_postgres pg_dump -h postgres -U awx awxdb > backup-awx-$(date +%F).sql

erase all tables without removing database:

docker exec -it awx_postgres bash
PGPASSWORD='awxpass' psql -h postgres -U awx awx -t -c "select 'drop table \"' || tablename || '\" cascade;' from pg_tables where schemaname='public'" | psql -h postgres -U awx awx

restore postgres database:

docker cp backup-awx-2020-02-21.sql awx_postgres:/
docker exec -i awx_postgres psql -h postgres -U awx -f /backup-awx-2020-02-21.sql awxdb

edit /root/.awx/awxcompose/environment.sh for changes:

DATABASE_USER=awx
DATABASE_NAME=awx
DATABASE_HOST=postgres
DATABASE_PORT=5432
DATABASE_PASSWORD=awxpass
MEMCACHED_HOST=memcached
MEMCACHED_PORT=11211
RABBITMQ_HOST=rabbitmq
RABBITMQ_PORT=5672
AWX_ADMIN_USER=admin
AWX_ADMIN_PASSWORD=password

if you have contents on /var/lib/awx/projects copy then to new host:

scp -r MY_Project/ root@192.168.25.1:/var/lib/awx/projects/

restart docker environment:

cd ~/.awx/awxcompose
docker-compose down
docker-compose up -d

check logs for errors:

docker-compose logs -f

kubernetes

install operator:

kubectl apply -f https://raw.githubusercontent.com/geerlingguy/tower-operator/master/deploy/tower-operator.yaml

ssl

add ssl config to /root/.awx/awxcompose/ngnix.conf:

       ssl on;
       ssl_certificate /etc/nginx/server.crt;
       ssl_certificate_key /etc/nginx/server.key;
       ssl_protocols TLSv1.2;
       ssl_ciphers HIGH:!aNULL:!MD5;

add this volumes to awx_web edit /root/.awx/awxcompose/docker-compose.yml:

- "~/.awx/awxcompose/nginx.conf:/etc/nginx/nginx.conf:ro"
- "~/.awx/awxcompose/server.crt:/etc/nginx/server.crt:ro"
- "~/.awx/awxcompose/server.key:/etc/nginx/server.key:ro"

change port 80 to 443 in /root/.awx/awxcompose/docker-compose.yml:

ports:
  - "443:8052"

restart environment:

cd /root/.awx/awxcompose/
docker-compose down
docker-compose up -d

references