summaryrefslogtreecommitdiffstats
path: root/roles
diff options
context:
space:
mode:
Diffstat (limited to 'roles')
-rwxr-xr-xroles/lib_openshift/src/generate.py30
-rw-r--r--roles/lib_utils/library/yedit.py6
-rwxr-xr-xroles/lib_utils/src/generate.py32
-rw-r--r--roles/openshift_logging/library/openshift_logging_facts.py4
-rw-r--r--roles/openshift_logging/tasks/generate_configmaps.yaml2
5 files changed, 48 insertions, 26 deletions
diff --git a/roles/lib_openshift/src/generate.py b/roles/lib_openshift/src/generate.py
index 8451d99ab..6daade108 100755
--- a/roles/lib_openshift/src/generate.py
+++ b/roles/lib_openshift/src/generate.py
@@ -10,6 +10,7 @@ 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/')
class GenerateAnsibleException(Exception):
@@ -42,22 +43,29 @@ def generate(parts):
return data
-def main():
- ''' combine the necessary files to create the ansible module '''
- args = parse_args()
+def get_sources():
+ '''return the path to the generate sources'''
+ return yaml.load(open(OPENSHIFT_ANSIBLE_SOURCES_PATH).read())
- library = os.path.join(OPENSHIFT_ANSIBLE_PATH, '..', 'library/')
- sources = yaml.load(open(OPENSHIFT_ANSIBLE_SOURCES_PATH).read())
- for fname, parts in sources.items():
+def verify():
+ '''verify if the generated code matches the library code'''
+ for fname, parts in get_sources().items():
data = generate(parts)
- fname = os.path.join(library, fname)
- if args.verify:
- if not open(fname).read() == data.getvalue():
- raise GenerateAnsibleException('Generated content does not match for %s' % fname)
+ fname = os.path.join(LIBRARY, fname)
+ if not open(fname).read() == data.getvalue():
+ raise GenerateAnsibleException('Generated content does not match for %s' % fname)
+
- continue
+def main():
+ ''' combine the necessary files to create the ansible module '''
+ args = parse_args()
+ if args.verify:
+ verify()
+ for fname, parts in get_sources().items():
+ data = generate(parts)
+ fname = os.path.join(LIBRARY, fname)
with open(fname, 'w') as afd:
afd.seek(0)
afd.write(data.getvalue())
diff --git a/roles/lib_utils/library/yedit.py b/roles/lib_utils/library/yedit.py
index d882c983e..6a5b40dcc 100644
--- a/roles/lib_utils/library/yedit.py
+++ b/roles/lib_utils/library/yedit.py
@@ -134,6 +134,12 @@ options:
required: false
default: true
aliases: []
+ separator:
+ description:
+ - The separator being used when parsing strings.
+ required: false
+ default: '.'
+ aliases: []
author:
- "Kenny Woodson <kwoodson@redhat.com>"
extends_documentation_fragment: []
diff --git a/roles/lib_utils/src/generate.py b/roles/lib_utils/src/generate.py
index cece68fb4..6daade108 100755
--- a/roles/lib_utils/src/generate.py
+++ b/roles/lib_utils/src/generate.py
@@ -5,11 +5,12 @@
import argparse
import os
-import six
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/')
class GenerateAnsibleException(Exception):
@@ -42,22 +43,29 @@ def generate(parts):
return data
-def main():
- ''' combine the necessary files to create the ansible module '''
- args = parse_args()
+def get_sources():
+ '''return the path to the generate sources'''
+ return yaml.load(open(OPENSHIFT_ANSIBLE_SOURCES_PATH).read())
- library = os.path.join(OPENSHIFT_ANSIBLE_PATH, '..', 'library/')
- sources = yaml.load(open(OPENSHIFT_ANSIBLE_SOURCES_PATH).read())
- for fname, parts in sources.items():
+def verify():
+ '''verify if the generated code matches the library code'''
+ for fname, parts in get_sources().items():
data = generate(parts)
- fname = os.path.join(library, fname)
- if args.verify:
- if not open(fname).read() == data.getvalue():
- raise GenerateAnsibleException('Generated content does not match for %s' % fname)
+ fname = os.path.join(LIBRARY, fname)
+ if not open(fname).read() == data.getvalue():
+ raise GenerateAnsibleException('Generated content does not match for %s' % fname)
- continue
+def main():
+ ''' combine the necessary files to create the ansible module '''
+ args = parse_args()
+ if args.verify:
+ verify()
+
+ for fname, parts in get_sources().items():
+ data = generate(parts)
+ fname = os.path.join(LIBRARY, fname)
with open(fname, 'w') as afd:
afd.seek(0)
afd.write(data.getvalue())
diff --git a/roles/openshift_logging/library/openshift_logging_facts.py b/roles/openshift_logging/library/openshift_logging_facts.py
index 8bbfdf7bf..64bc33435 100644
--- a/roles/openshift_logging/library/openshift_logging_facts.py
+++ b/roles/openshift_logging/library/openshift_logging_facts.py
@@ -105,9 +105,9 @@ class OpenshiftLoggingFacts(OCBaseCommand):
def add_facts_for(self, comp, kind, name=None, facts=None):
''' Add facts for the provided kind '''
- if comp in self.facts is False:
+ if comp not in self.facts:
self.facts[comp] = dict()
- if kind in self.facts[comp] is False:
+ if kind not in self.facts[comp]:
self.facts[comp][kind] = dict()
if name:
self.facts[comp][kind][name] = facts
diff --git a/roles/openshift_logging/tasks/generate_configmaps.yaml b/roles/openshift_logging/tasks/generate_configmaps.yaml
index b24a7c342..8fcf517ad 100644
--- a/roles/openshift_logging/tasks/generate_configmaps.yaml
+++ b/roles/openshift_logging/tasks/generate_configmaps.yaml
@@ -49,7 +49,7 @@
- copy:
content: "{{curator_config_contents}}"
dest: "{{mktemp.stdout}}/curator.yml"
- when: curator_config_contenets is defined
+ when: curator_config_contents is defined
changed_when: no
- command: >