AKAI TSUKI

System development or Technical something

install AWX on CentOS 7.

Please see this url.
https://github.com/ansible/awx/blob/devel/INSTALL.md


I have already installed docker-ce.

[root@cent7devops installer]# docker version
Client:
 Version:           18.06.0-ce
 API version:       1.38
 Go version:        go1.10.3
 Git commit:        0ffa825
 Built:             Wed Jul 18 19:08:18 2018
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.06.0-ce
  API version:      1.38 (minimum version 1.12)
  Go version:       go1.10.3
  Git commit:       0ffa825
  Built:            Wed Jul 18 19:10:42 2018
  OS/Arch:          linux/amd64
  Experimental:     false
[root@cent7devops installer]#

and install package.

[root@cent7devops awx]# yum install git
[root@cent7devops installer]# git --version
git version 1.8.3.1
[root@cent7devops installer]#
[root@cent7devops awx]# yum install python2-pip.noarch
[root@cent7devops awx]# pip install -U pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl (1.3MB)
    100% |????????????????????????????????| 1.3MB 1.1MB/s
Installing collected packages: pip
  Found existing installation: pip 8.1.2
    Uninstalling pip-8.1.2:
      Successfully uninstalled pip-8.1.2
Successfully installed pip-18.0
[root@cent7devops awx]#
[root@cent7devops awx]# pip -V
pip 18.0 from /usr/lib/python2.7/site-packages/pip (python 2.7)
[root@cent7devops awx]#
[root@cent7devops installer]# pip install docker-py
*snip*
Installing collected packages: websocket-client, idna, chardet, urllib3, certifi, requests, docker-pycreds, docker-py
  Found existing installation: idna 2.4
    Uninstalling idna-2.4:
      Successfully uninstalled idna-2.4
  Found existing installation: chardet 2.2.1
    Uninstalling chardet-2.2.1:
      Successfully uninstalled chardet-2.2.1
Successfully installed certifi-2018.4.16 chardet-3.0.4 docker-py-1.10.6 docker-pycreds-0.3.0 idna-2.7 requests-2.19.1 urllib3-1.23 websocket-client-0.48.0
[root@cent7devops installer]#

I execute git clone command.

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

I confirm invenroty file.

[root@cent7devops work-awx]# cd awx/installer/
[root@cent7devops installer]# cat inventory | grep -v -e "^#.*$" | grep -v -e "^\s*$"
localhost ansible_connection=local ansible_python_interpreter="/usr/bin/env python"
[all:vars]
dockerhub_base=ansible
dockerhub_version=latest
postgres_data_dir=/tmp/pgdocker
host_port=80
docker_compose_dir=/var/lib/awx
pg_username=awx
pg_password=awxpass
pg_database=awx
pg_port=5432
secret_key=awxsecret
[root@cent7devops installer]#

I edit postgres_data_dir parameter.

[root@cent7devops installer]# cp -p inventory inventory.bak
[root@cent7devops installer]# vi inventory
[root@cent7devops installer]# diff inventory inventory.bak
36c36
< postgres_data_dir=/opt/awx/pgdocker
---
> postgres_data_dir=/tmp/pgdocker
[root@cent7devops installer]#

I create directory for "pgdocker".

[root@cent7devops installer]# mkdir -p /opt/awx/pgdocker
[root@cent7devops installer]# ls -l /opt/awx/pgdocker/
total 0
[root@cent7devops installer]#

install docker-compose. (no need?)

[root@cent7devops installer]# curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   617    0   617    0     0    821      0 --:--:-- --:--:-- --:--:--   821
100 11.2M  100 11.2M    0     0  2035k      0  0:00:05  0:00:05 --:--:-- 2575k
[root@cent7devops installer]# chmod +x /usr/local/bin/docker-compose
[root@cent7devops installer]# docker-compose version
docker-compose version 1.22.0, build f46880fe
docker-py version: 3.4.1
CPython version: 3.6.6
OpenSSL version: OpenSSL 1.1.0f  25 May 2017
[root@cent7devops installer]#

I deploy AWX. But an error occurred as follows:

[root@cent7devops installer]# ansible-playbook -i inventory install.yml -vvv

*snip*

