#!/usr/bin/ansible-playbook --module-path=../../../library/ # # ./oadm_manage_node.yml -e "cli_master_test=$OPENSHIFT_MASTER --- - hosts: "{{ cli_master_test }}" gather_facts: no user: root tasks: - name: get list of nodes oc_obj: state: list kind: node register: obj_out - name: Set the node to work with set_fact: node_to_test: "{{ obj_out['results']['results'][0]['items'][0]['metadata']['name'] }}" - name: list pods from a node oadm_manage_node: list_pods: True node: - "{{ node_to_test }}" register: podout - debug: var=podout - assert: that: "'{{ node_to_test }}' in podout.results.nodes" msg: Pod data was not returned - name: set node to unschedulable oadm_manage_node: schedulable: False node: - "{{ node_to_test }}" register: nodeout - debug: var=nodeout - name: assert that schedulable=False assert: that: nodeout.results.nodes[0]['schedulable'] == False msg: "{{ node_to_test }} schedulable set to True" - name: get node scheduable oc_obj: kind: node state: list name: "{{ node_to_test }}" namespace: None register: nodeout - debug: var=nodeout - name: assert that schedulable=False assert: that: nodeout.results.results[0]['spec']['unschedulable'] - name: set node to schedulable oadm_manage_node: schedulable: True node: - "{{ node_to_test }}" register: nodeout - debug: var=nodeout - name: assert that schedulable=False assert: that: nodeout.results.nodes[0]['schedulable'] msg: "{{ node_to_test }} schedulable set to False"