Ver código fonte

Add openshift_metering role and playbook

This role installs and configures operator-framework/operator-metering
for Openshift with a playbook that installs it with defaults for
Openshift origin 3.10+.
Chance Zibolski 6 anos atrás
pai
commit
c9d2f8ee36
26 arquivos alterados com 697 adições e 0 exclusões
  1. 3 0
      playbooks/common/private/components.yml
  2. 40 0
      playbooks/openshift-metering/README.md
  3. 8 0
      playbooks/openshift-metering/config.yml
  4. 16 0
      playbooks/openshift-metering/gcp-config.yml
  5. 32 0
      playbooks/openshift-metering/private/config.yml
  6. 1 0
      playbooks/openshift-metering/private/roles
  7. 49 0
      roles/openshift_metering/README.md
  8. 4 0
      roles/openshift_metering/defaults/main.yml
  9. 16 0
      roles/openshift_metering/files/crds/metering.crd.yaml
  10. 15 0
      roles/openshift_metering/files/crds/prestotable.crd.yaml
  11. 14 0
      roles/openshift_metering/files/crds/report.crd.yaml
  12. 15 0
      roles/openshift_metering/files/crds/reportdatasource.crd.yaml
  13. 15 0
      roles/openshift_metering/files/crds/reportgenerationquery.crd.yaml
  14. 15 0
      roles/openshift_metering/files/crds/reportprometheusquery.crd.yaml
  15. 14 0
      roles/openshift_metering/files/crds/scheduledreport.crd.yaml
  16. 14 0
      roles/openshift_metering/files/crds/storagelocation.crd.yaml
  17. 96 0
      roles/openshift_metering/files/operator/metering-helm-operator-deployment.yaml
  18. 144 0
      roles/openshift_metering/files/operator/metering-helm-operator-role.yaml
  19. 11 0
      roles/openshift_metering/files/operator/metering-helm-operator-rolebinding.yaml
  20. 4 0
      roles/openshift_metering/files/operator/metering-helm-operator-service-account.yaml
  21. 5 0
      roles/openshift_metering/files/operator/metering.yaml
  22. 22 0
      roles/openshift_metering/meta/main.yaml
  23. 120 0
      roles/openshift_metering/tasks/install.yaml
  24. 6 0
      roles/openshift_metering/tasks/main.yaml
  25. 16 0
      roles/openshift_metering/tasks/uninstall.yaml
  26. 2 0
      roles/openshift_metering/vars/main.yml

+ 3 - 0
playbooks/common/private/components.yml

@@ -22,6 +22,9 @@
 - import_playbook: ../../openshift-monitoring/private/config.yml
   when: openshift_monitoring_deploy | default(false) | bool
 
+- import_playbook: ../../openshift-metering/private/config.yml
+  when: openshift_metering_install | default(false) | bool
+
 - import_playbook: ../../openshift-web-console/private/config.yml
   when: openshift_web_console_install | default(true) | bool
 

+ 40 - 0
playbooks/openshift-metering/README.md

@@ -0,0 +1,40 @@
+# OpenShift Metering
+
+This playbook runs the [Openshift Metering role](../../roles/openshift_metering).
+See the role for more information.
+
+## Prequisites:
+
+This playbook requires Openshift Monitoring to be installed, to install it set this variable:
+
+```yaml
+openshift_monitoring_deploy: true
+```
+
+## Installation
+
+To install Openshift Metering, set this variable:
+
+```yaml
+openshift_metering_install: true
+```
+
+To uninstall, set:
+
+```yaml
+openshift_metering_install: false
+```
+
+Then run:
+
+```bash
+ansible-playbook playbooks/openshift-metering/config.yml
+```
+
+## GCP Development
+
+The `gcp-config.yml` playbook is useful for ad-hoc installation in an existing GCE cluster:
+
+```bash
+ansible-playbook playbooks/openshift-metering/gcp-config.yml
+```

+ 8 - 0
playbooks/openshift-metering/config.yml

@@ -0,0 +1,8 @@
+---
+- import_playbook: ../init/main.yml
+  vars:
+    l_init_fact_hosts: "oo_masters_to_config"
+    l_openshift_version_set_hosts: "oo_masters_to_config:!oo_first_master"
+    l_sanity_check_hosts: "{{ groups['oo_masters_to_config'] }}"
+
+- import_playbook: private/config.yml

+ 16 - 0
playbooks/openshift-metering/gcp-config.yml

