Red Hat の杉村です。Ansible のテクニカルサポートエンジニアをしています。
Ansible Tower は upstream のプロジェクトとして開発されている AWX を元にしています。本記事では、AWX をインストールしてみた記録を紹介しようと思います。AWX についてはこちらをご覧ください。

AWX Project https://github.com/ansible/awx
Minishift のインストールと設定
AWX はコンテナで動作します。インストールできる環境としては OpenShift, Kubernetes と Docker Compose がインストールドキュメントに記載されていますので、お気軽に試せる OpenShift の単一ノード版の Minishift を使ってみることにしました。macOS Mojave (10.14.4) + VirtualBox 6.0.4 で動かしてみましたが、他の環境の方は適宜読み替えてみてください。
macOS では brew から簡単にインストールすることができます。
$ brew cask install minishift … $ minishift version minishift v1.33.0+ba29431
VirtualBox もインストールしておいてください。VirtualBox で CentOS 7 が起動され、その中で Minishift が動作するようになっています。
起動前に VM の設定をします。CPU は 4core、メモリは 16GB 割り振ってみました。
$ minishift config set vm-driver virtualbox $ minishift config set cpus 4 $ minishift config set memory 16gb $ minishift addons install --defaults $ minishift addons enable admin-user
設定を確認します。
$ minishift config view - cpus : 4 - memory : 16gb - vm-driver : virtualbox $ minishift addons list - admin-user : enabled P(0) - admissions-webhook : disabled P(0) - anyuid : disabled P(0) - che : disabled P(0) - htpasswd-identity-provider : disabled P(0) - redhat-registry-login : disabled P(0) - registry-route : disabled P(0) - xpaas : disabled P(0)
きちんと設定できていれば起動しましょう。ISO ファイルの取得などもありまして時間がかかります。
$ minishift start
minishift start
-- Starting profile 'minishift'
-- Check if deprecated options are used ... OK
-- Checking if https://github.com is reachable ... OK
-- Checking if requested OpenShift version 'v3.11.0' is valid ... OK
-- Checking if requested OpenShift version 'v3.11.0' is supported ... OK
-- Checking if requested hypervisor 'virtualbox' is supported on this platform ... OK
-- Checking if VirtualBox is installed ... OK
-- Checking the ISO URL ... OK
-- Checking if provided oc flags are supported ... OK
-- Starting the OpenShift cluster using 'virtualbox' hypervisor ...
-- Starting Minishift VM ......................... OK
-- Checking for IP address ... OK
-- Checking for nameservers ... OK
-- Checking if external host is reachable from the Minishift VM ...
Pinging 8.8.8.8 ... OK
-- Checking HTTP connectivity from the VM ...
Retrieving http://minishift.io/index.html ... OK
-- Checking if persistent storage volume is mounted ... OK
-- Checking available disk space ... 16% used OK
-- Writing current configuration for static assignment of IP address ... OK
-- OpenShift cluster will be configured with ...
Version: v3.11.0
-- Copying oc binary from the OpenShift container image to VM ... OK
-- Starting OpenShift cluster ................................
…
I0402 04:28:53.052106 5652 interface.go:41] Finished installing "openshift-controller-manager"
Adding default OAuthClient redirect URIs ...
Adding centos-imagestreams ...
Adding router ...
Adding registry ...
Adding sample-templates ...
Adding persistent-volumes ...
Adding web-console ...
I0402 04:28:53.062807 5652 interface.go:26] Installing "centos-imagestreams" ...
…
I0402 04:29:07.271715 5652 interface.go:41] Finished installing "centos-imagestreams" "openshift-router" "openshift-image-registry" "sample-templates" "persistent-volumes" "openshift-web-console-operator"
Server Information ...
OpenShift server started.
The server is accessible via web console at:
https://192.168.99.101:8443/console
無事起動できました。ここで表示されたURLに admin/admin でアクセスしてみてください。

ここでは developer ユーザで AWX のインストールをするようにしたいと思います。権限を付与します。developer ユーザも最初から作られており、パスワードは任意の文字列になっています。いまは手元だけの環境なので特に設定していませんが、必要があればきちんと設定してください。
$ oc login -u admin -p admin --as=system:admin $ oc adm policy add-cluster-role-to-user cluster-admin developer --as=system:admin
Minishift にプロジェクトを作ります。
$ oc new-project awx $ oc project awx Now using project "awx" on server "https://192.168.99.101:8443".
DB 用にストレージを用意します。pvc.yml ファイルを作ります。
apiVersion: "v1" kind: "PersistentVolumeClaim" metadata: name: "postgresql" spec: accessModes: - "ReadWriteMany" resources: requests: storage: "20Gi" volumeName: pv0001
このファイルを適用して作ります。
$ oc create -f pvc.yml $ oc get pvc NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE postgresql Bound pv0001 100Gi RWO,ROX,RWX 10s
これで準備は完了です。
AWX のインストール
いよいよ本命 AWX のインストールをしていきます。執筆時点での最新リリースバージョンである 4.0.0 を指定しました。
$ git clone https://github.com/ansible/awx.git $ cd awx $ git checkout 4.0.0 $ cd installer $ cp inventory inventory.orig
インストール先の情報を inventory ファイルに設定していきます。IPアドレスは minishift ip コマンドでわかります。openshift_token は、developer でログインして、右上の Copy Login Command から取得してください。コピーしてターミナルなどにペーストすると、このように文字列が出てくるようになっています。
oc login https://192.168.99.101:8443 --token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

これまで得た情報を元に、inventory ファイルを編集します。コメント行も多いですが、実際に設定した値を抜き出してみました。
$ grep -v "^#" inventory | grep -v "^$" localhost ansible_connection=local ansible_python_interpreter="/usr/bin/env python" [all:vars] dockerhub_base=ansible openshift_host=<IPアドレス>:8443 openshift_project=awx openshift_user=developer openshift_skip_tls_verify=True openshift_pg_emptydir=False openshift_token=<xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> awx_task_hostname=awx awx_web_hostname=awxweb postgres_data_dir=/tmp/pgdocker host_port=80 pg_username=awx pg_password=awxpass pg_database=awx pg_port=5432 rabbitmq_password=awxpass rabbitmq_erlang_cookie=cookiemonster admin_user=admin admin_password=<パスワード> create_preload_data=True secret_key=awxsecret
ここまで準備できたら、installer を実行します。Ansible のプレイブックになっています。
$ ansible-playbook -i inventory install.yml … PLAY RECAP ********************************************************************************************************************************* localhost : ok=36 changed=18 unreachable=0 failed=0
エラーなく終了したら、oc で確認してみてください。
$ oc status
In project awx on server https://192.168.99.101:8443
https://awx-web-svc-awx.192.168.99.101.nip.io (redirects) to pod port http (svc/awx-web-svc)
svc/awx-rmq-mgmt - 172.30.87.193:15672
statefulset/awx manages ansible/awx_web:4.0.0,ansible/awx_task:4.0.0,ansible/awx_rabbitmq:3.7.4,memcached:latest
created 22 minutes ago - 1 pod
svc/postgresql - 172.30.100.39:5432
dc/postgresql deploys registry.access.redhat.com/rhscl/postgresql-96-rhel7:latest
deployment #1 deployed 23 minutes ago - 1 pod
svc/rabbitmq (all nodes) ports 15672, 5672
statefulset/awx manages ansible/awx_web:4.0.0,ansible/awx_task:4.0.0,ansible/awx_rabbitmq:3.7.4,memcached:latest
created 22 minutes ago - 1 pod
View details with 'oc describe <resource>/<name>' or list everything with 'oc get all'.
$ oc get all NAME READY STATUS RESTARTS AGE pod/awx-0 4/4 Running 0 18m pod/postgresql-1-mgfsr 1/1 Running 0 23m NAME DESIRED CURRENT READY AGE replicationcontroller/postgresql-1 1 1 1 23m NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/awx-rmq-mgmt ClusterIP 172.30.87.193 <none> 15672/TCP 22m service/awx-web-svc NodePort 172.30.170.21 <none> 80:30026/TCP 22m service/postgresql ClusterIP 172.30.100.39 <none> 5432/TCP 23m service/rabbitmq NodePort 172.30.116.189 <none> 15672:32006/TCP,5672:32707/TCP 22m NAME DESIRED CURRENT AGE statefulset.apps/awx 1 1 22m NAME REVISION DESIRED CURRENT TRIGGERED BY deploymentconfig.apps.openshift.io/postgresql 1 1 1 config NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD route.route.openshift.io/awx-web-svc awx-web-svc-awx.192.168.99.101.nip.io awx-web-svc http edge/Redirect None
では実際にアクセスしてみましょう。TLS証明書の警告は出ますが、アクセスできるはずです。
https://awx-web-svc-awx.192.168.99.101.nip.io

inventory ファイルで admin_password に設定したパスワードを使って、admin ユーザでログインできます。

無事インストールできたでしょうか。最後に確認として、Demo Job Template を動かしてみてください。

Ansible Tower はすぐ導入できないという場合でも、AWX をぜひ使ってみてください。Happy Automation!