diff options
author | Scott Dodson <sdodson@redhat.com> | 2016-03-07 14:24:57 -0500 |
---|---|---|
committer | Scott Dodson <sdodson@redhat.com> | 2016-04-19 16:44:18 -0400 |
commit | bc11db0c73554be36b4196993d39a35cecbbd25b (patch) | |
tree | 36eaafd964e7a96f7f0d4272d3cc77d29272a52c /filter_plugins | |
parent | 7c11c212a270ea4da9094ed3156db91090b8c851 (diff) | |
download | openshift-bc11db0c73554be36b4196993d39a35cecbbd25b.tar.gz openshift-bc11db0c73554be36b4196993d39a35cecbbd25b.tar.bz2 openshift-bc11db0c73554be36b4196993d39a35cecbbd25b.tar.xz openshift-bc11db0c73554be36b4196993d39a35cecbbd25b.zip |
Add openshift_node_dnsmasq
Diffstat (limited to 'filter_plugins')
-rw-r--r-- | filter_plugins/openshift_node.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/filter_plugins/openshift_node.py b/filter_plugins/openshift_node.py new file mode 100644 index 000000000..4ef92ba03 --- /dev/null +++ b/filter_plugins/openshift_node.py @@ -0,0 +1,43 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# vim: expandtab:tabstop=4:shiftwidth=4 +''' +Custom filters for use in openshift-node +''' +from ansible import errors + +class FilterModule(object): + ''' Custom ansible filters for use by openshift_node role''' + + @staticmethod + def 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 != None: + return openshift_dns_ip + + if bool(hostvars['openshift']['common']['version_gte_3_2_or_1_2']): + return hostvars['ansible_default_ipv4']['address'] + elif bool(hostvars['openshift']['common']['version_gte_3_1_or_1_1']): + if 'openshift_master_cluster_vip' in hostvars: + return hostvars['openshift_master_cluster_vip'] + else: + if 'openshift_master_cluster_vip' in hostvars: + return hostvars['openshift_master_cluster_vip'] + elif 'openshift_node_first_master_ip' in hostvars: + return hostvars['openshift_node_first_master_ip'] + return None + + def filters(self): + ''' returns a mapping of filters to methods ''' + return {'get_dns_ip': self.get_dns_ip} |