TASK [local_docker : Activate postgres container] *************************************************************************************************************************************************************
task path: /root/work-awx/awx/installer/roles/local_docker/tasks/standalone.yml:2
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1532795794.42-204748296795817 `" && echo ansible-tmp-1532795794.42-204748296795817="` echo /root/.ansible/tmp/ansible-tmp-1532795794.42-204748296795817 `" ) && sleep 0'
Using module file /usr/lib/python2.7/site-packages/ansible/modules/cloud/docker/docker_container.py
<localhost> PUT /root/.ansible/tmp/ansible-local-13136TVuFdq/tmpIVOUUb TO /root/.ansible/tmp/ansible-tmp-1532795794.42-204748296795817/docker_container.py
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1532795794.42-204748296795817/ /root/.ansible/tmp/ansible-tmp-1532795794.42-204748296795817/docker_container.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/env python /root/.ansible/tmp/ansible-tmp-1532795794.42-204748296795817/docker_container.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1532795794.42-204748296795817/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_4MVoKw/ansible_module_docker_container.py", line 2081, in <module>
    main()
  File "/tmp/ansible_4MVoKw/ansible_module_docker_container.py", line 2076, in main
    cm = ContainerManager(client)
  File "/tmp/ansible_4MVoKw/ansible_module_docker_container.py", line 1703, in __init__
    self.present(state)
  File "/tmp/ansible_4MVoKw/ansible_module_docker_container.py", line 1723, in present
    new_container = self.container_create(self.parameters.image, self.parameters.create_parameters)
  File "/tmp/ansible_4MVoKw/ansible_module_docker_container.py", line 825, in create_parameters
    host_config=self._host_config(),
  File "/tmp/ansible_4MVoKw/ansible_module_docker_container.py", line 931, in _host_config
    return self.client.create_host_config(**params)
  File "/usr/lib/python2.7/site-packages/docker/api/container.py", line 157, in create_host_config
    return utils.create_host_config(*args, **kwargs)
TypeError: create_host_config() got an unexpected keyword argument 'init'

fatal: [localhost]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_4MVoKw/ansible_module_docker_container.py\", line 2081, in <module>\n    main()\n  File \"/tmp/ansible_4MVoKw/ansible_module_docker_container.py\", line 2076, in main\n    cm = ContainerManager(client)\n  File \"/tmp/ansible_4MVoKw/ansible_module_docker_container.py\", line 1703, in __init__\n    self.present(state)\n  File \"/tmp/ansible_4MVoKw/ansible_module_docker_container.py\", line 1723, in present\n    new_container = self.container_create(self.parameters.image, self.parameters.create_parameters)\n  File \"/tmp/ansible_4MVoKw/ansible_module_docker_container.py\", line 825, in create_parameters\n    host_config=self._host_config(),\n  File \"/tmp/ansible_4MVoKw/ansible_module_docker_container.py\", line 931, in _host_config\n    return self.client.create_host_config(**params)\n  File \"/usr/lib/python2.7/site-packages/docker/api/container.py\", line 157, in create_host_config\n    return utils.create_host_config(*args, **kwargs)\nTypeError: create_host_config() got an unexpected keyword argument 'init'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE",
    "rc": 1
}
        to retry, use: --limit @/root/work-awx/awx/installer/install.retry

PLAY RECAP ****************************************************************************************************************************************************************************************************
localhost                  : ok=4    changed=0    unreachable=0    failed=1

[root@cent7devops installer]#

I got infomation for error from below pages.
https://groups.google.com/forum/#!topic/awx-project/hWdGoYXFjs0
https://github.com/ansible/ansible/issues/43297
I uninstall docker-py and install docker of python package.

[root@cent7devops installer]# pip uninstall docker-py
Uninstalling docker-py-1.10.6:
  Would remove:
    /usr/lib/python2.7/site-packages/docker/*
    /usr/lib/python2.7/site-packages/docker_py-1.10.6.dist-info/*
Proceed (y/n)? y
  Successfully uninstalled docker-py-1.10.6
[root@cent7devops installer]# pip install docker
*snip*
Installing collected packages: docker
Successfully installed docker-3.4.1
[root@cent7devops installer]#

and retry to deploy AWX. I succeeded now.

[root@cent7devops installer]# ansible-playbook -i inventory install.yml
*snip*
TASK [local_docker : Start the containers] ********************************************************************************************************************************************************************
skipping: [localhost]

PLAY RECAP ****************************************************************************************************************************************************************************************************
localhost                  : ok=12   changed=5    unreachable=0    failed=0

[root@cent7devops installer]#

I confirm docker container status.

[root@cent7devops installer]# docker ps
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                                                 NAMES
1bce3bc17924        ansible/awx_task:latest      "/tini -- /bin/sh -c…"   23 minutes ago      Up 23 minutes       8052/tcp                                              awx_task
94845f8e21e3        ansible/awx_web:latest       "/tini -- /bin/sh -c…"   23 minutes ago      Up 23 minutes       0.0.0.0:80->8052/tcp                                  awx_web
23e88bb7fedc        memcached:alpine             "docker-entrypoint.s…"   26 minutes ago      Up 26 minutes       11211/tcp                                             memcached
0e37308457d8        ansible/awx_rabbitmq:3.7.4   "docker-entrypoint.s…"   26 minutes ago      Up 26 minutes       4369/tcp, 5671-5672/tcp, 15671-15672/tcp, 25672/tcp   rabbitmq
9734b0d16739        postgres:9.6                 "docker-entrypoint.s…"   27 minutes ago      Up 27 minutes       5432/tcp                                              postgres
[root@cent7devops installer]#

and I access to awx web page.