From 4b0fa927ae262a09da87c72ced250c1b3e9c91ae Mon Sep 17 00:00:00 2001 From: Scott Dodson Date: Mon, 20 Mar 2017 13:17:08 -0400 Subject: Simplify excluder enablement logic a bit more --- roles/openshift_excluder/README.md | 2 -- roles/openshift_excluder/tasks/adjust.yml | 4 ++-- roles/openshift_excluder/tasks/disable.yml | 1 - roles/openshift_excluder/tasks/enable.yml | 9 +++------ roles/openshift_excluder/tasks/exclude.yml | 2 -- 5 files changed, 5 insertions(+), 13 deletions(-) diff --git a/roles/openshift_excluder/README.md b/roles/openshift_excluder/README.md index e76a15952..e048bd107 100644 --- a/roles/openshift_excluder/README.md +++ b/roles/openshift_excluder/README.md @@ -18,8 +18,6 @@ Facts | enable_docker_excluder | enable_excluders | Enable docker excluder. If not set, the docker excluder is ignored. | | enable_openshift_excluder | enable_excluders | Enable openshift excluder. If not set, the openshift excluder is ignored. | | enable_excluders | None | Enable all excluders -| enable_docker_excluder_override | None | indication the docker excluder needs to be enabled | -| disable_openshift_excluder_override | None | indication the openshift excluder needs to be disabled | Role Variables -------------- diff --git a/roles/openshift_excluder/tasks/adjust.yml b/roles/openshift_excluder/tasks/adjust.yml index cbdd7785b..c32cd6070 100644 --- a/roles/openshift_excluder/tasks/adjust.yml +++ b/roles/openshift_excluder/tasks/adjust.yml @@ -9,7 +9,7 @@ vars: # Enable the docker excluder only if it is overrided # BZ #1430612: docker excluders should be enabled even during installation and upgrade - exclude_docker_excluder: "{{ enable_docker_excluder | default(true) | bool }}" + exclude_docker_excluder: "{{ docker_excluder_on | bool }}" # excluder is to be disabled by default exclude_openshift_excluder: false # All excluders that are to be disabled are disabled @@ -20,6 +20,6 @@ unexclude_docker_excluder: false # disable openshift excluder is never overrided to be enabled # disable it if the docker excluder is enabled - unexclude_openshift_excluder: "{{ openshift_excluder_on | bool }}" + unexclude_openshift_excluder: true when: - not openshift.common.is_atomic | bool diff --git a/roles/openshift_excluder/tasks/disable.yml b/roles/openshift_excluder/tasks/disable.yml index 2245c7b21..988cda166 100644 --- a/roles/openshift_excluder/tasks/disable.yml +++ b/roles/openshift_excluder/tasks/disable.yml @@ -1,7 +1,6 @@ --- # input variables # - with_status_check -# - with_install # - excluder_package_state # - docker_excluder_package_state - include: init.yml diff --git a/roles/openshift_excluder/tasks/enable.yml b/roles/openshift_excluder/tasks/enable.yml index 9122c9aeb..e719325bc 100644 --- a/roles/openshift_excluder/tasks/enable.yml +++ b/roles/openshift_excluder/tasks/enable.yml @@ -1,6 +1,5 @@ --- # input variables: -# - with_install - block: - include: init.yml @@ -8,14 +7,12 @@ vars: install_docker_excluder: "{{ docker_excluder_on | bool }}" install_openshift_excluder: "{{ openshift_excluder_on | bool }}" - when: with_install | default(docker_excluder_on or openshift_excluder_on) | bool + when: docker_excluder_on or openshift_excluder_on | bool - include: exclude.yml vars: - # Enable the docker excluder only if it is overrided, resp. enabled by default (in that order) - exclude_docker_excluder: "{{ enable_docker_excluder_override | default(docker_excluder_on) | bool }}" - # Enable the openshift excluder only if it is not overrided, resp. enabled by default (in that order) - exclude_openshift_excluder: "{{ not disable_openshift_excluder_override | default(not openshift_excluder_on) | bool }}" + exclude_docker_excluder: "{{ docker_excluder_on | bool }}" + exclude_openshift_excluder: "{{ openshift_excluder_on | bool }}" when: - not openshift.common.is_atomic | bool diff --git a/roles/openshift_excluder/tasks/exclude.yml b/roles/openshift_excluder/tasks/exclude.yml index d31351aea..293a54184 100644 --- a/roles/openshift_excluder/tasks/exclude.yml +++ b/roles/openshift_excluder/tasks/exclude.yml @@ -5,8 +5,6 @@ - block: - name: Enable docker excluder command: "{{ openshift.common.service_type }}-docker-excluder exclude" - # if the docker override is set, it means the docker excluder needs to be enabled no matter what - # if the docker override is not set, the excluder is set based on enable_docker_excluder when: - exclude_docker_excluder | default(false) | bool -- cgit v1.2.3 From 6aee40fc1fab324134f4a28c2b124ba58e83932a Mon Sep 17 00:00:00 2001 From: Scott Dodson Date: Mon, 20 Mar 2017 13:17:24 -0400 Subject: Protect against missing commands Rather than trying to keep track of state everywhere, lets just check to see if the command exist before we attempt to run them --- roles/openshift_excluder/tasks/exclude.yml | 12 ++++++++++++ roles/openshift_excluder/tasks/unexclude.yml | 11 +++++++++++ 2 files changed, 23 insertions(+) diff --git a/roles/openshift_excluder/tasks/exclude.yml b/roles/openshift_excluder/tasks/exclude.yml index 293a54184..ca18d343f 100644 --- a/roles/openshift_excluder/tasks/exclude.yml +++ b/roles/openshift_excluder/tasks/exclude.yml @@ -3,16 +3,28 @@ # - exclude_docker_excluder # - exclude_openshift_excluder - block: + + - name: Check for docker-excluder + stat: + path: /sbin/{{ openshift.common.service_type }}-docker-excluder + register: docker_excluder_stat - name: Enable docker excluder command: "{{ openshift.common.service_type }}-docker-excluder exclude" when: - exclude_docker_excluder | default(false) | bool + - docker_excluder_stat.stat.exists + - name: Check for openshift excluder + stat: + path: /sbin/{{ openshift.common.service_type }}-excluder + register: openshift_excluder_stat - name: Enable openshift excluder command: "{{ openshift.common.service_type }}-excluder exclude" # if the openshift override is set, it means the openshift excluder is disabled no matter what # if the openshift override is not set, the excluder is set based on enable_openshift_excluder when: - exclude_openshift_excluder | default(false) | bool + - openshift_excluder_stat.stat.exists + when: - not openshift.common.is_atomic | bool diff --git a/roles/openshift_excluder/tasks/unexclude.yml b/roles/openshift_excluder/tasks/unexclude.yml index 9112adbac..4df7f14b4 100644 --- a/roles/openshift_excluder/tasks/unexclude.yml +++ b/roles/openshift_excluder/tasks/unexclude.yml @@ -3,15 +3,26 @@ # - unexclude_docker_excluder # - unexclude_openshift_excluder - block: + + - name: Check for docker-excluder + stat: + path: /sbin/{{ openshift.common.service_type }}-docker-excluder + register: docker_excluder_stat - name: disable docker excluder command: "{{ openshift.common.service_type }}-docker-excluder unexclude" when: - unexclude_docker_excluder | default(false) | bool + - docker_excluder_stat.stat.exists + - name: Check for openshift excluder + stat: + path: /sbin/{{ openshift.common.service_type }}-excluder + register: openshift_excluder_stat - name: disable openshift excluder command: "{{ openshift.common.service_type }}-excluder unexclude" when: - unexclude_openshift_excluder | default(false) | bool + - openshift_excluder_stat.stat.exists when: - not openshift.common.is_atomic | bool -- cgit v1.2.3 From 36b7f1bb7b036d619f224594c4fc08ed2b434a80 Mon Sep 17 00:00:00 2001 From: Scott Dodson Date: Mon, 20 Mar 2017 14:12:54 -0400 Subject: Get rid of adjust.yml --- roles/openshift_excluder/tasks/adjust.yml | 25 ------------------------- roles/openshift_excluder/tasks/disable.yml | 23 +++++++++++++++++++++-- 2 files changed, 21 insertions(+), 27 deletions(-) delete mode 100644 roles/openshift_excluder/tasks/adjust.yml diff --git a/roles/openshift_excluder/tasks/adjust.yml b/roles/openshift_excluder/tasks/adjust.yml deleted file mode 100644 index c32cd6070..000000000 --- a/roles/openshift_excluder/tasks/adjust.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -# Depending on enablement of individual excluders and their status -# some excluders needs to be disabled, resp. enabled -# By default, all excluders are disabled unless overrided. -- block: - - include: init.yml - # All excluders that are to be enabled are enabled - - include: exclude.yml - vars: - # Enable the docker excluder only if it is overrided - # BZ #1430612: docker excluders should be enabled even during installation and upgrade - exclude_docker_excluder: "{{ docker_excluder_on | bool }}" - # excluder is to be disabled by default - exclude_openshift_excluder: false - # All excluders that are to be disabled are disabled - - include: unexclude.yml - vars: - # If the docker override is not set, default to the generic behaviour - # BZ #1430612: docker excluders should be enabled even during installation and upgrade - unexclude_docker_excluder: false - # disable openshift excluder is never overrided to be enabled - # disable it if the docker excluder is enabled - unexclude_openshift_excluder: true - when: - - not openshift.common.is_atomic | bool diff --git a/roles/openshift_excluder/tasks/disable.yml b/roles/openshift_excluder/tasks/disable.yml index 988cda166..e23496b3b 100644 --- a/roles/openshift_excluder/tasks/disable.yml +++ b/roles/openshift_excluder/tasks/disable.yml @@ -17,5 +17,24 @@ # it the docker excluder is enabled, we install it and in case its status is non-zero # it is enabled no matter what - # And finally adjust an excluder in order to update host components correctly -- include: adjust.yml +# And finally adjust an excluder in order to update host components correctly. First +# exclude then unexclude +- block: + - include: exclude.yml + vars: + # Enable the docker excluder only if it is overrided + # BZ #1430612: docker excluders should be enabled even during installation and upgrade + exclude_docker_excluder: "{{ docker_excluder_on | bool }}" + # excluder is to be disabled by default + exclude_openshift_excluder: false + # All excluders that are to be disabled are disabled + - include: unexclude.yml + vars: + # If the docker override is not set, default to the generic behaviour + # BZ #1430612: docker excluders should be enabled even during installation and upgrade + unexclude_docker_excluder: false + # disable openshift excluder is never overrided to be enabled + # disable it if the docker excluder is enabled + unexclude_openshift_excluder: true + when: + - not openshift.common.is_atomic | bool -- cgit v1.2.3 From 0dc62b7550980a0627cb15796be3746f6a924a7d Mon Sep 17 00:00:00 2001 From: Scott Dodson Date: Mon, 20 Mar 2017 16:19:13 -0400 Subject: Attempt to match version of excluders to target version --- playbooks/common/openshift-cluster/disable_excluder.yml | 2 +- roles/openshift_excluder/tasks/install.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/playbooks/common/openshift-cluster/disable_excluder.yml b/playbooks/common/openshift-cluster/disable_excluder.yml index 68bffb5f5..f664c51c9 100644 --- a/playbooks/common/openshift-cluster/disable_excluder.yml +++ b/playbooks/common/openshift-cluster/disable_excluder.yml @@ -1,5 +1,5 @@ --- -- name: Record excluder state and disable +- name: Disable excluders hosts: oo_masters_to_config:oo_nodes_to_config gather_facts: no tasks: diff --git a/roles/openshift_excluder/tasks/install.yml b/roles/openshift_excluder/tasks/install.yml index dcc8df0cb..3490a613e 100644 --- a/roles/openshift_excluder/tasks/install.yml +++ b/roles/openshift_excluder/tasks/install.yml @@ -6,14 +6,14 @@ - name: Install docker excluder package: - name: "{{ openshift.common.service_type }}-docker-excluder" + name: "{{ openshift.common.service_type }}-docker-excluder{{ openshift_pkg_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) + '*' }}" state: "{{ docker_excluder_package_state }}" when: - install_docker_excluder | default(true) | bool - name: Install openshift excluder package: - name: "{{ openshift.common.service_type }}-excluder" + name: "{{ openshift.common.service_type }}-excluder{{ openshift_pkg_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) + '*' }}" state: "{{ openshift_excluder_package_state }}" when: - install_openshift_excluder | default(true) | bool -- cgit v1.2.3