Bladeren bron

Translate legacy facts within the oo_openshift_env filter.

Andrew Butcher 9 jaren geleden
bovenliggende
commit
bfa45e45ed
2 gewijzigde bestanden met toevoegingen van 8 en 7 verwijderingen
  1. 8 1
      filter_plugins/oo_filters.py
  2. 0 6
      roles/openshift_hosted_facts/tasks/main.yml

+ 8 - 1
filter_plugins/oo_filters.py

@@ -650,7 +650,9 @@ class FilterModule(object):
 
     @staticmethod
     def oo_openshift_env(hostvars):
-        ''' Return facts which begin with "openshift_"
+        ''' Return facts which begin with "openshift_" and translate
+            legacy facts to their openshift_env counterparts.
+
             Ex: hostvars = {'openshift_fact': 42,
                             'theyre_taking_the_hobbits_to': 'isengard'}
                 returns  = {'openshift_fact': 42}
@@ -663,6 +665,11 @@ class FilterModule(object):
         for key in hostvars:
             if regex.match(key):
                 facts[key] = hostvars[key]
+
+        migrations = {'openshift_router_selector': 'openshift_hosted_router_selector'}
+        for old_fact, new_fact in migrations.iteritems():
+            if old_fact in facts and new_fact not in facts:
+                facts[new_fact] = facts[old_fact]
         return facts
 
     @staticmethod

+ 0 - 6
roles/openshift_hosted_facts/tasks/main.yml

@@ -1,10 +1,4 @@
 ---
-- name: Set legacy hosted facts
-  openshift_facts:
-    role: hosted
-    openshift_env:
-      openshift_hosted_router_selector: "{{ openshift_router_selector | default(None) }}"
-
 - name: Set hosted facts
   openshift_facts:
     role: hosted