はじめての AWX

KATO Tomoyuki
6 min readDec 23, 2017

--

Ansible Advent Calendar 2017 23日目の記事です。

AWX は、長らく Ansible Tower として開発されていた商用製品をクリーンアップして OSS 化したものです。Ansibleのダッシュボード、REST API、ユーザー管理・アクセス制御などの機能を提供します。AWS については3日目の記事にも書かれているので、そちらとそのリンク先のOSSブログもご覧ください。どちらもいい記事になっています。Ansible Tower は Think IT の連載記事に導入方法からクラウド連携機能までまとまっています。

じゃぁ何も書くことがないのでは、という声が聞こえてきそうですね。はい、そのとおりです。そこをあえて「はじめての」方向けに、できるだけシンプルな手順を、できるだけAWXのドキュメントそのままにインストールすることを目指してみたいと思います。

今回は CentOS 7.4.1708 を使用します。AWXのインストール環境としてDockerとOpenShiftを利用できますが、Docker単体にインストールすることにします。

Docker のインストール

AWXのドキュメントからリンクされているとおり、Dockerの公式ドキュメントに沿って Docker CE をインストールします。最後に sudo docker run hello-world を実行すると、以下のように表示されると正常にインストールできています。

[admin@c7 ~]$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:445b2fe9afea8b4aa0b2f27fe49dd6ad130dfe7a8fd0832be5de99625dad47cd
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://cloud.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/

Docker SDK for Python (docker-py) のインストール

docker-pyのドキュメントにあるとおり、最新版は pip を使用してインストールします。CentOSのpipは、EPELリポジトリーからインストールできます。

$ sudo yum install epel-release
$ sudo yum install python-pip
$ sudo pip install --upgrade pip
$ sudo pip install docker

AWX のインストール

まずAWXのリポジトリーをダウンロードします。

$ sudo yum install git
$ git clone https://github.com/ansible/awx.git
$ cd awx

インストールする前にインストールの設定を確認します。ドキュメントにあるとおり installer ディレクトリの inventory ファイルにまとまっています。各パラメーターの詳細はドキュメントをご確認ください。基本的にはそのままで動作します。データベースを永続化したい場合、 postgres_data_dir の設定をどこか永続できる場所に変更する必要があります。

ここでようやくAWXをインストールします。

$ sudo yum install ansible
$ cd installer
$ sudo ansible-playbook -i inventory install.yml

数分くらい待ち、とくにエラーなく実行完了したら、ブラウザーからアクセスしましょう。

AWS login screen

これでAWXがインストールできました。複数のDockerイメージを利用した構成をAnsibleを用いて自動的に構築するため、かんたんにインストールできることがわかったと思います。

Ansible Advent Calendar 2017 のさまざまな記事のネタをはじめ、Ansibleには単なる自動化を超えた可能性の広がりがあります。AWXのユーザー管理やアクセス制御などの機能を活用しつつ、コマンドラインに抵抗のある利用者にも手軽にAnsibleを利用できる環境を実現できます。Ansibleを活用して幸せな世界を実現していきましょう。

--

--