diff options
46 files changed, 343 insertions, 184 deletions
diff --git a/.tito/packages/openshift-ansible b/.tito/packages/openshift-ansible index 1cd7bde30..c08bf1ac6 100644 --- a/.tito/packages/openshift-ansible +++ b/.tito/packages/openshift-ansible @@ -1 +1 @@ -3.6.15-1 ./ +3.6.16-1 ./ diff --git a/DEPLOYMENT_TYPES.md b/DEPLOYMENT_TYPES.md index 668d14fc0..42ac5635a 100644 --- a/DEPLOYMENT_TYPES.md +++ b/DEPLOYMENT_TYPES.md @@ -1,18 +1,17 @@ #Deployment Types -This module supports OpenShift Origin, OpenShift Enterprise, and Atomic -Enterprise Platform. Each deployment type sets various defaults used throughout -your environment. +This module supports OpenShift Origin and OpenShift Enterprise Each deployment +type sets various defaults used throughout your environment. The table below outlines the defaults per `deployment_type`. -| deployment_type | origin | enterprise (< 3.1) | atomic-enterprise | openshift-enterprise (>= 3.1) | -|-----------------------------------------------------------------|------------------------------------------|----------------------------------------|----------------------------------|----------------------------------| -| **openshift.common.service_type** (also used for package names) | origin | openshift | atomic-openshift | | -| **openshift.common.config_base** | /etc/origin | /etc/openshift | /etc/origin | /etc/origin | -| **openshift.common.data_dir** | /var/lib/origin | /var/lib/openshift | /var/lib/origin | /var/lib/origin | -| **openshift.master.registry_url openshift.node.registry_url** | openshift/origin-${component}:${version} | openshift3/ose-${component}:${version} | aos3/aos-${component}:${version} | aos3/aos-${component}:${version} | -| **Image Streams** | centos | rhel + xpaas | N/A | rhel | +| deployment_type | origin | enterprise (< 3.1) | openshift-enterprise (>= 3.1) | +|-----------------------------------------------------------------|------------------------------------------|----------------------------------------|----------------------------------| +| **openshift.common.service_type** (also used for package names) | origin | openshift | | +| **openshift.common.config_base** | /etc/origin | /etc/openshift | /etc/origin | +| **openshift.common.data_dir** | /var/lib/origin | /var/lib/openshift | /var/lib/origin | +| **openshift.master.registry_url openshift.node.registry_url** | openshift/origin-${component}:${version} | openshift3/ose-${component}:${version} | aos3/aos-${component}:${version} | +| **Image Streams** | centos | rhel + xpaas | rhel | **NOTE** `enterprise` deployment type is used for OpenShift Enterprise version diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py index a619f9ccb..b550bd16a 100644 --- a/filter_plugins/oo_filters.py +++ b/filter_plugins/oo_filters.py @@ -1,6 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- # vim: expandtab:tabstop=4:shiftwidth=4 +# pylint: disable=too-many-lines """ Custom filters for use in openshift-ansible """ @@ -21,13 +22,16 @@ import pkg_resources import yaml from ansible import errors -# pylint no-name-in-module and import-error disabled here because pylint -# fails to properly detect the packages when installed in a virtualenv -from ansible.compat.six import string_types # pylint:disable=no-name-in-module,import-error -from ansible.compat.six.moves.urllib.parse import urlparse # pylint:disable=no-name-in-module,import-error -from ansible.module_utils._text import to_text from ansible.parsing.yaml.dumper import AnsibleDumper +# ansible.compat.six goes away with Ansible 2.4 +try: + from ansible.compat.six import string_types, u + from ansible.compat.six.moves.urllib.parse import urlparse +except ImportError: + from ansible.module_utils.six import string_types, u + from ansible.module_utils.six.moves.urllib.parse import urlparse + HAS_OPENSSL = False try: import OpenSSL.crypto @@ -125,34 +129,57 @@ def oo_merge_hostvars(hostvars, variables, inventory_hostname): return merged_hostvars -def oo_collect(data, attribute=None, filters=None): +def oo_collect(data_list, 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. 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 - {'a':4, 'z': 'b'}, # FAILED, obj['z'] != obj['z'] - ] + Ex: data_list = [ {'a':1, 'b':5, 'z': 'z'}, # True, return + {'a':2, 'z': 'z'}, # True, return + {'a':3, 'z': 'z'}, # True, return + {'a':4, 'z': 'b'}, # FAILED, obj['z'] != obj['z'] + ] attribute = 'a' filters = {'z': 'z'} returns [1, 2, 3] + + This also deals with lists of lists with dict as elements. + Ex: data_list = [ + [ {'a':1, 'b':5, 'z': 'z'}, # True, return + {'a':2, 'b':6, 'z': 'z'} # True, return + ], + [ {'a':3, 'z': 'z'}, # True, return + {'a':4, 'z': 'b'} # FAILED, obj['z'] != obj['z'] + ], + {'a':5, 'z': 'z'}, # True, return + ] + attribute = 'a' + filters = {'z': 'z'} + returns [1, 2, 3, 5] """ - if not isinstance(data, list): - raise errors.AnsibleFilterError("|failed expects to filter on a List") + if not isinstance(data_list, list): + raise errors.AnsibleFilterError("oo_collect expects to filter on a List") if not attribute: - raise errors.AnsibleFilterError("|failed expects attribute to be set") + raise errors.AnsibleFilterError("oo_collect expects attribute to be set") + + data = [] + retval = [] + + for item in data_list: + if isinstance(item, list): + retval.extend(oo_collect(item, attribute, filters)) + else: + data.append(item) if filters is not None: if not isinstance(filters, dict): - raise errors.AnsibleFilterError("|failed expects filter to be a" - " dict") - retval = [get_attr(d, attribute) for d in data if ( - all([d.get(key, None) == filters[key] for key in filters]))] + raise errors.AnsibleFilterError( + "oo_collect expects filter to be a dict") + retval.extend([get_attr(d, attribute) for d in data if ( + all([d.get(key, None) == filters[key] for key in filters]))]) else: - retval = [get_attr(d, attribute) for d in data] + retval.extend([get_attr(d, attribute) for d in data]) retval = [val for val in retval if val is not None] @@ -655,11 +682,11 @@ def to_padded_yaml(data, level=0, indent=2, **kw): return "" try: - transformed = yaml.dump(data, indent=indent, allow_unicode=True, - default_flow_style=False, - Dumper=AnsibleDumper, **kw) + transformed = u(yaml.dump(data, indent=indent, allow_unicode=True, + default_flow_style=False, + Dumper=AnsibleDumper, **kw)) padded = "\n".join([" " * level * indent + line for line in transformed.splitlines()]) - return to_text("\n{0}".format(padded)) + return "\n{0}".format(padded) except Exception as my_e: raise errors.AnsibleFilterError('Failed to convert: %s' % my_e) diff --git a/openshift-ansible.spec b/openshift-ansible.spec index 992fe63c2..af30cbd5f 100644 --- a/openshift-ansible.spec +++ b/openshift-ansible.spec @@ -9,7 +9,7 @@ %global __requires_exclude ^/usr/bin/ansible-playbook$ Name: openshift-ansible -Version: 3.6.15 +Version: 3.6.16 Release: 1%{?dist} Summary: Openshift and Atomic Enterprise Ansible License: ASL 2.0 @@ -270,6 +270,34 @@ Atomic OpenShift Utilities includes %changelog +* Wed Apr 05 2017 Jenkins CD Merge Bot <tdawson@redhat.com> 3.6.16-1 +- Removing test coverage for shared code. (kwoodson@redhat.com) +- Port 10255 unnecessary. Removing all instances (ccallega@redhat.com) +- oo_filters: Disable pylint too-many-lines test (jarrpa@redhat.com) +- oo_collect: Allow list elements to be lists of dict (jarrpa@redhat.com) +- oc_label: handle case where _get() returns no results (jarrpa@redhat.com) +- Addressing py27-yamllint (esauer@redhat.com) +- Add 'docker-registry.default.svc' to cert-redeploy too (sdodson@redhat.com) +- Support unicode output when dumping yaml (rteague@redhat.com) +- Add docker-registry.default.svc short name to registry service signing + (sdodson@redhat.com) +- oc_configmap: Add missing check for name (jarrpa@redhat.com) +- oo_collect: Update comments to show source of failure (jarrpa@redhat.com) +- openshift_facts: Allow examples_content_version to be set to v1.6 + (jarrpa@redhat.com) +- Restart polkitd to workaround a bug in polkitd (sdodson@redhat.com) +- Add names to openshift_image_tag asserts (smilner@redhat.com) +- doc: Remove atomic-openshift deployment type (smilner@redhat.com) +- openshift_version now requires prepended version formats (smilner@redhat.com) +- Warn if openshift_image_tag is defined by hand for package installs + (smilner@redhat.com) +- Verify openshift_image_tag is valid during openshift_version main + (smilner@redhat.com) +- Add openshift_version fact fallback debug messages (smilner@redhat.com) +- cleanup: when in openshift_version tasks are multiline (smilner@redhat.com) +- Compatibility updates to openshift_logging role for ansible 2.2.2.0+ + (esauer@redhat.com) + * Tue Apr 04 2017 Jenkins CD Merge Bot <tdawson@redhat.com> 3.6.15-1 - Document etcd_ca_default_days in example inventories. (abutcher@redhat.com) - Fixed a bug. Ansible requires a msg param when module.fail_json. diff --git a/playbooks/openstack/openshift-cluster/files/heat_stack.yaml b/playbooks/openstack/openshift-cluster/files/heat_stack.yaml index 20ce47c07..82329eac1 100644 --- a/playbooks/openstack/openshift-cluster/files/heat_stack.yaml +++ b/playbooks/openstack/openshift-cluster/files/heat_stack.yaml @@ -340,16 +340,6 @@ resources: port_range_max: 10250 remote_mode: remote_group_id - direction: ingress - protocol: tcp - port_range_min: 10255 - port_range_max: 10255 - remote_mode: remote_group_id - - direction: ingress - protocol: udp - port_range_min: 10255 - port_range_max: 10255 - remote_mode: remote_group_id - - direction: ingress protocol: udp port_range_min: 4789 port_range_max: 4789 diff --git a/roles/lib_openshift/library/oc_adm_ca_server_cert.py b/roles/lib_openshift/library/oc_adm_ca_server_cert.py index 6a4e9b512..958498754 100644 --- a/roles/lib_openshift/library/oc_adm_ca_server_cert.py +++ b/roles/lib_openshift/library/oc_adm_ca_server_cert.py @@ -157,13 +157,13 @@ EXAMPLES = ''' # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1131,7 +1131,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod diff --git a/roles/lib_openshift/library/oc_adm_manage_node.py b/roles/lib_openshift/library/oc_adm_manage_node.py index 5f49eef39..5f1b94c3a 100644 --- a/roles/lib_openshift/library/oc_adm_manage_node.py +++ b/roles/lib_openshift/library/oc_adm_manage_node.py @@ -143,13 +143,13 @@ EXAMPLES = ''' # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1117,7 +1117,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod diff --git a/roles/lib_openshift/library/oc_adm_policy_group.py b/roles/lib_openshift/library/oc_adm_policy_group.py index 7caba04f5..423dbe44b 100644 --- a/roles/lib_openshift/library/oc_adm_policy_group.py +++ b/roles/lib_openshift/library/oc_adm_policy_group.py @@ -129,13 +129,13 @@ EXAMPLES = ''' # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1103,7 +1103,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod diff --git a/roles/lib_openshift/library/oc_adm_policy_user.py b/roles/lib_openshift/library/oc_adm_policy_user.py index aac3f7166..b72fce8bb 100644 --- a/roles/lib_openshift/library/oc_adm_policy_user.py +++ b/roles/lib_openshift/library/oc_adm_policy_user.py @@ -129,13 +129,13 @@ EXAMPLES = ''' # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1103,7 +1103,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod diff --git a/roles/lib_openshift/library/oc_adm_registry.py b/roles/lib_openshift/library/oc_adm_registry.py index b0345b026..273f38fb7 100644 --- a/roles/lib_openshift/library/oc_adm_registry.py +++ b/roles/lib_openshift/library/oc_adm_registry.py @@ -247,13 +247,13 @@ EXAMPLES = ''' # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1221,7 +1221,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod diff --git a/roles/lib_openshift/library/oc_adm_router.py b/roles/lib_openshift/library/oc_adm_router.py index 307269da4..16d4a8393 100644 --- a/roles/lib_openshift/library/oc_adm_router.py +++ b/roles/lib_openshift/library/oc_adm_router.py @@ -272,13 +272,13 @@ EXAMPLES = ''' # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1246,7 +1246,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod diff --git a/roles/lib_openshift/library/oc_clusterrole.py b/roles/lib_openshift/library/oc_clusterrole.py index 308a7d806..f05d47b63 100644 --- a/roles/lib_openshift/library/oc_clusterrole.py +++ b/roles/lib_openshift/library/oc_clusterrole.py @@ -121,13 +121,13 @@ EXAMPLES = ''' # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1095,7 +1095,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod diff --git a/roles/lib_openshift/library/oc_configmap.py b/roles/lib_openshift/library/oc_configmap.py index 96345ffe0..9f4748e0a 100644 --- a/roles/lib_openshift/library/oc_configmap.py +++ b/roles/lib_openshift/library/oc_configmap.py @@ -127,13 +127,13 @@ EXAMPLES = ''' # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1101,7 +1101,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod @@ -1524,6 +1524,10 @@ class OCConfigMap(OpenShiftCLI): if state == 'list': return {'changed': False, 'results': api_rval, 'state': state} + if not params['name']: + return {'failed': True, + 'msg': 'Please specify a name when state is absent|present.'} + ######## # Delete ######## diff --git a/roles/lib_openshift/library/oc_edit.py b/roles/lib_openshift/library/oc_edit.py index 99027c07f..df3c92845 100644 --- a/roles/lib_openshift/library/oc_edit.py +++ b/roles/lib_openshift/library/oc_edit.py @@ -171,13 +171,13 @@ oc_edit: # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1145,7 +1145,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod diff --git a/roles/lib_openshift/library/oc_env.py b/roles/lib_openshift/library/oc_env.py index 34f86a478..f96318f83 100644 --- a/roles/lib_openshift/library/oc_env.py +++ b/roles/lib_openshift/library/oc_env.py @@ -138,13 +138,13 @@ EXAMPLES = ''' # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1112,7 +1112,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod diff --git a/roles/lib_openshift/library/oc_group.py b/roles/lib_openshift/library/oc_group.py index 00d67108d..962af40c1 100644 --- a/roles/lib_openshift/library/oc_group.py +++ b/roles/lib_openshift/library/oc_group.py @@ -111,13 +111,13 @@ EXAMPLES = ''' # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1085,7 +1085,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod diff --git a/roles/lib_openshift/library/oc_image.py b/roles/lib_openshift/library/oc_image.py index ee918a2d1..047f49e6d 100644 --- a/roles/lib_openshift/library/oc_image.py +++ b/roles/lib_openshift/library/oc_image.py @@ -130,13 +130,13 @@ EXAMPLES = ''' # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1104,7 +1104,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod diff --git a/roles/lib_openshift/library/oc_label.py b/roles/lib_openshift/library/oc_label.py index 62b6049c4..700fe6d20 100644 --- a/roles/lib_openshift/library/oc_label.py +++ b/roles/lib_openshift/library/oc_label.py @@ -147,13 +147,13 @@ EXAMPLES = ''' # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1121,7 +1121,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod @@ -1551,9 +1551,9 @@ class OCLabel(OpenShiftCLI): label_list = [] if self.name: - result = self._get(resource=self.kind, rname=self.name, selector=self.selector) + result = self._get(resource=self.kind, rname=self.name) - if 'labels' in result['results'][0]['metadata']: + if result['results'][0] and 'labels' in result['results'][0]['metadata']: label_list.append(result['results'][0]['metadata']['labels']) else: label_list.append({}) diff --git a/roles/lib_openshift/library/oc_obj.py b/roles/lib_openshift/library/oc_obj.py index 075c286e0..9a1eefa3b 100644 --- a/roles/lib_openshift/library/oc_obj.py +++ b/roles/lib_openshift/library/oc_obj.py @@ -150,13 +150,13 @@ register: router_output # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1124,7 +1124,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod diff --git a/roles/lib_openshift/library/oc_objectvalidator.py b/roles/lib_openshift/library/oc_objectvalidator.py index d65e1d4c9..297ae6cda 100644 --- a/roles/lib_openshift/library/oc_objectvalidator.py +++ b/roles/lib_openshift/library/oc_objectvalidator.py @@ -82,13 +82,13 @@ oc_objectvalidator: # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1056,7 +1056,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod diff --git a/roles/lib_openshift/library/oc_process.py b/roles/lib_openshift/library/oc_process.py index 112d9ab5f..7d5b6a751 100644 --- a/roles/lib_openshift/library/oc_process.py +++ b/roles/lib_openshift/library/oc_process.py @@ -139,13 +139,13 @@ EXAMPLES = ''' # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1113,7 +1113,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod diff --git a/roles/lib_openshift/library/oc_project.py b/roles/lib_openshift/library/oc_project.py index 3fddce055..005195dff 100644 --- a/roles/lib_openshift/library/oc_project.py +++ b/roles/lib_openshift/library/oc_project.py @@ -136,13 +136,13 @@ EXAMPLES = ''' # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1110,7 +1110,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod diff --git a/roles/lib_openshift/library/oc_pvc.py b/roles/lib_openshift/library/oc_pvc.py index d63f6e063..2cab01d50 100644 --- a/roles/lib_openshift/library/oc_pvc.py +++ b/roles/lib_openshift/library/oc_pvc.py @@ -131,13 +131,13 @@ EXAMPLES = ''' # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1105,7 +1105,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod diff --git a/roles/lib_openshift/library/oc_route.py b/roles/lib_openshift/library/oc_route.py index daddec69f..e1a96ee94 100644 --- a/roles/lib_openshift/library/oc_route.py +++ b/roles/lib_openshift/library/oc_route.py @@ -181,13 +181,13 @@ EXAMPLES = ''' # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1155,7 +1155,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod diff --git a/roles/lib_openshift/library/oc_scale.py b/roles/lib_openshift/library/oc_scale.py index 92e9362be..9ebabc9cc 100644 --- a/roles/lib_openshift/library/oc_scale.py +++ b/roles/lib_openshift/library/oc_scale.py @@ -125,13 +125,13 @@ EXAMPLES = ''' # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1099,7 +1099,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod diff --git a/roles/lib_openshift/library/oc_secret.py b/roles/lib_openshift/library/oc_secret.py index 1ffdce4df..c61139bb9 100644 --- a/roles/lib_openshift/library/oc_secret.py +++ b/roles/lib_openshift/library/oc_secret.py @@ -171,13 +171,13 @@ EXAMPLES = ''' # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1145,7 +1145,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod diff --git a/roles/lib_openshift/library/oc_service.py b/roles/lib_openshift/library/oc_service.py index 77056d5de..855eaade1 100644 --- a/roles/lib_openshift/library/oc_service.py +++ b/roles/lib_openshift/library/oc_service.py @@ -177,13 +177,13 @@ EXAMPLES = ''' # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1151,7 +1151,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod diff --git a/roles/lib_openshift/library/oc_serviceaccount.py b/roles/lib_openshift/library/oc_serviceaccount.py index 807bfc992..6b2bb8469 100644 --- a/roles/lib_openshift/library/oc_serviceaccount.py +++ b/roles/lib_openshift/library/oc_serviceaccount.py @@ -123,13 +123,13 @@ EXAMPLES = ''' # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1097,7 +1097,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod diff --git a/roles/lib_openshift/library/oc_serviceaccount_secret.py b/roles/lib_openshift/library/oc_serviceaccount_secret.py index c8f4ebef7..881331456 100644 --- a/roles/lib_openshift/library/oc_serviceaccount_secret.py +++ b/roles/lib_openshift/library/oc_serviceaccount_secret.py @@ -123,13 +123,13 @@ EXAMPLES = ''' # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1097,7 +1097,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod diff --git a/roles/lib_openshift/library/oc_user.py b/roles/lib_openshift/library/oc_user.py index aa9f07980..a14248e45 100644 --- a/roles/lib_openshift/library/oc_user.py +++ b/roles/lib_openshift/library/oc_user.py @@ -183,13 +183,13 @@ ok: [ded-int-aws-master-61034] => { # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1157,7 +1157,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod diff --git a/roles/lib_openshift/library/oc_version.py b/roles/lib_openshift/library/oc_version.py index eb293322d..947591991 100644 --- a/roles/lib_openshift/library/oc_version.py +++ b/roles/lib_openshift/library/oc_version.py @@ -95,13 +95,13 @@ oc_version: # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1069,7 +1069,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod diff --git a/roles/lib_openshift/library/oc_volume.py b/roles/lib_openshift/library/oc_volume.py index 23b292763..607d2e57a 100644 --- a/roles/lib_openshift/library/oc_volume.py +++ b/roles/lib_openshift/library/oc_volume.py @@ -160,13 +160,13 @@ EXAMPLES = ''' # -*- -*- -*- Begin included fragment: ../../lib_utils/src/class/yedit.py -*- -*- -*- -class YeditException(Exception): +class YeditException(Exception): # pragma: no cover ''' Exception class for Yedit ''' pass # pylint: disable=too-many-public-methods -class Yedit(object): +class Yedit(object): # pragma: no cover ''' Class to modify yaml files ''' re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$" re_key = r"(?:\[(-?\d+)\])|([0-9a-zA-Z%s/_-]+)" @@ -1134,7 +1134,7 @@ class OpenShiftCLI(object): return rval -class Utils(object): +class Utils(object): # pragma: no cover ''' utilities for openshiftcli modules ''' @staticmethod diff --git a/roles/lib_openshift/src/class/oc_configmap.py b/roles/lib_openshift/src/class/oc_configmap.py index 87de3e1df..de77d1102 100644 --- a/roles/lib_openshift/src/class/oc_configmap.py +++ b/roles/lib_openshift/src/class/oc_configmap.py @@ -127,6 +127,10 @@ class OCConfigMap(OpenShiftCLI): if state == 'list': return {'changed': False, 'results': api_rval, 'state': state} + if not params['name']: + return {'failed': True, + 'msg': 'Please specify a name when state is absent|present.'} + ######## # Delete ######## diff --git a/roles/lib_openshift/src/class/oc_label.py b/roles/lib_openshift/src/class/oc_label.py index bd312c170..ed17eecb1 100644 --- a/roles/lib_openshift/src/class/oc_label.py +++ b/roles/lib_openshift/src/class/oc_label.py @@ -134,9 +134,9 @@ class OCLabel(OpenShiftCLI): label_list = [] if self.name: - result = self._get(resource=self.kind, rname=self.name, selector=self.selector) + result = self._get(resource=self.kind, rname=self.name) - if 'labels' in result['results'][0]['metadata']: + if result['results'][0] and 'labels' in result['results'][0]['metadata']: label_list.append(result['results'][0]['metadata']['labels']) else: label_list.append({}) diff --git a/roles/lib_openshift/src/generate.py b/roles/lib_openshift/src/generate.py index 3f23455b5..2570f51dd 100755 --- a/roles/lib_openshift/src/generate.py +++ b/roles/lib_openshift/src/generate.py @@ -5,12 +5,16 @@ import argparse import os +import re import yaml import six OPENSHIFT_ANSIBLE_PATH = os.path.dirname(os.path.realpath(__file__)) OPENSHIFT_ANSIBLE_SOURCES_PATH = os.path.join(OPENSHIFT_ANSIBLE_PATH, 'sources.yml') # noqa: E501 LIBRARY = os.path.join(OPENSHIFT_ANSIBLE_PATH, '..', 'library/') +SKIP_COVERAGE_PATTERN = [re.compile('class Yedit.*$'), + re.compile('class Utils.*$')] +PRAGMA_STRING = ' # pragma: no cover' class GenerateAnsibleException(Exception): @@ -72,6 +76,11 @@ def generate(parts): if idx in [0, 1] and 'flake8: noqa' in line or 'pylint: skip-file' in line: # noqa: E501 continue + for skip in SKIP_COVERAGE_PATTERN: + if re.match(skip, line): + line = line.strip() + line += PRAGMA_STRING + os.linesep + data.write(line) fragment_banner(fpart, "footer", data) diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index e1f4c4e6d..7edf141e5 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -936,7 +936,9 @@ def set_version_facts_if_unset(facts): facts['common']['version_gte_3_5_or_1_5'] = version_gte_3_5_or_1_5 facts['common']['version_gte_3_6_or_1_6'] = version_gte_3_6_or_1_6 - if version_gte_3_5_or_1_5: + if version_gte_3_6_or_1_6: + examples_content_version = 'v1.6' + elif version_gte_3_5_or_1_5: examples_content_version = 'v1.5' elif version_gte_3_4_or_1_4: examples_content_version = 'v1.4' diff --git a/roles/openshift_logging/tasks/generate_pems.yaml b/roles/openshift_logging/tasks/generate_pems.yaml index 289b72ea6..e8cececfb 100644 --- a/roles/openshift_logging/tasks/generate_pems.yaml +++ b/roles/openshift_logging/tasks/generate_pems.yaml @@ -15,6 +15,7 @@ -subj "/CN={{component}}/OU=OpenShift/O=Logging/subjectAltName=DNS.1=localhost{{cert_ext.stdout}}" -days 712 -nodes when: - not key_file.stat.exists + - cert_ext is defined - cert_ext.stdout is defined check_mode: no @@ -24,7 +25,7 @@ -subj "/CN={{component}}/OU=OpenShift/O=Logging" -days 712 -nodes when: - not key_file.stat.exists - - cert_ext.stdout is undefined + - cert_ext is undefined or cert_ext is defined and cert_ext.stdout is undefined check_mode: no - name: Sign cert request with CA for {{component}} diff --git a/roles/openshift_logging/tasks/procure_server_certs.yaml b/roles/openshift_logging/tasks/procure_server_certs.yaml index 44dd5e894..7ab140357 100644 --- a/roles/openshift_logging/tasks/procure_server_certs.yaml +++ b/roles/openshift_logging/tasks/procure_server_certs.yaml @@ -11,12 +11,18 @@ - name: Trying to discover server cert variable name for {{ cert_info.procure_component }} set_fact: procure_component_crt={{ lookup('env', '{{cert_info.procure_component}}' + '_crt') }} - when: cert_info.hostnames is undefined and {{ cert_info.procure_component }}_crt is defined and {{ cert_info.procure_component }}_key is defined + when: + - cert_info.hostnames is undefined + - cert_info[ cert_info.procure_component + '_crt' ] is defined + - cert_info[ cert_info.procure_component + '_key' ] is defined check_mode: no - name: Trying to discover the server key variable name for {{ cert_info.procure_component }} set_fact: procure_component_key={{ lookup('env', '{{cert_info.procure_component}}' + '_key') }} - when: cert_info.hostnames is undefined and {{ cert_info.procure_component }}_crt is defined and {{ cert_info.procure_component }}_key is defined + when: + - cert_info.hostnames is undefined + - cert_info[ cert_info.procure_component + '_crt' ] is defined + - cert_info[ cert_info.procure_component + '_key' ] is defined check_mode: no - name: Creating signed server cert and key for {{ cert_info.procure_component }} @@ -27,26 +33,26 @@ --signer-serial={{generated_certs_dir}}/ca.serial.txt check_mode: no when: - - cert_info.hostnames is defined - - not component_key_file.stat.exists - - not component_cert_file.stat.exists + - cert_info.hostnames is defined + - not component_key_file.stat.exists + - not component_cert_file.stat.exists - name: Copying server key for {{ cert_info.procure_component }} to generated certs directory copy: content="{{procure_component_key}}" dest={{generated_certs_dir}}/{{cert_info.procure_component}}.key check_mode: no when: - - cert_info.hostnames is undefined - - "{{ cert_info.procure_component }}_crt is defined" - - "{{ cert_info.procure_component }}_key is defined" - - not component_key_file.stat.exists - - not component_cert_file.stat.exists + - cert_info.hostnames is undefined + - cert_info[ cert_info.procure_component + '_crt' ] is defined + - cert_info[ cert_info.procure_component + '_key' ] is defined + - not component_key_file.stat.exists + - not component_cert_file.stat.exists - name: Copying Server cert for {{ cert_info.procure_component }} to generated certs directory copy: content="{{procure_component_crt}}" dest={{generated_certs_dir}}/{{cert_info.procure_component}}.crt check_mode: no when: - - cert_info.hostnames is undefined - - "{{ cert_info.procure_component }}_crt is defined" - - "{{ cert_info.procure_component }}_key is defined" - - not component_key_file.stat.exists - - not component_cert_file.stat.exists + - cert_info.hostnames is undefined + - cert_info[ cert_info.procure_component + '_crt' ] is defined + - cert_info[ cert_info.procure_component + '_key' ] is defined + - not component_key_file.stat.exists + - not component_cert_file.stat.exists diff --git a/roles/openshift_master_facts/filter_plugins/openshift_master.py b/roles/openshift_master_facts/filter_plugins/openshift_master.py index 01806c97f..e570392ff 100644 --- a/roles/openshift_master_facts/filter_plugins/openshift_master.py +++ b/roles/openshift_master_facts/filter_plugins/openshift_master.py @@ -14,9 +14,12 @@ from distutils.version import LooseVersion # pylint: disable=no-name-in-module, from ansible import errors from ansible.parsing.yaml.dumper import AnsibleDumper from ansible.plugins.filter.core import to_bool as ansible_bool -# pylint import-error disabled because pylint cannot find the package -# when installed in a virtualenv -from ansible.compat.six import string_types # pylint: disable=no-name-in-module,import-error + +# ansible.compat.six goes away with Ansible 2.4 +try: + from ansible.compat.six import string_types, u +except ImportError: + from ansible.module_utils.six import string_types, u import yaml @@ -490,10 +493,10 @@ class FilterModule(object): idp_list.append(idp_inst) IdentityProviderBase.validate_idp_list(idp_list, openshift_version, deployment_type) - return yaml.dump([idp.to_dict() for idp in idp_list], - allow_unicode=True, - default_flow_style=False, - Dumper=AnsibleDumper) + return u(yaml.dump([idp.to_dict() for idp in idp_list], + allow_unicode=True, + default_flow_style=False, + Dumper=AnsibleDumper)) @staticmethod def validate_pcs_cluster(data, masters=None): diff --git a/roles/openshift_node/defaults/main.yml b/roles/openshift_node/defaults/main.yml index fffbf2994..bd95f8526 100644 --- a/roles/openshift_node/defaults/main.yml +++ b/roles/openshift_node/defaults/main.yml @@ -6,10 +6,6 @@ os_firewall_allow: port: 80/tcp - service: https port: 443/tcp -- service: Openshift kubelet ReadOnlyPort - port: 10255/tcp -- service: Openshift kubelet ReadOnlyPort udp - port: 10255/udp - service: OpenShift OVS sdn port: 4789/udp when: openshift.node.use_openshift_sdn | bool diff --git a/roles/openshift_node/meta/main.yml b/roles/openshift_node/meta/main.yml index c97ff1b4b..0da41d0c1 100644 --- a/roles/openshift_node/meta/main.yml +++ b/roles/openshift_node/meta/main.yml @@ -26,10 +26,6 @@ dependencies: port: 80/tcp - service: https port: 443/tcp - - service: Openshift kubelet ReadOnlyPort - port: 10255/tcp - - service: Openshift kubelet ReadOnlyPort udp - port: 10255/udp - role: os_firewall os_firewall_allow: - service: OpenShift OVS sdn diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml index 35953b744..c3d001bb4 100644 --- a/roles/openshift_version/tasks/main.yml +++ b/roles/openshift_version/tasks/main.yml @@ -9,16 +9,55 @@ # be used by default. Users must indicate what they want. - fail: msg: "Must specify openshift_release or openshift_image_tag in inventory to install origin. (suggestion: add openshift_release=\"1.2\" to inventory)" - when: is_containerized | bool and openshift.common.deployment_type == 'origin' and openshift_release is not defined and openshift_image_tag is not defined + when: + - is_containerized | bool + - openshift.common.deployment_type == 'origin' + - openshift_release is not defined + - openshift_image_tag is not defined # Normalize some values that we need in a certain format that might be confusing: - set_fact: - openshift_image_tag: "{{ 'v' + openshift_image_tag }}" - when: openshift_image_tag is defined and openshift_image_tag[0] != 'v' and openshift_image_tag != 'latest' + openshift_release: "{{ openshift_release[1:] }}" + when: + - openshift_release is defined + - openshift_release[0] == 'v' - set_fact: - openshift_pkg_version: "{{ '-' + openshift_pkg_version }}" - when: openshift_pkg_version is defined and openshift_pkg_version[0] != '-' + openshift_release: "{{ openshift_release | string }}" + when: openshift_release is defined + +# Verify that the image tag is in a valid format +- block: + + # Verifies that when the deployment type is origin the version: + # - starts with a v + # - Has 3 integers seperated by dots + # It also allows for optional trailing data which: + # - must start with a dash + # - may contain numbers, letters, dashes and dots. + - name: Verify Origin openshift_image_tag is valid + assert: + that: + - "{{ openshift_image_tag|match('(^v?\\d+\\.\\d+\\.\\d+(-[\\w\\-\\.]*)?$)') }}" + msg: "openshift_image_tag must be in the format v#.#.#[-optional.#]. Examples: v1.2.3, v3.5.1-alpha.1" + when: openshift.common.deployment_type == 'origin' + + # Verifies that when the deployment type is openshift-enterprise the version: + # - starts with a v + # - Has at least 2 integers seperated by dots + # It also allows for optional trailing data which: + # - must start with a dash + # - may contain numbers + - name: Verify Enterprise openshift_image_tag is valid + assert: + that: + - "{{ openshift_image_tag|match('(^v\\d+\\.\\d+[\\.\\d+]*(-\\d+)?$)') }}" + msg: "openshift_image_tag must be in the format v#.#[.#[.#]]. Examples: v1.2, v3.4.1, v3.5.1.3, v1.2-1, v1.2.3-4" + when: openshift.common.deployment_type == 'openshift-enterprise' + + when: + - openshift_image_tag is defined + - openshift_image_tag != "latest" # Make sure we copy this to a fact if given a var: - set_fact: @@ -30,7 +69,10 @@ - name: Use openshift.common.version fact as version to configure if already installed set_fact: openshift_version: "{{ openshift.common.version }}" - when: openshift.common.version is defined and openshift_version is not defined and openshift_protect_installed_version | bool + when: + - openshift.common.version is defined + - openshift_version is not defined + - openshift_protect_installed_version | bool - name: Set openshift_version for rpm installation include: set_version_rpm.yml @@ -40,17 +82,39 @@ include: set_version_containerized.yml when: is_containerized | bool +# Warn if the user has provided an openshift_image_tag but is not doing a containerized install +# NOTE: This will need to be modified/removed for future container + rpm installations work. +- name: Warn if openshift_image_tag is defined when not doing a containerized install + debug: + msg: > + openshift_image_tag is used for containerized installs. If you are trying to + specify an image for a non-container install see oreg_url. + when: + - not is_containerized | bool + - openshift_image_tag is defined + + # At this point we know openshift_version is set appropriately. Now we set # openshift_image_tag and openshift_pkg_version, so all roles can always assume # each of this variables *will* be set correctly and can use them per their # intended purpose. -- set_fact: - openshift_image_tag: v{{ openshift_version }} +- block: + - debug: + msg: "openshift_image_tag was not defined. Falling back to v{{ openshift_version }}" + + - set_fact: + openshift_image_tag: v{{ openshift_version }} + when: openshift_image_tag is not defined -- set_fact: - openshift_pkg_version: -{{ openshift_version }} +- block: + - debug: + msg: "openshift_pkg_version was not defined. Falling back to -{{ openshift_version }}" + + - set_fact: + openshift_pkg_version: -{{ openshift_version }} + when: openshift_pkg_version is not defined - fail: @@ -67,13 +131,18 @@ - fail: msg: "No OpenShift version available, please ensure your systems are fully registered and have access to appropriate yum repositories." - when: not is_containerized | bool and openshift_version == '0.0' + when: + - not is_containerized | bool + - openshift_version == '0.0' # We can't map an openshift_release to full rpm version like we can with containers, make sure # the rpm version we looked up matches the release requested and error out if not. - fail: msg: "Detected OpenShift version {{ openshift_version }} does not match requested openshift_release {{ openshift_release }}. You may need to adjust your yum repositories, inventory, or run the appropriate OpenShift upgrade playbook." - when: not is_containerized | bool and openshift_release is defined and not openshift_version.startswith(openshift_release) | bool + when: + - not is_containerized | bool + - openshift_release is defined + - not openshift_version.startswith(openshift_release) | bool # The end result of these three variables is quite important so make sure they are displayed and logged: - debug: var=openshift_release diff --git a/roles/openshift_version/tasks/set_version_containerized.yml b/roles/openshift_version/tasks/set_version_containerized.yml index cd0f20ae9..0ec4c49d6 100644 --- a/roles/openshift_version/tasks/set_version_containerized.yml +++ b/roles/openshift_version/tasks/set_version_containerized.yml @@ -4,12 +4,16 @@ # Expects a leading "v" in inventory, strip it off here unless # openshift_image_tag=latest openshift_version: "{{ openshift_image_tag[1:].split('-')[0] if openshift_image_tag != 'latest' else openshift_image_tag }}" - when: openshift_image_tag is defined and openshift_version is not defined + when: + - openshift_image_tag is defined + - openshift_version is not defined - name: Set containerized version to configure if openshift_release specified set_fact: openshift_version: "{{ openshift_release }}" - when: openshift_release is defined and openshift_version is not defined + when: + - openshift_release is defined + - openshift_version is not defined - name: Lookup latest containerized version if no version specified command: > @@ -20,7 +24,10 @@ # Origin latest = pre-release version (i.e. v1.3.0-alpha.1-321-gb095e3a) - set_fact: openshift_version: "{{ (cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0:2] | join('-'))[1:] }}" - when: openshift_version is not defined and openshift.common.deployment_type == 'origin' and cli_image_version.stdout_lines[0].split('-') | length > 1 + when: + - openshift_version is not defined + - openshift.common.deployment_type == 'origin' + - cli_image_version.stdout_lines[0].split('-') | length > 1 - set_fact: openshift_version: "{{ cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0][1:] }}" @@ -32,11 +39,15 @@ command: > docker run --rm {{ openshift.common.cli_image }}:v{{ openshift_version }} version register: cli_image_version - when: openshift_version is defined and openshift_version.split('.') | length == 2 + when: + - openshift_version is defined + - openshift_version.split('.') | length == 2 - set_fact: openshift_version: "{{ cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0:2][1:] | join('-') if openshift.common.deployment_type == 'origin' else cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0][1:] }}" - when: openshift_version is defined and openshift_version.split('.') | length == 2 + when: + - openshift_version is defined + - openshift_version.split('.') | length == 2 # We finally have the specific version. Now we clean up any strange # dangly +c0mm1t-offset tags in the version. See also, diff --git a/roles/openshift_version/tasks/set_version_rpm.yml b/roles/openshift_version/tasks/set_version_rpm.yml index 0c2ef4bb7..c7604af1a 100644 --- a/roles/openshift_version/tasks/set_version_rpm.yml +++ b/roles/openshift_version/tasks/set_version_rpm.yml @@ -3,7 +3,9 @@ set_fact: # Expects a leading "-" in inventory, strip it off here, and remove trailing release, openshift_version: "{{ openshift_pkg_version[1:].split('-')[0] }}" - when: openshift_pkg_version is defined and openshift_version is not defined + when: + - openshift_pkg_version is defined + - openshift_version is not defined # if {{ openshift.common.service_type}}-excluder is enabled, # the repoquery for {{ openshift.common.service_type}} will not work. diff --git a/roles/os_firewall/tasks/firewall/firewalld.yml b/roles/os_firewall/tasks/firewall/firewalld.yml index 2b40eee1b..4b2979887 100644 --- a/roles/os_firewall/tasks/firewall/firewalld.yml +++ b/roles/os_firewall/tasks/firewall/firewalld.yml @@ -34,6 +34,12 @@ pause: seconds=10 when: result | changed +- name: Restart polkitd + systemd: + name: polkit + state: restarted + when: result | changed + # Fix suspected race between firewalld and polkit BZ1436964 - name: Wait for polkit action to have been created command: pkaction --action-id=org.fedoraproject.FirewallD1.config.info diff --git a/utils/src/ooinstall/ansible_plugins/facts_callback.py b/utils/src/ooinstall/ansible_plugins/facts_callback.py index c881e4b92..433e29dde 100644 --- a/utils/src/ooinstall/ansible_plugins/facts_callback.py +++ b/utils/src/ooinstall/ansible_plugins/facts_callback.py @@ -7,6 +7,12 @@ import yaml from ansible.plugins.callback import CallbackBase from ansible.parsing.yaml.dumper import AnsibleDumper +# ansible.compat.six goes away with Ansible 2.4 +try: + from ansible.compat.six import u +except ImportError: + from ansible.module_utils.six import u + # pylint: disable=super-init-not-called class CallbackModule(CallbackBase): @@ -39,10 +45,10 @@ class CallbackModule(CallbackBase): facts = abridged_result['result']['ansible_facts']['openshift'] hosts_yaml = {} hosts_yaml[res._host.get_name()] = facts - to_dump = yaml.dump(hosts_yaml, - allow_unicode=True, - default_flow_style=False, - Dumper=AnsibleDumper) + to_dump = u(yaml.dump(hosts_yaml, + allow_unicode=True, + default_flow_style=False, + Dumper=AnsibleDumper)) os.write(self.hosts_yaml, to_dump) def v2_runner_on_skipped(self, res): |