@@ -0,0 +1,16 @@
+---
+- hosts: localhost
+  connection: local
+  tasks:
+  - name: place all scale groups into Ansible groups
+    include_role:
+      name: openshift_gcp
+      tasks_from: setup_scale_group_facts.yml
+
+- import_playbook: ../init/main.yml
+  vars:
+    l_init_fact_hosts: "oo_masters_to_config"
+    l_openshift_version_set_hosts: "oo_masters_to_config:!oo_first_master"
+    l_sanity_check_hosts: "{{ groups['oo_masters_to_config'] }}"
+
+- import_playbook: private/config.yml

+ 32 - 0
playbooks/openshift-metering/private/config.yml

@@ -0,0 +1,32 @@
+---
+- name: Openshift Metering Checkpoint Start
+  hosts: all
+  gather_facts: false
+  tasks:
+  - name: Set Openshift Metering 'In Progress'
+    run_once: true
+    set_stats:
+      data:
+        installer_phase_openshift_metering:
+          title: "Openshift Metering"
+          playbook: "playbooks/openshift-metering/config.yml"
+          status: "In Progress"
+          start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
+
+
+- name: Configure Openshift Metering
+  hosts: oo_first_master
+  roles:
+  - role: openshift_metering
+
+- name: Openshift Metering Checkpoint End
+  hosts: all
+  gather_facts: false
+  tasks:
+  - name: Set Openshift Metering 'Complete'
+    run_once: true
+    set_stats:
+      data:
+        installer_phase_openshift_metering:
+          status: "Complete"
+          end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"

+ 1 - 0
playbooks/openshift-metering/private/roles

@@ -0,0 +1 @@
+../../../roles/

+ 49 - 0
roles/openshift_metering/README.md

@@ -0,0 +1,49 @@
+# OpenShift Metering
+
+This role installs the OpenShift [Metering](https://github.com/operator-framework/operator-metering), which supports metering operators and applications in Kubernetes and producing reports on this metered information.
+
+### **NOTE: This component is unsupported in OCP at this time.**
+
+## Installation
+
+To install Openshift Metering, set this variable:
+
+```yaml
+openshift_metering_install: true
+```
+
+To uninstall, set:
+
+```yaml
+openshift_metering_install: false
+```
+
+## Configuration
+
+The metering operator comes with a default no-op [Metering configuration][metering-config].
+To supply additional configuration options set the `openshift_metering_config` variable to a dictionary containing the contents of the `Metering` `spec` field you wish to set.
+
+For example:
+
+```
+openshift_metering_config:
+  metering-operator:
+    config:
+      awsAccessKeyID: "REPLACEME"
+```
+
+Updating the operator itself to a custom image can be done by setting `openshift_metering_operator_image` to a docker image and tag that should be used.
+
+For example:
+
+```
+openshift_metering_config: quay.io/coreos/chargeback-helm-operator:latest
+```
+
+Using a custom project/namespace can be done by specifying `__openshift_metering_namespace`.
+
+## License
+
+Apache License, Version 2.0
+
+[metering-config]: https://github.com/operator-framework/operator-metering/blob/master/Documentation/metering-config.md

+ 4 - 0
roles/openshift_metering/defaults/main.yml

@@ -0,0 +1,4 @@
+---
+openshift_metering_operator_image: ''
+
+openshift_metering_config: null

+ 16 - 0
roles/openshift_metering/files/crds/metering.crd.yaml

@@ -0,0 +1,16 @@
+apiVersion: apiextensions.k8s.io/v1beta1
+kind: CustomResourceDefinition
+metadata:
+  name: meterings.chargeback.coreos.com
+  annotations:
+    catalog.app.coreos.com/description: An instance of Metering
+    catalog.app.coreos.com/displayName: Metering
+spec:
+  group: chargeback.coreos.com
+  version: v1alpha1
+  scope: Namespaced
+  names:
+    plural: meterings
+    singular: metering
+    kind: Metering
+    listKind: MeteringList

+ 15 - 0
roles/openshift_metering/files/crds/prestotable.crd.yaml

@@ -0,0 +1,15 @@
+apiVersion: apiextensions.k8s.io/v1beta1
+kind: CustomResourceDefinition
+metadata:
+  name: prestotables.chargeback.coreos.com
+  annotations:
+    catalog.app.coreos.com/displayName: "Chargeback Presto Table"
+    catalog.app.coreos.com/description: "A table within PrestoDB"
+spec:
+  group: chargeback.coreos.com
+  version: v1alpha1
+  scope: Namespaced
+  names:
+    plural: prestotables
+    singular: prestotable
+    kind: PrestoTable

+ 14 - 0
roles/openshift_metering/files/crds/report.crd.yaml

@@ -0,0 +1,14 @@
+apiVersion: apiextensions.k8s.io/v1beta1
+kind: CustomResourceDefinition
+metadata:
+  name: reports.chargeback.coreos.com
+  annotations:
+    catalog.app.coreos.com/displayName: "Chargeback Report"
+    catalog.app.coreos.com/description: "A chargeback report for a specific time interval"
+spec:
+  group: chargeback.coreos.com
+  version: v1alpha1
+  scope: Namespaced
+  names:
+    plural: reports
+    kind: Report

+ 15 - 0
roles/openshift_metering/files/crds/reportdatasource.crd.yaml

@@ -0,0 +1,15 @@
+apiVersion: apiextensions.k8s.io/v1beta1
+kind: CustomResourceDefinition
+metadata:
+  name: reportdatasources.chargeback.coreos.com
+  annotations:
+    catalog.app.coreos.com/displayName: "Chargeback data source"
+    catalog.app.coreos.com/description: "A resource describing a source of data for usage by Report Generation Queries"
+spec:
+  group: chargeback.coreos.com
+  version: v1alpha1
+  scope: Namespaced
+  names:
+    plural: reportdatasources
+    singular: reportdatasource
+    kind: ReportDataSource

+ 15 - 0
roles/openshift_metering/files/crds/reportgenerationquery.crd.yaml

@@ -0,0 +1,15 @@
+apiVersion: apiextensions.k8s.io/v1beta1
+kind: CustomResourceDefinition
+metadata:
+  name: reportgenerationqueries.chargeback.coreos.com
+  annotations:
+    catalog.app.coreos.com/displayName: "Chargeback generation query"
+    catalog.app.coreos.com/description: "A SQL query used by Chargeback to generate reports"
+spec:
+  group: chargeback.coreos.com
+  version: v1alpha1
+  scope: Namespaced
+  names:
+    plural: reportgenerationqueries
+    singular: reportgenerationquery
+    kind: ReportGenerationQuery

+ 15 - 0
roles/openshift_metering/files/crds/reportprometheusquery.crd.yaml

@@ -0,0 +1,15 @@
+apiVersion: apiextensions.k8s.io/v1beta1
+kind: CustomResourceDefinition
+metadata:
+  name: reportprometheusqueries.chargeback.coreos.com
+  annotations:
+    catalog.app.coreos.com/displayName: "Chargeback prometheus query"
+    catalog.app.coreos.com/description: "A Prometheus query by Chargeback to do metering"
+spec:
+  group: chargeback.coreos.com
+  version: v1alpha1
+  scope: Namespaced
+  names:
+    plural: reportprometheusqueries
+    singular: reportprometheusquery
+    kind: ReportPrometheusQuery

+ 14 - 0
roles/openshift_metering/files/crds/scheduledreport.crd.yaml

@@ -0,0 +1,14 @@
+apiVersion: apiextensions.k8s.io/v1beta1
+kind: CustomResourceDefinition
+metadata:
+  name: scheduledreports.chargeback.coreos.com
+  annotations:
+    catalog.app.coreos.com/displayName: "Chargeback Scheduled Report"
+    catalog.app.coreos.com/description: "A chargeback report that runs on a scheduled interval"
+spec:
+  group: chargeback.coreos.com
+  version: v1alpha1
+  scope: Namespaced
+  names:
+    plural: scheduledreports
+    kind: ScheduledReport

+ 14 - 0
roles/openshift_metering/files/crds/storagelocation.crd.yaml

@@ -0,0 +1,14 @@
+apiVersion: apiextensions.k8s.io/v1beta1
+kind: CustomResourceDefinition
+metadata:
+  name: storagelocations.chargeback.coreos.com
+  annotations:
+    catalog.app.coreos.com/displayName: "Chargeback storage location"
+    catalog.app.coreos.com/description: "Represents a configurable storage location for Chargeback to store metering and report data"
+spec:
+  group: chargeback.coreos.com
+  version: v1alpha1
+  scope: Namespaced
+  names:
+    plural: storagelocations
+    kind: StorageLocation

+ 96 - 0
roles/openshift_metering/files/operator/metering-helm-operator-deployment.yaml

@@ -0,0 +1,96 @@
+apiVersion: apps/v1beta1
+kind: Deployment
+metadata:
+  name: metering-helm-operator
+  labels:
+    app: metering-helm-operator
+spec:
+  replicas: 1
+  strategy:
+    type: Recreate
+  selector:
+    matchLabels:
+      app: metering-helm-operator
+  template:
+    metadata:
+      labels:
+        app: metering-helm-operator
+    spec:
+      securityContext:
+        runAsNonRoot: true
+      containers:
+      - name: metering-helm-operator
+        image: "quay.io/coreos/chargeback-helm-operator:0.6.1-latest"
+        args: ["run-operator.sh"]
+        imagePullPolicy: Always
+        env:
+        - name: HELM_RELEASE_CRD_NAME
+          value: Metering
+        - name: HELM_RELEASE_CRD_API_GROUP
+          value: chargeback.coreos.com
+        - name: HELM_CHART_PATH
+          value: /openshift-metering-0.1.0.tgz
+        - name: MY_POD_NAME
+          valueFrom:
+            fieldRef:
+              fieldPath: metadata.name
+        - name: MY_POD_NAMESPACE
+          valueFrom:
+            fieldRef:
+              fieldPath: metadata.namespace
+        - name: HELM_HOST
+          value: "127.0.0.1:44134"
+        - name: HELM_WAIT
+          value: "false"
+        - name: HELM_RECONCILE_INTERVAL_SECONDS
+          value: "30"
+        - name: RELEASE_HISTORY_LIMIT
+          value: "3"
+        resources:
+          requests:
+            memory: "25Mi"
+            cpu: "50m"
+          limits:
+            memory: "25Mi"
+            cpu: "50m"
+      - name: tiller
+        image: "quay.io/coreos/chargeback-helm-operator:0.6.1-latest"
+        args: ["/tiller"]
+        imagePullPolicy: Always
+        env:
+        - name: TILLER_NAMESPACE
+          valueFrom:
+            fieldRef:
+              fieldPath: metadata.namespace
+        - name: TILLER_HISTORY_MAX
+          value: "3"
+        resources:
+          requests:
+            memory: "50Mi"
+            cpu: "50m"
+          limits:
+            memory: "100Mi"
+            cpu: "50m"
+        livenessProbe:
+          failureThreshold: 3
+          httpGet:
+            path: /liveness
+            port: 44135
+            scheme: HTTP
+          initialDelaySeconds: 1
+          periodSeconds: 10
+          successThreshold: 1
+          timeoutSeconds: 1
+        readinessProbe:
+          failureThreshold: 3
+          httpGet:
+            path: /readiness
+            port: 44135
+            scheme: HTTP
+          initialDelaySeconds: 1
+          periodSeconds: 10
+          successThreshold: 1
+          timeoutSeconds: 1
+      restartPolicy: Always
+      terminationGracePeriodSeconds: 30
+      serviceAccount: metering-helm-operator

+ 144 - 0
roles/openshift_metering/files/operator/metering-helm-operator-role.yaml

@@ -0,0 +1,144 @@
+apiVersion: rbac.authorization.k8s.io/v1beta1
+kind: Role
+metadata:
+  name: metering-helm-operator
+rules:
+  - apiGroups:
+    - chargeback.coreos.com
+    resources:
+    - '*'
+    verbs:
+    - '*'
+  - apiGroups:
+    - ""
+    resources:
+    - pods
+    - pods/attach
+    - pods/exec
+    - pods/portforward
+    - pods/proxy
+    verbs:
+    - create
+    - delete
+    - deletecollection
+    - get
+    - list
+    - patch
+    - update
+    - watch
+  - apiGroups:
+    - ""
+    resources:
+    - configmaps
+    - endpoints
+    - persistentvolumeclaims
+    - replicationcontrollers
+    - replicationcontrollers/scale
+    - secrets
+    - serviceaccounts
+    - services
+    - services/proxy
+    verbs:
+    - create
+    - delete
+    - deletecollection
+    - get
+    - list
+    - patch
+    - update
+    - watch
+  - apiGroups:
+    - ""
+    resources:
+    - bindings
+    - events
+    - limitranges
+    - namespaces/status
+    - pods/log
+    - pods/status
+    - replicationcontrollers/status
+    - resourcequotas
+    - resourcequotas/status
+    verbs:
+    - get
+    - list
+    - watch
+  - apiGroups:
+    - ""
+    resources:
+    - events
+    verbs:
+    - create
+    - update
+    - patch
+  - apiGroups:
+    - ""
+    resources:
+    - namespaces
+    verbs:
+    - get
+    - list
+    - watch
+  - apiGroups:
+    - apps
+    resources:
+    - deployments
+    - deployments/rollback
+    - deployments/scale
+    - statefulsets
+    verbs:
+    - create
+    - delete
+    - deletecollection
+    - get
+    - list
+    - patch
+    - update
+    - watch
+  - apiGroups:
+    - batch
+    resources:
+    - cronjobs
+    - jobs
+    verbs:
+    - create
+    - delete
+    - deletecollection
+    - get
+    - list
+    - patch
+    - update
+    - watch
+  - apiGroups:
+    - extensions
+    resources:
+    - daemonsets
+    - deployments
+    - deployments/rollback
+    - deployments/scale
+    - replicasets
+    - replicasets/scale
+    - replicationcontrollers/scale
+    verbs:
+    - create
+    - delete
+    - deletecollection
+    - get
+    - list
+    - patch
+    - update
+    - watch
+  - apiGroups:
+    - rbac.authorization.k8s.io
+    resources:
+    - rolebindings
+    - roles
+    verbs:
+    - create
+    - delete
+    - deletecollection
+    - get
+    - list
+    - patch
+    - update
+    - watch

+ 11 - 0
roles/openshift_metering/files/operator/metering-helm-operator-rolebinding.yaml

@@ -0,0 +1,11 @@
+apiVersion: rbac.authorization.k8s.io/v1beta1
+kind: RoleBinding
+metadata:
+  name: metering-helm-operator
+roleRef:
+  apiGroup: rbac.authorization.k8s.io
+  kind: Role
+  name: metering-helm-operator
+subjects:
+- kind: ServiceAccount
+  name: metering-helm-operator

+ 4 - 0
roles/openshift_metering/files/operator/metering-helm-operator-service-account.yaml

@@ -0,0 +1,4 @@
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+  name: metering-helm-operator

+ 5 - 0
roles/openshift_metering/files/operator/metering.yaml

@@ -0,0 +1,5 @@
+apiVersion: chargeback.coreos.com/v1alpha1
+kind: Metering
+metadata:
+  name: openshift-metering
+spec:

+ 22 - 0
roles/openshift_metering/meta/main.yaml

@@ -0,0 +1,22 @@
+---
+galaxy_info:
+  author: OpenShift Development <dev@lists.openshift.redhat.com>
+  description: Deploy OpenShift metering
+  company: Red Hat, Inc.
+  license: Apache License, Version 2.0
+  min_ansible_version: 2.4
+  platforms:
+  - name: EL
+    versions:
+    - 7
+  - name: Fedora
+    versions:
+    - all
+  categories:
+  - openshift
+  - metering
+  - operator
+dependencies:
+- role: lib_openshift
+- role: lib_utils
+- role: openshift_facts

+ 120 - 0
roles/openshift_metering/tasks/install.yaml

@@ -0,0 +1,120 @@
+---
+- name: Create temp directory for doing work in on target
+  command: mktemp -td openshift-metering-ansible-XXXXXX
+  register: mktemp
+  changed_when: False
+
+- name: Ensures {{ mktemp.stdout }}/metering-manifests directories exists
+  file:
+    path: "{{ item }}"
+    state: directory
+  with_items:
+  - "{{ mktemp.stdout }}/metering-manifests/operator"
+
+- name: Copy operator files to temp directory
+  copy:
+    src: "{{ item }}"
+    dest: "{{ mktemp.stdout }}/metering-manifests/operator/{{ item | basename }}"
+  with_fileglob:
+  - "files/operator/*.yaml"
+  register: temp_operator_files
+
+- name: Update Metering Helm Operator deployment image
+  yedit:
+    src: "{{ mktemp.stdout }}/metering-manifests/operator/metering-helm-operator-deployment.yaml"
+    edits:
+    - key: spec.template.spec.containers[0].image
+      value: "{{ openshift_metering_operator_image }}"
+    - key: spec.template.spec.containers[1].image
+      value: "{{ openshift_metering_operator_image }}"
+  when: openshift_metering_operator_image != ""
+
+- name: Update Metering config
+  yedit:
+    src: "{{ mktemp.stdout }}/metering-manifests/operator/metering.yaml"
+    edits:
+    - key: spec
+      value: "{{ openshift_metering_config }}"
+  when: openshift_metering_config != None
+
+- name: Fetch updated operator manifests
+  fetch:
+    src: "{{ item.dest }}"
+    dest: "/tmp/updated_manifests/"
+    flat: true
+  with_items: "{{ temp_operator_files.results }}"
+  register: updated_operator_manifests
+  loop_control:
+    label: "{{ item.dest }}"
+
+- name: "Create {{ __openshift_metering_namespace }} project"
+  oc_project:
+    state: present
+    name: "{{ __openshift_metering_namespace }}"
+    description: Openshift Metering
+    node_selector: ""
+
+- name: Create metering namespace viewer cluster role
+  oc_clusterrole:
+    state: present
+    name: "openshift-metering-namespace-viewer-{{ __openshift_metering_namespace }}"
+    rules:
+    - apiGroups: [""]
+      resources: ["namespaces"]
+      verbs: ["get"]
+
+- name: Create namespace viewer clusterrolebinding
+  oc_obj:
+    state: present
+    kind: ClusterRoleBinding
+    name: "openshift-metering-namespace-viewer-{{ __openshift_metering_namespace }}"
+    content:
+      path: "{{ mktemp.stdout }}/openshift-metering-namespace-viewer-{{ __openshift_metering_namespace }}"
+      data:
+        apiVersion: v1
+        kind: ClusterRoleBinding
+        metadata:
+          name: "openshift-metering-namespace-viewer-{{ __openshift_metering_namespace }}"
+        roleRef:
+          apiGroup: rbac.authorization.k8s.io
+          kind: ClusterRole
+          name: "openshift-metering-namespace-viewer-{{ __openshift_metering_namespace }}"
+        subjects:
+        - kind: ServiceAccount
+          name: metering
+          namespace: "{{ __openshift_metering_namespace }}"
+
+- name: Install Metering CRDs
+  oc_obj:
+    state: present
+    kind: "{{ obj.kind }}"
+    name: "{{ obj.metadata.name }}"
+    namespace: "{{ __openshift_metering_namespace }}"
+    content:
+      path: "/tmp/{{ obj.kind }}-{{ obj.metadata.name }}.yaml"
+      data: "{{ obj }}"
+  vars:
+    obj: "{{ lookup('file', item) | from_yaml }}"
+  with_fileglob:
+  - "files/crds/*.yaml"
+
+- name: Install Metering Helm Operator
+  oc_obj:
+    state: present
+    kind: "{{ obj.kind }}"
+    name: "{{ obj.metadata.name }}"
+    namespace: "{{ __openshift_metering_namespace }}"
+    content:
+      path: "/tmp/{{ obj.kind }}-{{ obj.metadata.name }}.yaml"
+      data: "{{ obj }}"
+  vars:
+    obj: "{{ lookup('file', item.dest) | from_yaml }}"
+  with_items: "{{ updated_operator_manifests.results }}"
+  loop_control:
+    label: "{{ item.dest }}"
+
+- name: Delete temp directory
+  file:
+    name: "{{ mktemp.stdout }}"
+    state: absent
+  changed_when: False

+ 6 - 0
roles/openshift_metering/tasks/main.yaml

@@ -0,0 +1,6 @@
+---
+- include_tasks: install.yaml
+  when: openshift_metering_install | default(true) | bool
+
+- include_tasks: uninstall.yaml
+  when: not openshift_metering_install | default(true) | bool

+ 16 - 0
roles/openshift_metering/tasks/uninstall.yaml

@@ -0,0 +1,16 @@
+---
+- name: "Remove {{ __openshift_metering_namespace }} project"
+  oc_project:
+    name: "{{ __openshift_metering_namespace }}"
+    state: absent
+
+- name: Remove namespace viewer clusterrolebinding from openshift-metering
+  oc_obj:
+    state: absent
+    kind: ClusterRoleBinding
+    name: "openshift-metering-namespace-viewer-{{ __openshift_metering_namespace }}"
+
+- name: Remove metering namespace viewer cluster role
+  oc_clusterrole:
+    state: absent
+    name: "openshift-metering-namespace-viewer-{{ __openshift_metering_namespace }}"

+ 2 - 0
roles/openshift_metering/vars/main.yml

@@ -0,0 +1,2 @@
+---
+__openshift_metering_namespace: openshift-metering