Skip to content

Instantly share code, notes, and snippets.

@kmurudi
Last active July 14, 2017 05:14
Show Gist options
  • Save kmurudi/bdfd21cd6af02e3b51ad164ad85d4a01 to your computer and use it in GitHub Desktop.
Save kmurudi/bdfd21cd6af02e3b51ad164ad85d4a01 to your computer and use it in GitHub Desktop.
---
- hosts: master.unset.ocp-admin.aws.openshifttestdrive.com
tasks:
- name: Check if the 'ocversion' is correct
command: oc version
register: version
failed_when: version.stdout_lines[0] != "oc v3.5.5.26" or version.stdout_lines[1] != "kubernetes v1.5.2+43a9be4"
- name: Checking status for Node1
command: oc get -o jsonpath='{.status.conditions[?(@.reason=="KubeletReady")].type}' node node_names.stdout_lines[1]
register: node1
failed_when: "'Ready' not in node1.stdout"
- name: Checking status for Node2
command: oc get -o jsonpath='{.status.conditions[?(@.reason=="KubeletReady")].type}' node node_names.stdout_lines[2]
register: node2
failed_when: "'Ready' not in node2.stdout"
- name: Checking status for Node3
command: oc get -o jsonpath='{.status.conditions[?(@.reason=="KubeletReady")].type}' node node_names.stdout_lines[3]
register: node3
failed_when: "'Ready' not in node3.stdout"
- name: Checking status for Node4
command: oc get -o jsonpath='{.status.conditions[?(@.reason=="KubeletReady")].type}' node node_names.stdout_lines[4]
register: node4
failed_when: "'Ready' not in node4.stdout"
- name: Checking status for Node5
command: oc get -o jsonpath='{.status.conditions[?(@.reason=="KubeletReady")].type}' node node_names.stdout_lines[5]
register: node5
failed_when: "'Ready' not in node5.stdout"
- name: Checking that master node is unschedulable
command: oc get -o jsonpath='{.spec.unschedulable}' node node_names.stdout_lines[1]
register: master
failed_when: "'true' not in master.stdout"
- name: Checking number of nodes
shell: sed -e '1,/\[nodes\]/d' /etc/ansible/hosts | wc -l
register: number_of_nodes
failed_when: number_of_nodes.stdout != '5'
- name: Creating new project using 'oc adm'
command: oc adm new-project my-new-proj
register: project_name
- name: Listing projects to check if new project exists
command: oc get -o jsonpath='{.items[*].metadata.name}' projects
register: project_list
failed_when: "'my-new-proj' not in project_list.stdout"
- name: Checking if the project created is Active
command: oc get -o jsonpath='{.status.phase}' project my-new-proj
register: status
failed_when: status.stdout != 'Active'
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment