Skip to content

Commit

Permalink
Merge pull request openshift#4176 from mtnbikenc/refactor-openshift_e…
Browse files Browse the repository at this point in the history
…xcluders

Merged by openshift-bot
  • Loading branch information
OpenShift Bot authored May 18, 2017
2 parents b1c0247 + c5c222e commit ed988a6
Show file tree
Hide file tree
Showing 19 changed files with 254 additions and 253 deletions.
16 changes: 8 additions & 8 deletions playbooks/common/openshift-cluster/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
tags:
- always
gather_facts: no
tasks:
- include_role:
name: openshift_excluder
tasks_from: disable
roles:
- role: openshift_excluder
r_openshift_excluder_action: disable
r_openshift_excluder_service_type: "{{ openshift.common.service_type }}"

- include: ../openshift-etcd/config.yml
tags:
Expand Down Expand Up @@ -50,7 +50,7 @@
tags:
- always
gather_facts: no
tasks:
- include_role:
name: openshift_excluder
tasks_from: enable
roles:
- role: openshift_excluder
r_openshift_excluder_action: enable
r_openshift_excluder_service_type: "{{ openshift.common.service_type }}"
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
- name: Disable excluders
hosts: oo_masters_to_config
gather_facts: no
tasks:
- include_role:
name: openshift_excluder
tasks_from: verify_upgrade
- include_role:
name: openshift_excluder
tasks_from: disable
vars:
openshift_excluder_package_state: latest
docker_excluder_package_state: latest
roles:
- role: openshift_excluder
r_openshift_excluder_action: disable
r_openshift_excluder_service_type: "{{ openshift.common.service_type }}"
r_openshift_excluder_verify_upgrade: true
r_openshift_excluder_upgrade_target: "{{ openshift_upgrade_target }}"
r_openshift_excluder_package_state: latest
r_openshift_excluder_docker_package_state: latest
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
- name: Disable excluders
hosts: oo_nodes_to_config
gather_facts: no
tasks:
- include_role:
name: openshift_excluder
tasks_from: verify_upgrade
- include_role:
name: openshift_excluder
tasks_from: disable
vars:
openshift_excluder_package_state: latest
docker_excluder_package_state: latest
roles:
- role: openshift_excluder
r_openshift_excluder_action: disable
r_openshift_excluder_service_type: "{{ openshift.common.service_type }}"
r_openshift_excluder_verify_upgrade: true
r_openshift_excluder_upgrade_target: "{{ openshift_upgrade_target }}"
r_openshift_excluder_package_state: latest
r_openshift_excluder_docker_package_state: latest
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
tags:
- always
gather_facts: no
tasks:
- include_role:
name: openshift_excluder
tasks_from: enable
roles:
- role: openshift_excluder
r_openshift_excluder_action: enable
r_openshift_excluder_service_type: "{{ openshift.common.service_type }}"
13 changes: 3 additions & 10 deletions playbooks/common/openshift-cluster/upgrades/upgrade_nodes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
- openshift_facts
- docker
- openshift_node_upgrade
- role: openshift_excluder
r_openshift_excluder_action: enable
r_openshift_excluder_service_type: "{{ openshift.common.service_type }}"

post_tasks:
- name: Set node schedulability
Expand All @@ -46,13 +49,3 @@
register: node_schedulable
until: node_schedulable|succeeded
when: node_unschedulable|changed

- name: Re-enable excluder if it was previously enabled
hosts: oo_nodes_to_config
tags:
- always
gather_facts: no
tasks:
- include_role:
name: openshift_excluder
tasks_from: enable
16 changes: 8 additions & 8 deletions playbooks/common/openshift-master/scaleup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@
tags:
- always
gather_facts: no
tasks:
- include_role:
name: openshift_excluder
tasks_from: disable
roles:
- role: openshift_excluder
r_openshift_excluder_action: disable
r_openshift_excluder_service_type: "{{ openshift.common.service_type }}"

- include: ../openshift-master/config.yml

