summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wiest <twiest@users.noreply.github.com>2015-06-29 15:41:28 -0400
committerThomas Wiest <twiest@users.noreply.github.com>2015-06-29 15:41:28 -0400
commita27076bee3e8f93681f5d5e1c4b072084f6847b6 (patch)
tree4ee6293daf334a825e9fcf1caa71ce42189a621d
parentaccd98845aac3e271295e3115501b25e6d72b114 (diff)
parentcde074730ed8278673498157008651d192c8236a (diff)
downloadopenshift-a27076bee3e8f93681f5d5e1c4b072084f6847b6.tar.gz
openshift-a27076bee3e8f93681f5d5e1c4b072084f6847b6.tar.bz2
openshift-a27076bee3e8f93681f5d5e1c4b072084f6847b6.tar.xz
openshift-a27076bee3e8f93681f5d5e1c4b072084f6847b6.zip
Merge pull request #309 from brenton/manage_node
delegate_to doesn't appear to be thread safe
-rw-r--r--filter_plugins/oo_filters.py7
-rw-r--r--playbooks/common/openshift-node/config.yml15
-rw-r--r--roles/openshift_manage_node/tasks/main.yml11
-rw-r--r--roles/openshift_node/tasks/main.yml21
4 files changed, 30 insertions, 24 deletions
diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py
index b7248efaa..0f3f4fa9e 100644
--- a/filter_plugins/oo_filters.py
+++ b/filter_plugins/oo_filters.py
@@ -52,8 +52,9 @@ class FilterModule(object):
@staticmethod
def oo_collect(data, attribute=None, filters=None):
''' This takes a list of dict and collects all attributes specified into a
- list If filter is specified then we will include all items that match
- _ALL_ of filters.
+ list. If filter is specified then we will include all items that
+ match _ALL_ of filters. If a dict entry is missing the key in a
+ filter it will be excluded from the match.
Ex: data = [ {'a':1, 'b':5, 'z': 'z'}, # True, return
{'a':2, 'z': 'z'}, # True, return
{'a':3, 'z': 'z'}, # True, return
@@ -74,7 +75,7 @@ class FilterModule(object):
raise errors.AnsibleFilterError("|fialed expects filter to be a"
" dict")
retval = [FilterModule.get_attr(d, attribute) for d in data if (
- all([d[key] == filters[key] for key in filters]))]
+ all([d.get(key, None) == filters[key] for key in filters]))]
else:
retval = [FilterModule.get_attr(d, attribute) for d in data]
diff --git a/playbooks/common/openshift-node/config.yml b/playbooks/common/openshift-node/config.yml
index 2d2560db4..0eec1ae61 100644
--- a/playbooks/common/openshift-node/config.yml
+++ b/playbooks/common/openshift-node/config.yml
@@ -135,3 +135,18 @@
roles:
- os_env_extras
- os_env_extras_node
+
+- name: Set scheduleability
+ hosts: oo_first_master
+ vars:
+ openshift_unscheduleable_nodes: "{{ hostvars
+ | oo_select_keys(groups['oo_nodes_to_config'])
+ | oo_collect('openshift_hostname', {'openshift_scheduleable': False}) }}"
+ pre_tasks:
+ - set_fact:
+ openshift_scheduleable_nodes: "{{ hostvars
+ | oo_select_keys(groups['oo_nodes_to_config'])
+ | oo_collect('openshift_hostname')
+ | difference(openshift_unscheduleable_nodes) }}"
+ roles:
+ - openshift_manage_node
diff --git a/roles/openshift_manage_node/tasks/main.yml b/roles/openshift_manage_node/tasks/main.yml
new file mode 100644
index 000000000..d4c623f10
--- /dev/null
+++ b/roles/openshift_manage_node/tasks/main.yml
@@ -0,0 +1,11 @@
+- name: Handle unscheduleable node
+ delegate_to: "{{ openshift_first_master }}"
+ command: >
+ {{ openshift.common.admin_binary }} manage-node {{ item }} --schedulable=false
+ with_items: openshift_unscheduleable_nodes
+
+- name: Handle scheduleable node
+ delegate_to: "{{ openshift_first_master }}"
+ command: >
+ {{ openshift.common.admin_binary }} manage-node {{ item }} --schedulable=true
+ with_items: openshift_scheduleable_nodes
diff --git a/roles/openshift_node/tasks/main.yml b/roles/openshift_node/tasks/main.yml
index 13f30a6f8..770b55351 100644
--- a/roles/openshift_node/tasks/main.yml
+++ b/roles/openshift_node/tasks/main.yml
@@ -73,24 +73,3 @@
- name: Start and enable openshift-node
service: name=openshift-node enabled=yes state=started
-
-- name: Check scheduleable state
- delegate_to: "{{ openshift_first_master }}"
- command: >
- {{ openshift.common.client_binary }} get node {{ openshift.common.hostname }}
- register: ond_get_node
- until: ond_get_node.rc == 0
- retries: 10
- delay: 5
-
-- name: Handle unscheduleable node
- delegate_to: "{{ openshift_first_master }}"
- command: >
- {{ openshift.common.admin_binary }} manage-node {{ openshift.common.hostname }} --schedulable=false
- when: openshift_scheduleable is defined and openshift_scheduleable == False and "SchedulingDisabled" not in ond_get_node.stdout
-
-- name: Handle scheduleable node
- delegate_to: "{{ openshift_first_master }}"
- command: >
- {{ openshift.common.admin_binary }} manage-node {{ openshift.common.hostname }} --schedulable=true
- when: (openshift_scheduleable is not defined or openshift_scheduleable == True) and "SchedulingDisabled" in ond_get_node.stdout