diff options
-rw-r--r-- | roles/ansible_service_broker/tasks/install.yml | 121 | ||||
-rw-r--r-- | roles/lib_openshift/library/oc_adm_registry.py | 5 | ||||
-rw-r--r-- | roles/lib_openshift/library/oc_adm_router.py | 5 | ||||
-rw-r--r-- | roles/lib_openshift/library/oc_service.py | 16 | ||||
-rw-r--r-- | roles/lib_openshift/src/ansible/oc_service.py | 1 | ||||
-rw-r--r-- | roles/lib_openshift/src/class/oc_service.py | 4 | ||||
-rw-r--r-- | roles/lib_openshift/src/doc/service | 6 | ||||
-rw-r--r-- | roles/lib_openshift/src/lib/service.py | 5 | ||||
-rwxr-xr-x | roles/lib_openshift/src/test/unit/test_oc_service.py | 4 |
9 files changed, 96 insertions, 71 deletions
diff --git a/roles/ansible_service_broker/tasks/install.yml b/roles/ansible_service_broker/tasks/install.yml index ff90f59a3..26ad7e217 100644 --- a/roles/ansible_service_broker/tasks/install.yml +++ b/roles/ansible_service_broker/tasks/install.yml @@ -147,64 +147,41 @@ - set_fact: service_ca_crt: "{{ asb_client_secret.results.results.0.data['service-ca.crt'] }}" -# Using oc_obj because oc_service doesn't seem to allow annotations -# TODO: Extend oc_service to allow annotations - name: create ansible-service-broker service - oc_obj: + oc_service: name: asb namespace: openshift-ansible-service-broker - state: present - kind: Service - content: - path: /tmp/asbsvcout - data: - apiVersion: v1 - kind: Service - metadata: - name: asb - namespace: openshift-ansible-service-broker - labels: - app: openshift-ansible-service-broker - service: asb - annotations: - service.alpha.openshift.io/serving-cert-secret-name: asb-tls - spec: - ports: - - name: port-1338 - port: 1338 - targetPort: 1338 - protocol: TCP - selector: - app: openshift-ansible-service-broker - service: asb + labels: + app: openshift-ansible-service-broker + service: asb + annotations: + service.alpha.openshift.io/serving-cert-secret-name: asb-tls + ports: + - name: port-1338 + port: 1338 + targetPort: 1338 + protocol: TCP + selector: + app: openshift-ansible-service-broker + service: asb - name: create asb-etcd service - oc_obj: + oc_service: name: asb-etcd namespace: openshift-ansible-service-broker - state: present - kind: Service - content: - path: /tmp/asbetcdsvcout - data: - apiVersion: v1 - kind: Service - metadata: - name: asb-etcd - labels: - app: etcd - service: asb-etcd - annotations: - service.alpha.openshift.io/serving-cert-secret-name: etcd-tls - spec: - ports: - - name: port-2379 - port: 2379 - targetPort: 2379 - protocol: TCP - selector: - app: etcd - service: asb-etcd + labels: + app: etcd + service: asb-etcd + annotations: + service.alpha.openshift.io/serving-cert-secret-name: etcd-tls + ports: + - name: port-2379 + port: 2379 + targetPort: 2379 + protocol: TCP + selector: + app: etcd + service: asb-etcd - name: create route for ansible-service-broker service oc_route: @@ -219,28 +196,25 @@ tls_termination: Reencrypt - name: create persistent volume claim for etcd - oc_obj: + oc_pvc: name: etcd namespace: openshift-ansible-service-broker - state: present - kind: PersistentVolumeClaim - content: - path: /tmp/pvcout - data: - apiVersion: v1 - kind: PersistentVolumeClaim - metadata: - name: etcd - namespace: openshift-ansible-service-broker - spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 1Gi + access_modes: + - ReadWriteOnce + volume_capacity: 1G + +- name: Search for existing Ansible Service Broker deployment config + oc_obj: + name: asb + namespace: openshift-ansible-service-broker + kind: DeploymentConfig + state: list + register: asb_dc - name: Create Ansible Service Broker deployment config + when: asb_dc.results.results.0 | length == 0 oc_obj: + force: yes name: asb namespace: openshift-ansible-service-broker state: present @@ -315,9 +289,18 @@ secret: secretName: broker-etcd-auth-secret +- name: Search for existing Ansible Service Broker etcd deployment config + oc_obj: + name: asb-etcd + namespace: openshift-ansible-service-broker + kind: DeploymentConfig + state: list + register: asb_etcd_dc + - name: Create asb-etcd deployment config + when: asb_etcd_dc.results.results.0 | length == 0 oc_obj: - name: etcd + name: asb-etcd namespace: openshift-ansible-service-broker state: present kind: DeploymentConfig diff --git a/roles/lib_openshift/library/oc_adm_registry.py b/roles/lib_openshift/library/oc_adm_registry.py index 0771aa5a5..fe565987c 100644 --- a/roles/lib_openshift/library/oc_adm_registry.py +++ b/roles/lib_openshift/library/oc_adm_registry.py @@ -1993,6 +1993,7 @@ class ServiceConfig(object): sname, namespace, ports, + annotations=None, selector=None, labels=None, cluster_ip=None, @@ -2004,6 +2005,7 @@ class ServiceConfig(object): self.name = sname self.namespace = namespace self.ports = ports + self.annotations = annotations self.selector = selector self.labels = labels self.cluster_ip = cluster_ip @@ -2026,6 +2028,9 @@ class ServiceConfig(object): self.data['metadata']['labels'] = {} for lab, lab_value in self.labels.items(): self.data['metadata']['labels'][lab] = lab_value + if self.annotations: + self.data['metadata']['annotations'] = self.annotations + self.data['spec'] = {} if self.ports: diff --git a/roles/lib_openshift/library/oc_adm_router.py b/roles/lib_openshift/library/oc_adm_router.py index 146f71f68..5550390e4 100644 --- a/roles/lib_openshift/library/oc_adm_router.py +++ b/roles/lib_openshift/library/oc_adm_router.py @@ -1559,6 +1559,7 @@ class ServiceConfig(object): sname, namespace, ports, + annotations=None, selector=None, labels=None, cluster_ip=None, @@ -1570,6 +1571,7 @@ class ServiceConfig(object): self.name = sname self.namespace = namespace self.ports = ports + self.annotations = annotations self.selector = selector self.labels = labels self.cluster_ip = cluster_ip @@ -1592,6 +1594,9 @@ class ServiceConfig(object): self.data['metadata']['labels'] = {} for lab, lab_value in self.labels.items(): self.data['metadata']['labels'][lab] = lab_value + if self.annotations: + self.data['metadata']['annotations'] = self.annotations + self.data['spec'] = {} if self.ports: diff --git a/roles/lib_openshift/library/oc_service.py b/roles/lib_openshift/library/oc_service.py index 3e8aea4f1..c541e1bbd 100644 --- a/roles/lib_openshift/library/oc_service.py +++ b/roles/lib_openshift/library/oc_service.py @@ -90,6 +90,12 @@ options: required: false default: default aliases: [] + annotations: + description: + - Annotations to apply to the object + required: false + default: None + aliases: [] selector: description: - The selector to apply when filtering for services. @@ -1471,6 +1477,7 @@ class ServiceConfig(object): sname, namespace, ports, + annotations=None, selector=None, labels=None, cluster_ip=None, @@ -1482,6 +1489,7 @@ class ServiceConfig(object): self.name = sname self.namespace = namespace self.ports = ports + self.annotations = annotations self.selector = selector self.labels = labels self.cluster_ip = cluster_ip @@ -1504,6 +1512,9 @@ class ServiceConfig(object): self.data['metadata']['labels'] = {} for lab, lab_value in self.labels.items(): self.data['metadata']['labels'][lab] = lab_value + if self.annotations: + self.data['metadata']['annotations'] = self.annotations + self.data['spec'] = {} if self.ports: @@ -1662,6 +1673,7 @@ class OCService(OpenShiftCLI): sname, namespace, labels, + annotations, selector, cluster_ip, portal_ip, @@ -1674,7 +1686,7 @@ class OCService(OpenShiftCLI): ''' Constructor for OCVolume ''' super(OCService, self).__init__(namespace, kubeconfig, verbose) self.namespace = namespace - self.config = ServiceConfig(sname, namespace, ports, selector, labels, + self.config = ServiceConfig(sname, namespace, ports, annotations, selector, labels, cluster_ip, portal_ip, session_affinity, service_type, external_ips) self.user_svc = Service(content=self.config.data) @@ -1739,6 +1751,7 @@ class OCService(OpenShiftCLI): oc_svc = OCService(params['name'], params['namespace'], params['labels'], + params['annotations'], params['selector'], params['clusterip'], params['portalip'], @@ -1840,6 +1853,7 @@ def main(): debug=dict(default=False, type='bool'), namespace=dict(default='default', type='str'), name=dict(default=None, type='str'), + annotations=dict(default=None, type='dict'), labels=dict(default=None, type='dict'), selector=dict(default=None, type='dict'), clusterip=dict(default=None, type='str'), diff --git a/roles/lib_openshift/src/ansible/oc_service.py b/roles/lib_openshift/src/ansible/oc_service.py index b90c08255..0c55391e3 100644 --- a/roles/lib_openshift/src/ansible/oc_service.py +++ b/roles/lib_openshift/src/ansible/oc_service.py @@ -14,6 +14,7 @@ def main(): debug=dict(default=False, type='bool'), namespace=dict(default='default', type='str'), name=dict(default=None, type='str'), + annotations=dict(default=None, type='dict'), labels=dict(default=None, type='dict'), selector=dict(default=None, type='dict'), clusterip=dict(default=None, type='str'), diff --git a/roles/lib_openshift/src/class/oc_service.py b/roles/lib_openshift/src/class/oc_service.py index 7268a0c88..e41237b7e 100644 --- a/roles/lib_openshift/src/class/oc_service.py +++ b/roles/lib_openshift/src/class/oc_service.py @@ -13,6 +13,7 @@ class OCService(OpenShiftCLI): sname, namespace, labels, + annotations, selector, cluster_ip, portal_ip, @@ -25,7 +26,7 @@ class OCService(OpenShiftCLI): ''' Constructor for OCVolume ''' super(OCService, self).__init__(namespace, kubeconfig, verbose) self.namespace = namespace - self.config = ServiceConfig(sname, namespace, ports, selector, labels, + self.config = ServiceConfig(sname, namespace, ports, annotations, selector, labels, cluster_ip, portal_ip, session_affinity, service_type, external_ips) self.user_svc = Service(content=self.config.data) @@ -90,6 +91,7 @@ class OCService(OpenShiftCLI): oc_svc = OCService(params['name'], params['namespace'], params['labels'], + params['annotations'], params['selector'], params['clusterip'], params['portalip'], diff --git a/roles/lib_openshift/src/doc/service b/roles/lib_openshift/src/doc/service index ba9aa0b38..b596dff85 100644 --- a/roles/lib_openshift/src/doc/service +++ b/roles/lib_openshift/src/doc/service @@ -39,6 +39,12 @@ options: required: false default: default aliases: [] + annotations: + description: + - Annotations to apply to the object + required: false + default: None + aliases: [] selector: description: - The selector to apply when filtering for services. diff --git a/roles/lib_openshift/src/lib/service.py b/roles/lib_openshift/src/lib/service.py index 0e8cc3aa5..84620c518 100644 --- a/roles/lib_openshift/src/lib/service.py +++ b/roles/lib_openshift/src/lib/service.py @@ -10,6 +10,7 @@ class ServiceConfig(object): sname, namespace, ports, + annotations=None, selector=None, labels=None, cluster_ip=None, @@ -21,6 +22,7 @@ class ServiceConfig(object): self.name = sname self.namespace = namespace self.ports = ports + self.annotations = annotations self.selector = selector self.labels = labels self.cluster_ip = cluster_ip @@ -43,6 +45,9 @@ class ServiceConfig(object): self.data['metadata']['labels'] = {} for lab, lab_value in self.labels.items(): self.data['metadata']['labels'][lab] = lab_value + if self.annotations: + self.data['metadata']['annotations'] = self.annotations + self.data['spec'] = {} if self.ports: diff --git a/roles/lib_openshift/src/test/unit/test_oc_service.py b/roles/lib_openshift/src/test/unit/test_oc_service.py index 9c21a262f..2a7b3c7dc 100755 --- a/roles/lib_openshift/src/test/unit/test_oc_service.py +++ b/roles/lib_openshift/src/test/unit/test_oc_service.py @@ -34,6 +34,7 @@ class OCServiceTest(unittest.TestCase): 'ports': None, 'state': 'list', 'labels': None, + 'annotations': None, 'clusterip': None, 'portalip': None, 'selector': None, @@ -120,6 +121,7 @@ class OCServiceTest(unittest.TestCase): 'targetPOrt': 9000}, 'state': 'present', 'labels': None, + 'annotations': None, 'clusterip': None, 'portalip': None, 'selector': {'router': 'router'}, @@ -318,6 +320,7 @@ class OCServiceTest(unittest.TestCase): 'targetPOrt': 9000}, 'state': 'present', 'labels': {'component': 'some_component', 'infra': 'true'}, + 'annotations': None, 'clusterip': None, 'portalip': None, 'selector': {'router': 'router'}, @@ -407,6 +410,7 @@ class OCServiceTest(unittest.TestCase): 'targetPOrt': 9000}, 'state': 'present', 'labels': {'component': 'some_component', 'infra': 'true'}, + 'annotations': None, 'clusterip': None, 'portalip': None, 'selector': {'router': 'router'}, |