Expand All @@ -81,7 +81,7 @@
tags:
- always
gather_facts: no
tasks:
- include_role:
name: openshift_excluder
tasks_from: enable
roles:
- role: openshift_excluder
r_openshift_excluder_action: enable
r_openshift_excluder_service_type: "{{ openshift.common.service_type }}"
16 changes: 8 additions & 8 deletions playbooks/common/openshift-node/scaleup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
tags:
- always
gather_facts: no
tasks:
- include_role:
name: openshift_excluder
tasks_from: disable
roles:
- role: openshift_excluder
r_openshift_excluder_action: disable
r_openshift_excluder_service_type: "{{ openshift.common.service_type }}"

- include: ../openshift-node/config.yml

Expand All @@ -44,7 +44,7 @@
tags:
- always
gather_facts: no
tasks:
- include_role:
name: openshift_excluder
tasks_from: enable
roles:
- role: openshift_excluder
r_openshift_excluder_action: enable
r_openshift_excluder_service_type: "{{ openshift.common.service_type }}"
65 changes: 42 additions & 23 deletions roles/openshift_excluder/README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,69 @@
OpenShift Excluder
================
==================

Manages the excluder packages which add yum and dnf exclusions ensuring that
the packages we care about are not inadvertantly updated. See
the packages we care about are not inadvertently updated. See
https://github.com/openshift/origin/tree/master/contrib/excluder

Requirements
------------
openshift_facts

None

Facts
-----
Inventory Variables
-------------------

| Name | Default Value | Description |
-----------------------------|---------------|----------------------------------------|
| 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
| Name | Default Value | Description |
---------------------------------------|----------------------------|----------------------------------------|
| openshift_enable_excluders | True | Enable all excluders |
| openshift_enable_docker_excluder | openshift_enable_excluders | Enable docker excluder. If not set, the docker excluder is ignored. |
| openshift_enable_openshift_excluder | openshift_enable_excluders | Enable openshift excluder. If not set, the openshift excluder is ignored. |

Role Variables
--------------
None

| Name | Default | Choices | Description |
|-------------------------------------------|---------|-----------------|---------------------------------------------------------------------------|
| r_openshift_excluder_action | enable | enable, disable | Action to perform when calling this role |
| r_openshift_excluder_verify_upgrade | false | true, false | When upgrading, this variable should be set to true when calling the role |
| r_openshift_excluder_package_state | present | present, latest | Use 'latest' to upgrade openshift_excluder package |
| r_openshift_excluder_docker_package_state | present | present, latest | Use 'latest' to upgrade docker_excluder package |
| r_openshift_excluder_service_type | None | | (Required) Defined as openshift.common.service_type e.g. atomic-openshift |
| r_openshift_excluder_upgrade_target | None | | Required when r_openshift_excluder_verify_upgrade is true, defined as openshift_upgrade_target by Upgrade playbooks e.g. '3.6'|

Dependencies
------------
- openshift_facts
- openshift_repos
- lib_utils

Tasks to include
----------------

- exclude: enable excluders
- unexclude: disable excluders
- install: install excluders (installation is followed by excluder enabling)
- enable: enable excluders (install excluder(s) if not installed)
- disabled: disable excluders (install excluder(s) if not installed)

- lib_utils

Example Playbook
----------------

```yaml
- name: Demonstrate OpenShift Excluder usage
hosts: oo_masters_to_config:oo_nodes_to_config
roles:
# Disable all excluders
- role: openshift_excluder
r_openshift_excluder_action: disable
r_openshift_excluder_service_type: "{{ openshift.common.service_type }}"
# Enable all excluders
- role: openshift_excluder
r_openshift_excluder_action: enable
r_openshift_excluder_service_type: "{{ openshift.common.service_type }}"
# Disable all excluders and verify appropriate excluder packages are available for upgrade
- role: openshift_excluder
r_openshift_excluder_action: disable
r_openshift_excluder_service_type: "{{ openshift.common.service_type }}"
r_openshift_excluder_verify_upgrade: true
r_openshift_excluder_upgrade_target: "{{ openshift_upgrade_target }}"
r_openshift_excluder_package_state: latest
r_openshift_excluder_docker_package_state: latest
```
TODO
----
It should be possible to manage the two excluders independently though that's not a hard requirement. However it should be done to manage docker on RHEL Containerized hosts.
License
Expand Down
19 changes: 16 additions & 3 deletions roles/openshift_excluder/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
---
# keep the 'current' package or update to 'latest' if available?
openshift_excluder_package_state: present
docker_excluder_package_state: present
r_openshift_excluder_package_state: present
r_openshift_excluder_docker_package_state: present

