Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Use Ansible to install Openshift Origin (oc) single node cluster on number of machines!

Install OpenShift Origin on one node (CENTOS) - commands:

1) Install docker

yum install docker -y 
systemctl start docker


echo "INSECURE_REGISTRY='--insecure-registry'" >> /etc/sysconfig/docker
systemctl enable docker
systemctl start  docker

2) Get Openshift and put it in class path

mkdir ~/1sarvani && cd 1sarvani
tar -xvzf openshift-origin-client-tools-v1.5.0-031cbe4-linux-64bit.tar.gz
mv openshift-origin-client-tools-v1.5.0-031cbe4-linux-64bit/* /usr/local/bin/

3) start OC cluster oc cluster up OR

oc cluster up \
                --image-streams=rhel7 \
                --host-pv-dir='/root/host-pv' \
                --host-volumes-dir='/root/host-volumes' \
                --host-data-dir='/root/host-etcd-data' \
                --host-config-dir='/root/host-config' \

Now, to do the same using Ansible:


  • When OSE installation throws error: config.yml --> {"failed": true, "msg": "Failed to query Docker API. Is docker running on this host?"} However, you have docker installed and is running!
  • Solution : we need docker-ce and not docker or docker-ee
    sudo systemctl stop docker
    sudo yum -y remove docker
    sudo yum remove container-selinux-2.33-1.git86f33cd.el7.noarch
    sudo yum-config-manager -y --add-repo
    sudo yum install -y --setopt=obsoletes=0   docker-ce-17.03.1.ce-1.el7.centos   docker-ce-selinux-17.03.1.ce-1.el7.centos
    sudo mv  /var/lib/docker/devicemapper/ /tmp
    systemctl status docker
    sudo systemctl start docker
    systemctl status docker
  • More simpler solution In your hosts file, in the play, [OSEv3:vars] , add the line openshift_disable_check=disk_availability,docker_storage,memory_availability to disable the checks! OR Goto /openshift-ansible/playbooks/common/openshift-cluster/config.yml and inside - - action: openshift_health_check
 action: openshift_health_check
      - disk_availability
      #- memory_availability
      - package_availability
      - package_version
      #- docker_image_availability
      #- docker_storage

Install OpenShift Origin on multiple nodes (CENTOS7.4)

Pre-reqs Installting using ansible

I am using the following:

  • Step1) Create 3 vms. 1 master(m1), 2 nodes(n1,n2)
  • Step2) Prepare the vms: - set hostname with fqdn hostnamectl set-hostname, cat /etc/sysconfig/network file should also have the same. - have '/etc/hosts' entry for m1, n1, n2 Example m1 n1 n2
  • Step3) Have 40Gb at /var partition. Assuming you have space and /var needs to be extended, follow the following:
--to extend file system
 df -Th
 lvextend -L +40G /dev/mapper/vg_root-var
 df -TH
 resize2fs /dev/mapper/vg_root-var
 df -TH

Else, add new disk, create partition, and then extend

  • Step4) Now, time to prepare the host with prereq installs:
yum install -y epel-release docker ansible git
yum install -y wget git net-tools bind-utils iptables-services bridge-utils bash-completion kexec-tools sos psacct
echo "INSECURE_REGISTRY='--insecure-registry'" >> /etc/sysconfig/docker    # is the default value of the servicesSubnet variable in the master-config.yaml file
cat /etc/sysconfig/docker  #verify insecure reg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment