Wolfgang Kulhanek
2019-03-13 2ca1dc095406e66976c86108e69b54f329fba35c
Getting closer on Automation Broker. Still not there.
2 files added
7 files modified
123 ■■■■ changed files
ansible/roles/ocp-workload-automation-broker/defaults/main.yml 5 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-automation-broker/tasks/pre_workload.yml 1 ●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-automation-broker/tasks/remove_workload.yml 10 ●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-automation-broker/tasks/workload.yml 69 ●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-automation-broker/templates/automation_broker.j2 2 ●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-automation-broker/templates/broker_project.j2 11 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-automation-broker/templates/catalog_source.j2 13 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-automation-broker/templates/operator_group.j2 6 ●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-automation-broker/templates/subscription.j2 6 ●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-automation-broker/defaults/main.yml
@@ -3,5 +3,6 @@
ocp_username: opentlc-mgr
silent: False
broker_project: openshift-automation-broker
broker_project_display: "OpenShift Automation Broker"
_broker_project: openshift-automation-broker
_broker_project_display: "OpenShift Automation Broker"
_broker_subscription_csv: "automationbrokeroperator.v0.2.0"
ansible/roles/ocp-workload-automation-broker/tasks/pre_workload.yml
@@ -1,7 +1,6 @@
---
# Implement your Pre Workload deployment tasks here
# Leave this as the last task in the playbook.
- name: pre_workload tasks complete
  debug:
ansible/roles/ocp-workload-automation-broker/tasks/remove_workload.yml
@@ -1,8 +1,14 @@
---
# Implement your Workload removal tasks here
- name: remove Workshop terminal project
  command: "oc delete project {{ terminal_project }}"
- name: Remove Automation Broker Project
  k8s:
    name: "{{ _broker_project }}"
    api_version: v1
    kind: Namespace
    state: absent
# Not removing the Service Broker objects because they may be used elsewhere.
# Leave this as the last task in the playbook.
- name: remove_workload tasks complete
ansible/roles/ocp-workload-automation-broker/tasks/workload.yml
@@ -5,69 +5,40 @@
  debug:
    msg: "Setting up workload for user ocp_username = {{ ocp_username }}"
- name: Create openshift-automation-broker project
  command: "oc create namespace {{ broker_project }}"
  ignore_errors: true
# - name: Annotate openshift-automation-broker project with Project Name
#   command: "oc annotate namespace {{ broker_project }} openshift.io/display-name='{{ broker_project_display }}'"
#   ignore_errors: true
- name: Upload YAML files
  copy:
    src: "{{ item.src }}"
    dest: "{{ item.dest }}"
    owner: root
    group: root
    mode: 0664
- name: Create OpenShift Objects for Service Broker
  k8s:
    state: present
    definition: "{{ lookup('file', item ) | from_yaml }}"
  loop:
  - { src: './files/service_catalog_api_server.yaml',         dest: '/tmp/service_catalog_api_server.yaml' }
  - { src: './files/service_catalog_controller_manager.yaml', dest: '/tmp/service_catalog_controller_manager.yaml' }
  - ./files/service_catalog_api_server.yaml
  - ./files/service_catalog_controller_manager.yaml
- name: Upload YAML Templates
  template:
    src: "{{ item.src }}"
    dest: "{{ item.dest }}"
    owner: root
    group: root
    mode: 0664
- name: Create OpenShift Objects for Automation Broker
  k8s:
    state: present
    definition: "{{ lookup('template', item ) | from_yaml }}"
  loop:
  - { src: './templates/operator_group.j2',    dest: '/tmp/operator_group.yaml' }
  - { src: './templates/subscription.j2',      dest: '/tmp/subscription.yaml' }
  - { src: './templates/automation_broker.j2', dest: '/tmp/automation_broker.yaml' }
- name: Create OpenShift objects
  command: "oc create -f {{ item }} -n {{ broker_project }}"
  ignore_errors: true
  loop:
  - /tmp/service_catalog_api_server.yaml
  - /tmp/service_catalog_controller_manager.yaml
  - /tmp/operator_group.yaml
  - /tmp/subscription.yaml
  - ./templates/broker_project.j2
  - ./templates/operator_group.j2
  - ./templates/catalog_source.j2
  - ./templates/subscription.j2
- name: Wait until CSV is Installed
  command: oc get csv automationbrokeroperator.v0.2.0 -o jsonpath --template='{.status.phase}'
  command: oc get csv "{{ _broker_subscription_csv }}" -o jsonpath --template='{.status.phase}'
  register: csv
  retries: 30
  delay: 10
  until: csv.stdout == "Succeeded"
- name: Create Automation Broker
  command: "oc apply -f /tmp/automation_broker.yaml"
  ignore_errors: true
  k8s:
    state: present
    definition: "{{ lookup('template', item ) | from_yaml }}"
  loop:
  - ./templates/automation_broker.j2
- name: Grant Automation Broker Service Account cluster-admin
  command: "oc adm policy add-cluster-role-to-user cluster-admin system:serviceaccount:{{ broker_project }}:ansible-service-broker"
- name: Cleanup files
  file:
    path: "{{ item }}"
    state: absent
  loop:
  - /tmp/service_catalog_api_server.yaml
  - /tmp/service_catalog_controller_manager.yaml
  - /tmp/operator_group.yaml
  - /tmp/automation-broker-subscription.yaml
  - /tmp/automation-broker.yaml
# Leave this as the last task in the playbook.
- name: workload tasks complete
ansible/roles/ocp-workload-automation-broker/templates/automation_broker.j2
@@ -2,7 +2,7 @@
kind: AutomationBroker
metadata:
  name: ansible-service-broker
  namespace: "{{ broker_project }}"
  namespace: "{{ _broker_project }}"
spec:
  createBrokerNamespace: 'false'
  waitForBroker: 'false'
ansible/roles/ocp-workload-automation-broker/templates/broker_project.j2
New file
@@ -0,0 +1,11 @@
apiVersion: project.openshift.io/v1
kind: Project
metadata:
  annotations:
    openshift.io/description: ""
    openshift.io/display-name: "{{ _broker_project_display }}"
    openshift.io/requester: "{{ ocp_username }}"
  name: "{{ _broker_project }}"
spec:
  finalizers:
  - kubernetes
ansible/roles/ocp-workload-automation-broker/templates/catalog_source.j2
New file
@@ -0,0 +1,13 @@
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
  name: installed-community-openshift-automation-broker
  namespace: "{{ _broker_project }}"
spec:
  address: community-operators.openshift-marketplace.svc.cluster.local:50051
  displayName: Community Operators
  icon:
    base64data: ""
    mediatype: ""
  publisher: Community
  sourceType: grpc
ansible/roles/ocp-workload-automation-broker/templates/operator_group.j2
@@ -1,8 +1,8 @@
apiVersion: operators.coreos.com/v1alpha2
kind: OperatorGroup
metadata:
  generateName: automation-broker-
  namespace: "{{ broker_project }}"
  name: automation-broker-group
  namespace: "{{ _broker_project }}"
spec:
  targetNamespaces:
  - "{{ broker_project }}"
  - "{{ _broker_project }}"
ansible/roles/ocp-workload-automation-broker/templates/subscription.j2
@@ -2,11 +2,11 @@
kind: Subscription
metadata:
  name: automationbroker
  namespace: "{{ broker_project }}"
  namespace: "{{ _broker_project }}"
spec:
  channel: alpha
  installPlanApproval: Automatic
  name: automationbroker
  source: installed-community-automation-broker
  sourceNamespace: "{{ broker_project }}"
  startingCSV: automationbrokeroperator.v0.2.0
  sourceNamespace: "{{ _broker_project }}"
  startingCSV: "{{ _broker_subscription_csv }}"