enable_excluders: true
# Legacy variables are included for backwards compatibility with v3.5
# Inventory variables Legacy
# openshift_enable_excluders enable_excluders
# openshift_enable_openshift_excluder enable_openshift_excluder
# openshift_enable_docker_excluder enable_docker_excluder
r_openshift_excluder_enable_excluders: "{{ openshift_enable_excluders | default(enable_excluders) | default(true) }}"
r_openshift_excluder_enable_openshift_excluder: "{{ openshift_enable_openshift_excluder | default(enable_openshift_excluder) | default(r_openshift_excluder_enable_excluders) }}"
r_openshift_excluder_enable_docker_excluder: "{{ openshift_enable_docker_excluder | default(enable_docker_excluder) | default(r_openshift_excluder_enable_excluders) }}"

# Default action when calling this role
r_openshift_excluder_action: enable

# When upgrading, this variable should be set to true when calling the role
r_openshift_excluder_verify_upgrade: false
6 changes: 2 additions & 4 deletions roles/openshift_excluder/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
galaxy_info:
author: Scott Dodson
description: OpenShift Examples
description: OpenShift Excluder
company: Red Hat, Inc.
license: Apache License, Version 2.0
min_ansible_version: 2.2
Expand All @@ -12,6 +12,4 @@ galaxy_info:
categories:
- cloud
dependencies:
- { role: openshift_facts }
- { role: openshift_repos }
- { role: lib_utils }
- role: lib_utils
65 changes: 28 additions & 37 deletions roles/openshift_excluder/tasks/disable.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,38 @@
---
# input variables
# - excluder_package_state
# - docker_excluder_package_state
- include: init.yml
- when: r_openshift_excluder_verify_upgrade
block:
- name: Include verify_upgrade.yml when upgrading
include: verify_upgrade.yml

# unexclude the current openshift/origin-excluder if it is installed so it can be updated
- include: unexclude.yml
- name: Disable OpenShift excluder so it can be updated
include: unexclude.yml
vars:
unexclude_docker_excluder: false
unexclude_openshift_excluder: "{{ openshift_excluder_on | bool }}"
when:
- not openshift.common.is_atomic | bool
unexclude_openshift_excluder: "{{ r_openshift_excluder_enable_openshift_excluder }}"

# Install any excluder that is enabled
- include: install.yml
vars:
# Both docker_excluder_on and openshift_excluder_on are set in openshift_excluder->init task
install_docker_excluder: "{{ docker_excluder_on | bool }}"
install_openshift_excluder: "{{ openshift_excluder_on | bool }}"
when: docker_excluder_on or openshift_excluder_on

# if the docker excluder is not enabled, we don't care about its status
# it the docker excluder is enabled, we install it and in case its status is non-zero
# it is enabled no matter what
- name: Include install.yml
include: install.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: "{{ openshift_excluder_on | bool }}"
when:
- not openshift.common.is_atomic | bool
- name: Include exclude.yml
include: exclude.yml
vars:
# Enable the docker excluder only if it is overridden
# BZ #1430612: docker excluders should be enabled even during installation and upgrade
exclude_docker_excluder: "{{ r_openshift_excluder_enable_docker_excluder }}"
# excluder is to be disabled by default
exclude_openshift_excluder: false

# All excluders that are to be disabled are disabled
- name: Include unexclude.yml
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 overridden to be enabled
# disable it if the docker excluder is enabled
unexclude_openshift_excluder: "{{ r_openshift_excluder_enable_openshift_excluder }}"
20 changes: 4 additions & 16 deletions roles/openshift_excluder/tasks/enable.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
---
# input variables:
- block:
- include: init.yml
- name: Install excluders
include: install.yml

- include: install.yml
vars:
install_docker_excluder: "{{ docker_excluder_on | bool }}"
install_openshift_excluder: "{{ openshift_excluder_on | bool }}"
when: docker_excluder_on or openshift_excluder_on | bool

- include: exclude.yml
vars:
exclude_docker_excluder: "{{ docker_excluder_on | bool }}"
exclude_openshift_excluder: "{{ openshift_excluder_on | bool }}"

when:
- not openshift.common.is_atomic | bool
- name: Enable excluders
include: exclude.yml
Loading

0 comments on commit ed988a6

Please sign in to comment.