From a007a9ae3f3a47ca5ae198ce02956fa53477637e Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Mon, 8 Oct 2018 08:43:45 +0000 Subject: [PATCH] Add install and deploy openshift roles. Change-Id: I9ad16ddba8495ed977d818c03ccca07b81c1d4b8 --- roles/deploy-openshift/README.rst | 1 + roles/deploy-openshift/tasks/main.yaml | 24 ++++++++++++ roles/install-openshift/README.rst | 16 ++++++++ roles/install-openshift/defaults/main.yaml | 2 + roles/install-openshift/tasks/main.yaml | 44 ++++++++++++++++++++++ 5 files changed, 87 insertions(+) create mode 100644 roles/deploy-openshift/README.rst create mode 100644 roles/deploy-openshift/tasks/main.yaml create mode 100644 roles/install-openshift/README.rst create mode 100644 roles/install-openshift/defaults/main.yaml create mode 100644 roles/install-openshift/tasks/main.yaml diff --git a/roles/deploy-openshift/README.rst b/roles/deploy-openshift/README.rst new file mode 100644 index 000000000..bb1f498b6 --- /dev/null +++ b/roles/deploy-openshift/README.rst @@ -0,0 +1 @@ +Deploy openshift using oc cluster up. diff --git a/roles/deploy-openshift/tasks/main.yaml b/roles/deploy-openshift/tasks/main.yaml new file mode 100644 index 000000000..aa413644e --- /dev/null +++ b/roles/deploy-openshift/tasks/main.yaml @@ -0,0 +1,24 @@ +--- +- name: Deploy local openshift cluster + command: "oc cluster up --insecure-skip-tls-verify=true --public-hostname={{ ansible_hostname }}" + become: yes + +- name: Create zuul user .kube directory + file: + path: "{{ ansible_user_dir }}/.kube" + state: directory + +- name: Setup zuul user kube config + copy: + src: /root/.kube/config + dest: "{{ ansible_env.HOME }}/.kube/config" + owner: "{{ ansible_env.USER }}" + mode: 0600 + remote_src: yes + become: yes + +- name: Login as system:admin + command: oc login -u system:admin + +- name: Who am i + command: oc whoami -c diff --git a/roles/install-openshift/README.rst b/roles/install-openshift/README.rst new file mode 100644 index 000000000..758245c08 --- /dev/null +++ b/roles/install-openshift/README.rst @@ -0,0 +1,16 @@ +Setup openshift requirements and pull the container images. +The deploy-openshift role can be used to start the services. + +This role only works on CentOS. + +**Role Variables** + +.. zuul:rolevar:: origin_repo + :default: centos-release-openshift-origin39 + + The origin repository. + +.. zuul:rolevar:: origin_version + :default: v3.9.0 + + The origin version. diff --git a/roles/install-openshift/defaults/main.yaml b/roles/install-openshift/defaults/main.yaml new file mode 100644 index 000000000..6f77c7535 --- /dev/null +++ b/roles/install-openshift/defaults/main.yaml @@ -0,0 +1,2 @@ +origin_repo: centos-release-openshift-origin39 +origin_version: v3.9.0 diff --git a/roles/install-openshift/tasks/main.yaml b/roles/install-openshift/tasks/main.yaml new file mode 100644 index 000000000..3b5497d05 --- /dev/null +++ b/roles/install-openshift/tasks/main.yaml @@ -0,0 +1,44 @@ +- name: Install origin repository + yum: + name: "{{ origin_repo }}" + become: yes + +- name: Install requirements + yum: + name: "{{ item }}" + with_items: + - origin + - docker + become: yes + +- name: Fix docker start options + lineinfile: + dest: /etc/sysconfig/docker + regexp: "^OPTIONS=" + line: "OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false --insecure-registry 172.30.0.0/16'" + become: yes + +# See: https://github.com/openshift/origin/issues/15038 +- name: Fix rhel secret issue + file: + path: /usr/share/rhel/secrets + state: absent + become: yes + +- name: Start docker service + service: + name: docker + state: started + become: yes + +- name: Pull origin images + command: "docker pull docker.io/openshift/{{ item }}:{{ origin_version }}" + with_items: + - origin-web-console + - origin-docker-registry + - origin-haproxy-router + - origin-deployer + - origin-sti-builder + - origin-pod + - origin + become: yes