summaryrefslogtreecommitdiffstats
path: root/roles
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2017-09-23 04:24:43 -0700
committerGitHub <noreply@github.com>2017-09-23 04:24:43 -0700
commit447ec08f82ff32cd9bf7b85dcfaef5313fc1f291 (patch)
tree9765c3395c239cf26e726c58b4b3682973fd331b /roles
parente1650a2e1da3b1a365a8e4f021d1c55fe4ffc72d (diff)
parent3ebc0b591f9445b8fde65bda3f76666bad2c8ca3 (diff)
downloadopenshift-447ec08f82ff32cd9bf7b85dcfaef5313fc1f291.tar.gz
openshift-447ec08f82ff32cd9bf7b85dcfaef5313fc1f291.tar.bz2
openshift-447ec08f82ff32cd9bf7b85dcfaef5313fc1f291.tar.xz
openshift-447ec08f82ff32cd9bf7b85dcfaef5313fc1f291.zip
Merge pull request #5384 from joelddiaz/node-fact-filter
Automatic merge from submit-queue move (and rename) get_dns_ip filter into openshift_node_facts Due to recent changes to filter_plugins/openshift_node.py, when trying to run a current version of the openshift_node_facts role on a system with an older version of the openshift-ansible-filter-plugins RPM, the new role will fail. ``` File "/usr/share/ansible_plugins/filter_plugins/openshift_node.py", line 30, in get_dns_ip if bool(hostvars['openshift']['common']['use_dnsmasq']): KeyError: 'use_dnsmasq' ``` It's not possible for us to have our current RPM version (presently openshift-ansible-filter-plugins-3.5.120-1.git.0.c60f69a.el7.noarch) and a newer RPM installed and run both current openshift-ansible code and older checked-out/vendored releases (for older clusters/releases). Since only the openshift_node_facts role uses the get_dns_ip filter, move the functionality into a role-specific filter plugin. In addition, rename the filter plugin to 'node_get_dns_ip' because Ansible is preffering the get_dns_ip from the RPM (ie /usr/share/ansible_plugins/filter_plugins/openshift_node.py) over the role-specific filter plugin of the same name. Ansile prefers the filter plugins in /usr/share/ansible_plugins/filter_plugins/* even when /etc/ansible/ansible.cfg is set to something like: filter_plugins = filter_plugins:/usr/share/ansible_plugins/filter_plugins:filter_plugins <--- yes, 'filter_plugins' before and after /usr/share/ansible_plugins/filter_plugins (ansible 2.3.1.0) (perhaps this is because the /usr/share/ansible/plugins/filter symlink to /usr/share/ansible_plugins/filter_plugins takes precedence over everything???) Renaming the filter plugin function ensures that versions of the openshift_node_facts role that depend on the old implementation can continue to use it through what the older RPM provides, and the new role can use it's role-specific filter plugin without any variable namespace collisions. Lastly, remove filter_plugins/openshift_node.py since it is now self-contained in roles/openshift_node_facts. https://bugzilla.redhat.com/show_bug.cgi?id=1494312
Diffstat (limited to 'roles')
-rw-r--r--roles/openshift_node_facts/filter_plugins/filters.py32
-rw-r--r--roles/openshift_node_facts/tasks/main.yml2
2 files changed, 33 insertions, 1 deletions
diff --git a/roles/openshift_node_facts/filter_plugins/filters.py b/roles/openshift_node_facts/filter_plugins/filters.py
new file mode 100644
index 000000000..69069f2dc
--- /dev/null
+++ b/roles/openshift_node_facts/filter_plugins/filters.py
@@ -0,0 +1,32 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+'''
+Custom filters for use in openshift-node
+'''
+from ansible import errors
+
+
+class FilterModule(object):
+ ''' Custom ansible filters for use by openshift_node_facts role'''
+
+ @staticmethod
+ def node_get_dns_ip(openshift_dns_ip, hostvars):
+ ''' Navigates the complicated logic of when to set dnsIP
+
+ In all situations if they've set openshift_dns_ip use that
+ For 1.0/3.0 installs we use the openshift_master_cluster_vip, openshift_node_first_master_ip, else None
+ For 1.1/3.1 installs we use openshift_master_cluster_vip, else None (product will use kube svc ip)
+ For 1.2/3.2+ installs we set to the node's default interface ip
+ '''
+
+ if not issubclass(type(hostvars), dict):
+ raise errors.AnsibleFilterError("|failed expects hostvars is a dict")
+
+ # We always use what they've specified if they've specified a value
+ if openshift_dns_ip is not None:
+ return openshift_dns_ip
+ return hostvars['ansible_default_ipv4']['address']
+
+ def filters(self):
+ ''' returns a mapping of filters to methods '''
+ return {'node_get_dns_ip': self.node_get_dns_ip}
diff --git a/roles/openshift_node_facts/tasks/main.yml b/roles/openshift_node_facts/tasks/main.yml
index c268c945e..fd4c49504 100644
--- a/roles/openshift_node_facts/tasks/main.yml
+++ b/roles/openshift_node_facts/tasks/main.yml
@@ -30,5 +30,5 @@
ovs_image: "{{ osn_ovs_image | default(None) }}"
proxy_mode: "{{ openshift_node_proxy_mode | default('iptables') }}"
local_quota_per_fsgroup: "{{ openshift_node_local_quota_per_fsgroup | default(None) }}"
- dns_ip: "{{ openshift_dns_ip | default(none) | get_dns_ip(hostvars[inventory_hostname])}}"
+ dns_ip: "{{ openshift_dns_ip | default(none) | node_get_dns_ip(hostvars[inventory_hostname])}}"
env_vars: "{{ openshift_node_env_vars | default(None) }}"