0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

AWXインストールメモ20190904(自分用)

Last updated at Posted at 2020-10-30

[参考]
Ansible AWXをインストールしてみる
https://qiita.com/nakacya/items/b80575210d2168284d89

awxを構築するために、以下を事前準備する必要。

Docker、docker-py、ansible、git、Node.js、npm、GNU Make

Docker CEインストール

[root@CentOS7 ~]# yum install -y yum-utils device-mapper-persistent-data lvm2 git
[root@CentOS7 ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
[root@CentOS7 ~]# yum install -y docker-ce docker-ce-cli containerd.io
[root@CentOS7 ~]# docker --version
Docker version 19.03.2, build 6a30dfc

docker-pyインストール

[root@CentOS7 ~]# yum -y install epel-release
[root@CentOS7 ~]# yum -y install python-pip
[root@CentOS7 ~]# pip -V
pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)
[root@CentOS7 ~]# python -V
Python 2.7.5

[root@CentOS7 ~]# pip install docker
[root@CentOS7 ~]# pip install --upgrade pip
[root@CentOS7 ~]# pip -V
pip 19.2.3 from /usr/lib/python2.7/site-packages/pip (python 2.7)

ansibleインストール

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

Node.js、npm インストール

最新版12.X導入

[root@CentOS7 ~]# curl -sL https://rpm.nodesource.com/setup_12.x | bash -
[root@CentOS7 ~]# yum install -y nodejs
[root@CentOS7 ~]# yum install -y gcc-c++ make
[root@CentOS7 ~]# npm -v
6.10.2

OS再起動

[root@CentOS7 ~]# reboot

awxインストール

git cloneを実行し、inventoryファイルなどをコピーする。

awx環境 は ansible により構築される。。すばらしいですね。

[root@CentOS7 ~]# git clone https://github.com/ansible/awx

awx設定(inventoryファイル)の変更

httpsでのアクセスを想定し、portを443へ変更

変更前

[root@CentOS7 ~]# egrep -v '^#' awx/installer/inventory | egrep -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_database=awx
pg_port=5432
rabbitmq_password=awxpass
rabbitmq_erlang_cookie=cookiemonster
admin_user=admin
admin_password=password
create_preload_data=True
secret_key=awxsecret

変更後

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=/pgdocker     <= 変更
host_port=443                       <= 変更
host_port_ssl=443
docker_compose_dir=/var/lib/awx
pg_username=awx
pg_password=awxpass
pg_database=awx
pg_port=5432
rabbitmq_password=awxpass
rabbitmq_erlang_cookie=cookiemonster
admin_user=admin
admin_password=password
create_preload_data=True
secret_key=awxsecret
project_data_dir=/var/lib/awx/projects

python3系の導入

このまま "ansible-playbook"ではpythonが古いとエラーになるので、、、

1. ライブラリのインストール
[root@CentOS7 ~]# yum -y install gcc zlib-devel bzip2 bzip2-devel readline readline-devel sqlite sqlite-devel openssl openssl-devel
2. pyenv installerのインストール
[root@CentOS7 ~]# curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
3. 以下環境変数を設定
[root@CentOS7 ~]# cat << 'EOS' >> ~/.bash_profile
export PATH="/root/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
EOS

[root@CentOS7 ~]# source ~/.bash_profile

[root@CentOS7 ~]# pyenv
pyenv 1.2.13
Usage: pyenv <command> [<args>]

Some useful pyenv commands are:
   commands    List all available pyenv commands
   local       Set or show the local application-specific Python version
   global      Set or show the global Python version
   shell       Set or show the shell-specific Python version
   install     Install a Python version using python-build
   uninstall   Uninstall a specific Python version
   rehash      Rehash pyenv shims (run this after installing executables)
   version     Show the current Python version and its origin
   versions    List all Python versions available to pyenv
   which       Display the full path to an executable
   whence      List all Python versions that contain the given executable

