awx ansible on rhel

As you probably read we did opensource ansible tower

https://github.com/ansible/awx . This was a big and necessary step to follow the red hat way of being truly opensource. Thanks to Jeff Geerling we also have a role https://galaxy.ansible.com/geerlingguy/awx/ to install awx.

To install AWX on RHEL (remember this is not supported by GSS) you need to do the following:

Step1: register your host with Red Hat

[root@host141 ~]# subscription-manager register

Step2: now add the needed channels

[root@host141 ~]# subscription manager attach --pool YOURPOOLFORRHEL

Step3: enable the repos extras and optional

[root@host141 ~]# subscription-manager repos --disable=*
[root@host141 ~]# subscription-manager repos --enable=rhel-7-server-rpms --enable=rhel-7-server-extras-rpms --enable=rhel-7-server-optional-rpms

Step4: to be able to run the build correctly you will have to do the following

[root@host141 ~]# mkdir -p /etc/docker

Step 5: add the following file. Without that you build will fail complaining that you cannot connect to github

[root@host141 ~]# cat << EOF > /etc/docker/daemon.json 
{
    "dns": ["8.8.8.8"]
}
EOF

Step 6: install ansible

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

Step 7: install all the necessary roles

[root@host141 ~]# cat << EOF > roles-for-awx.sh
ansible-galaxy install  geerlingguy.git
ansible-galaxy install geerlingguy.ansible
ansible-galaxy install  geerlingguy.docker
ansible-galaxy install  geerlingguy.pip
ansible-galaxy install  geerlingguy.nodejs
ansible-galaxy install geerlingguy.repo-epel
ansible-galaxy install geerlingguy.awx
EOF

chmod +x roles-for-awx.sh

Step 8: install the roles:

[root@host141 ~]# ./roles-for-awx.sh

Step 9: create the inventory add your host

[root@host141 ~]# mkdir inventory
[root@host141 ~]# touch hosts inventory/
[root@host141 ~]# echo '192.168.1.55' > inventory/hosts

Step 10: create the play to install awx

[root@host141 ~]# echo << EOF > install.yml
---
- hosts: all
  become: yes

  vars:
    nodejs_version: "6.x"
    pip_install_packages:
      - name: docker-py

  pre_tasks:
    - name: Update apt cache.
      apt: update_cache=yes cache_valid_time=600
      when: ansible_os_family == 'Debian'
      changed_when: false

  roles:
    - name: geerlingguy.repo-epel
      when: ansible_os_family == "RedHat"
    - geerlingguy.git
    - geerlingguy.ansible
    - geerlingguy.docker
    - geerlingguy.pip
    - geerlingguy.nodejs
    - geerlingguy.awx
EOF

Step 11: run the playbook

[root@host141 ~]# ansible-playbook -i inventory install.yml -vv

Step 12: If the install is successful you will see the following

[root@host141 ~]# docker ps
CONTAINER ID        IMAGE                COMMAND                  CREATED             STATUS              PORTS                                NAMES
5bd777f861d5        awx_task:1.0.0.337   "/tini -- /bin/sh ..."   About an hour ago   Up About an hour    8052/tcp                             awx_task
b56359a39b98        awx_web:1.0.0.337    "/tini -- /bin/sh ..."   About an hour ago   Up About an hour    0.0.0.0:80->8052/tcp                 awx_web
243a135f35bc        memcached:alpine     "docker-entrypoint..."   About an hour ago   Up About an hour    11211/tcp                            memcached
19d622b223b3        rabbitmq:3           "docker-entrypoint..."   About an hour ago   Up About an hour    4369/tcp, 5671-5672/tcp, 25672/tcp   rabbitmq
f6eede4708f5        postgres:9.6         "docker-entrypoint..."   About an hour ago   Up About an hour    5432/tcp                             postgres

Step 13: It will take a while until the instance comes up. You can check it like this

[root@host141 awx]# docker logs -f awx_task
Using /etc/ansible/ansible.cfg as config file
127.0.0.1 | SUCCESS => {
    "changed": true, 
    "db": "awx"
}
Operations to perform:
  Synchronize unmigrated apps: solo, api, staticfiles, messages, channels, django_extensions, ui, rest_framework, polymorphic
  Apply all migrations: sso, taggit, sessions, djcelery, sites, kombu_transport_django, social_auth, contenttypes, auth, conf, main
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
  Installing custom SQL...
Running migrations:
  Rendering model states... DONE
  Applying contenttypes.0001_initial... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0001_initial... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying taggit.0001_initial... OK
  Applying taggit.0002_auto_20150616_2121... OK
  Applying main.0001_initial... OK
  Applying main.0002_squashed_v300_release... OK
  Applying main.0003_squashed_v300_v303_updates... OK
  Applying main.0004_squashed_v310_release... OK
  Applying conf.0001_initial... OK
  Applying conf.0002_v310_copy_tower_settings... OK
  Applying conf.0003_v310_JSONField_changes... OK
  Applying conf.0004_v320_reencrypt... OK
  Applying djcelery.0001_initial... OK
  Applying kombu_transport_django.0001_initial... OK
  Applying main.0005_squashed_v310_v313_updates... OK
  Applying main.0006_v320_release... OK
2017-09-12 14:18:40,999 DEBUG    awx.main.migrations Removing all Rackspace InventorySource from database.
2017-09-12 14:18:41,028 DEBUG    awx.main.migrations Removing all InventorySource that have no link to an Inventory from database.
  Applying main.0007_v320_data_migrations... OK
  Applying main.0008_v320_drop_v1_credential_fields... OK
  Applying sessions.0001_initial... OK
  Applying sites.0001_initial... OK
  Applying social_auth.0001_initial... OK
  Applying social_auth.0002_add_related_name... OK
  Applying social_auth.0003_alter_email_max_length... OK
  Applying social_auth.0004_auto_20160423_0400... OK
  Applying social_auth.0005_auto_20160727_2333... OK
  Applying sso.0001_initial... OK
  Applying sso.0002_expand_provider_options... OK
Python 2.7.5 (default, Nov  6 2016, 00:28:07) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)

>>> <User: admin>
>>> Default organization added.
Demo Credential, Inventory, and Job Template added.
Successfully registered instance awx
(changed: True)
Creating instance group tower
Added instance awx to tower
(changed: True)

Step 14: Login to tower via http://yourip (username is admin, pass is password)

Step 15: Once logged in you should see