summaryrefslogtreecommitdiffstats
path: root/roles/lib_openshift/src/ansible
diff options
context:
space:
mode:
authorScott Dodson <sdodson@redhat.com>2017-01-18 13:39:43 -0500
committerGitHub <noreply@github.com>2017-01-18 13:39:43 -0500
commit7a0228f432a0d68bd63a68b940a7913d4a6a7e7c (patch)
tree351507d1744326f27bcf23e523e0bacc6de2a7fe /roles/lib_openshift/src/ansible
parentb4d76724b764d0f18ace622bafb9ce390fdd9f19 (diff)
parent3fd3cd3a07d9f000c8cb8bd1b7a49ac2af675696 (diff)
downloadopenshift-7a0228f432a0d68bd63a68b940a7913d4a6a7e7c.tar.gz
openshift-7a0228f432a0d68bd63a68b940a7913d4a6a7e7c.tar.bz2
openshift-7a0228f432a0d68bd63a68b940a7913d4a6a7e7c.tar.xz
openshift-7a0228f432a0d68bd63a68b940a7913d4a6a7e7c.zip
Merge pull request #3092 from kwoodson/lib_openshift_3.3
lib_openshift. This is the initial commit that has oc_route.
Diffstat (limited to 'roles/lib_openshift/src/ansible')
-rw-r--r--roles/lib_openshift/src/ansible/oc_edit.py48
-rw-r--r--roles/lib_openshift/src/ansible/oc_route.py82
2 files changed, 130 insertions, 0 deletions
diff --git a/roles/lib_openshift/src/ansible/oc_edit.py b/roles/lib_openshift/src/ansible/oc_edit.py
new file mode 100644
index 000000000..5c5954747
--- /dev/null
+++ b/roles/lib_openshift/src/ansible/oc_edit.py
@@ -0,0 +1,48 @@
+# pylint: skip-file
+# flake8: noqa
+
+
+def main():
+ '''
+ ansible oc module for editing objects
+ '''
+
+ module = AnsibleModule(
+ argument_spec=dict(
+ kubeconfig=dict(default='/etc/origin/master/admin.kubeconfig', type='str'),
+ state=dict(default='present', type='str',
+ choices=['present']),
+ debug=dict(default=False, type='bool'),
+ namespace=dict(default='default', type='str'),
+ name=dict(default=None, required=True, type='str'),
+ kind=dict(required=True,
+ type='str',
+ choices=['dc', 'deploymentconfig',
+ 'rc', 'replicationcontroller',
+ 'svc', 'service',
+ 'scc', 'securitycontextconstraints',
+ 'ns', 'namespace', 'project', 'projects',
+ 'is', 'imagestream',
+ 'istag', 'imagestreamtag',
+ 'bc', 'buildconfig',
+ 'routes',
+ 'node',
+ 'secret',
+ 'pv', 'persistentvolume']),
+ file_name=dict(default=None, type='str'),
+ file_format=dict(default='yaml', type='str'),
+ content=dict(default=None, required=True, type='dict'),
+ force=dict(default=False, type='bool'),
+ separator=dict(default='.', type='str'),
+ ),
+ supports_check_mode=True,
+ )
+
+ rval = Edit.run_ansible(module.params, module.check_mode)
+ if 'failed' in rval:
+ module.fail_json(**rval)
+
+ module.exit_json(**rval)
+
+if __name__ == '__main__':
+ main()
diff --git a/roles/lib_openshift/src/ansible/oc_route.py b/roles/lib_openshift/src/ansible/oc_route.py
new file mode 100644
index 000000000..3dcae052c
--- /dev/null
+++ b/roles/lib_openshift/src/ansible/oc_route.py
@@ -0,0 +1,82 @@
+# pylint: skip-file
+# flake8: noqa
+
+
+def get_cert_data(path, content):
+ '''get the data for a particular value'''
+ if not path and not content:
+ return None
+
+ rval = None
+ if path and os.path.exists(path) and os.access(path, os.R_OK):
+ rval = open(path).read()
+ elif content:
+ rval = content
+
+ return rval
+
+
+# pylint: disable=too-many-branches
+def main():
+ '''
+ ansible oc module for route
+ '''
+ module = AnsibleModule(
+ argument_spec=dict(
+ kubeconfig=dict(default='/etc/origin/master/admin.kubeconfig', type='str'),
+ state=dict(default='present', type='str',
+ choices=['present', 'absent', 'list']),
+ debug=dict(default=False, type='bool'),
+ name=dict(default=None, required=True, type='str'),
+ namespace=dict(default=None, required=True, type='str'),
+ tls_termination=dict(default=None, type='str'),
+ dest_cacert_path=dict(default=None, type='str'),
+ cacert_path=dict(default=None, type='str'),
+ cert_path=dict(default=None, type='str'),
+ key_path=dict(default=None, type='str'),
+ dest_cacert_content=dict(default=None, type='str'),
+ cacert_content=dict(default=None, type='str'),
+ cert_content=dict(default=None, type='str'),
+ key_content=dict(default=None, type='str'),
+ service_name=dict(default=None, type='str'),
+ host=dict(default=None, type='str'),
+ ),
+ mutually_exclusive=[('dest_cacert_path', 'dest_cacert_content'),
+ ('cacert_path', 'cacert_content'),
+ ('cert_path', 'cert_content'),
+ ('key_path', 'key_content'), ],
+ supports_check_mode=True,
+ )
+ files = {'destcacert': {'path': module.params['dest_cacert_path'],
+ 'content': module.params['dest_cacert_content'],
+ 'value': None, },
+ 'cacert': {'path': module.params['cacert_path'],
+ 'content': module.params['cacert_content'],
+ 'value': None, },
+ 'cert': {'path': module.params['cert_path'],
+ 'content': module.params['cert_content'],
+ 'value': None, },
+ 'key': {'path': module.params['key_path'],
+ 'content': module.params['key_content'],
+ 'value': None, }, }
+
+ if module.params['tls_termination']:
+ for key, option in files.items():
+ if key == 'destcacert' and module.params['tls_termination'] != 'reencrypt':
+ continue
+
+ option['value'] = get_cert_data(option['path'], option['content'])
+
+ if not option['value']:
+ module.fail_json(msg='Verify that you pass a value for %s' % key)
+
+ results = OCRoute.run_ansible(module.params, files, module.check_mode)
+
+ if 'failed' in results:
+ module.fail_json(**results)
+
+ module.exit_json(**results)
+
+
+if __name__ == '__main__':
+ main()