Setup OpenShift's requirements through Ansible

Recently I've been involved in a OpenShift deployment for a customer's POC environment with a very time-limited constraint.

For that matter I've tried to handle all the necessary manual steps with the help of Ansible.



You can launch the script from your laptop, a node outside or inside the OpenShift cluster.

Anyway remember that in case you'll use one of the master nodes for example, you should manually register it to RHN, attach it to ose3 channel and install Ansible by yourself.

In my case the machines are already installed (and subscribed) with Satellite6, so I don't need any subscription-manager registration task.

The machines are already installed with lvm2 enabled partition schema and the default VG has enough space to handle docker lvm pool (this is why I run only docker-storage-setup without configuring the /etc/sysconfig/docker file).


You may also find an updated version of the following file here:



This is the playbook I wrote for setting up the prerequisites of OpenShift installation process:

[root@openshift01 ~]# cat init.yml

- hosts: all


        - name: yum clean all

          command: yum clean all



        - name: subscription-manager refresh

          command: "subscription-manager refresh"



        - name: Enable chosen repositories

          command: "subscription-manager repos --disable '*' --enable rhel-7-server-rpms --enable rhel-7-server-extras-rpms --enable rhel-7-server-ose-3.2-rpms"


        - name: install libselinux-python

          yum: name=libselinux-python state=installed


        - name: install NetworkManager

          yum: name=NetworkManager state=installed


        - name: enable NetworkManager

          service: name=NetworkManager enabled=true state=started


        - name: Install required packages


            name: ""

            state: installed


            - wget

            - git

            - net-tools

            - bind-utils

            - iptables-services

            - bridge-utils

            - bash-completion


        - name: Update the system

          yum: state=latest name='*'        


        - name: Install atomic-openshift-utils

          yum: state=installed name=atomic-openshift-utils


        - name: Install docker

          yum: state=installed name='docker-1.10.3'


        - name: Enable insecure docker registry

          shell: sed -i "s|OPTIONS=.*|OPTIONS='--selinux-enabled --insecure-registry'|g" /etc/sysconfig/docker


        - name: docker-storage-setup

          shell: docker-storage-setup


        - name: enable docker service

          service: name=docker enabled=true state=started


- hosts: masters


        - name: Install htpasswd

          yum: state=installed name=httpd-tools


        - name: ensure /etc/origin/master esists

          file: path=/etc/origin/master state=directory


        - name: checking if /etc/origin/master/htpasswd exists

          stat: path=/etc/origin/master/htpasswd

          register: p


        - name: create developer user

          shell: echo developer | htpasswd -i -c /etc/origin/master/htpasswd developer

          when: p.stat.exists is not defined or not p.stat.exists



Please comment and/or integrate it in case you make the ansible playbook smarter!