See `pyenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/pyenv/pyenv#readme
4. Python3系のインストール

python 3.6.9 を導入しておく

[root@CentOS7 ~]# pyenv install 3.6.9
Downloading Python-3.6.9.tar.xz...
-> https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tar.xz
Installing Python-3.6.9...
Installed Python-3.6.9 to /root/.pyenv/versions/3.6.9
5. インストールしたPythonを使用するように設定
[root@CentOS7 ~]# pyenv global 3.6.9
6. インストールされているPythonの一覧を表示
[root@CentOS7 ~]# pyenv versions
  system
* 3.6.9 (set by /root/.pyenv/version)
7. docker-compose もインストール
[root@CentOS7 ~]# pip install docker-compose
pipもupdateしちゃう
[root@CentOS7 ~]# pip install --upgrade pip
8. docker を再起動
[root@CentOS7 ~]# systemctl start docker
[root@CentOS7 ~]# systemctl status docker
[root@CentOS7 ~]# systemctl enable docker
playbook実行

"failed=0"ならOK?

[root@CentOS7 ~]# cd awx/installer/
[root@CentOS7 installer]# ansible-playbook -i inventory install.yml
:
localhost  : ok=11   changed=6    unreachable=0    failed=0    skipped=78   rescued=0    ignored=0
dockerコンテナがデプロイされていることを確認する。
[root@CentOS7 installer]# docker ps
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                                                 NAMES
c350d9a09932        ansible/awx_task:6.1.0       "/tini -- /bin/sh -c…"   2 minutes ago       Up 2 minutes        8052/tcp                                              awx_task
c17cbebd6ae4        ansible/awx_web:6.1.0        "/tini -- /bin/sh -c…"   2 minutes ago       Up 2 minutes        0.0.0.0:443->8052/tcp                                 awx_web
dcaab07cd9ee        ansible/awx_rabbitmq:3.7.4   "docker-entrypoint.s…"   3 minutes ago       Up 2 minutes        4369/tcp, 5671-5672/tcp, 15671-15672/tcp, 25672/tcp   awx_rabbitmq
68282f1f06d0        postgres:9.6                 "docker-entrypoint.s…"   3 minutes ago       Up 2 minutes        5432/tcp                                              awx_postgres
8937c59f7a37        memcached:alpine             "docker-entrypoint.s…"   3 minutes ago       Up 2 minutes        11211/tcp                                             awx_memcached
awx_webコンテナ内にアクセスする。
[root@CentOS7 installer]# docker exec -i -t c17cbebd6ae4 /bin/bash
bash-4.2#
/etc/nginxディレクトリ直下に証明書用の新ディレクトリを作成
bash-4.2# cd /etc/nginx
bash-4.2# pwd
/etc/nginx
bash-4.2# mkdir certs
bash-4.2# cd certs
bash-4.2# pwd
/etc/nginx/certs
証明書の作成
bash-4.2# openssl genrsa -out server.key 2048
bash-4.2# openssl rsa -in server.key -out server.key
bash-4.2# openssl req -sha256 -new -key server.key -out server.csr -subj '/CN=awx.bc.googleusercontent.com'
bash-4.2# openssl x509 -req -sha256 -days 3650 -in server.csr -signkey server.key -out  server.crt
bash-4.2# ls
server.crt  server.csr  server.key
nginxの設定ファイルを編集
bash-4.2# cd /etc/nginx
bash-4.2# vi nginx.conf

以下行を修正、追記する

     43         server_name centos7.local;
     44         keepalive_timeout 65;
     45         ssl_certificate           /etc/nginx/certs/server.crt;
     46         ssl_certificate_key       /etc/nginx/certs/server.key;
     47         ssl on;
     48         ssl_session_cache  builtin:1000  shared:SSL:10m;
     49         ssl_protocols TLSv1.2;
     50         ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
     51         ssl_prefer_server_ciphers on;
awx_webコンテナを再起動
[root@CentOS7 installer]# docker ps
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                                                 NAMES
c17cbebd6ae4        ansible/awx_web:6.1.0        "/tini -- /bin/sh -c…"   16 minutes ago      Up 16 minutes       0.0.0.0:443->8052/tcp                                 awx_web

[root@CentOS7 installer]# docker restart c17cbebd6ae4
c17cbebd6ae4
[root@CentOS7 installer]#
https://【IPアドレス】

192.168.56.103_.png

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?