diff --git a/openshift/gitlab.yml b/openshift/gitlab.yml new file mode 100644 index 000000000..172e81ac5 --- /dev/null +++ b/openshift/gitlab.yml @@ -0,0 +1,130 @@ +--- +- name: Deploy gitlab on OCP + hosts: localhost + gather_facts: false + + tasks: + - name: create cert-manager-operator namespace + redhat.openshift.k8s: + name: cert-manager-operator + api_version: v1 + kind: Namespace + state: present + + - name: create OperatorGroup object for cert-manager-operator + redhat.openshift.k8s: + state: present + definition: + apiVersion: operators.coreos.com/v1 + kind: OperatorGroup + metadata: + name: cert-manager-operator-operatorgroup + namespace: cert-manager-operator + spec: + targetNamespaces: + - cert-manager-operator + + - name: create cert-manager-operator subscription + redhat.openshift.k8s: + state: present + definition: + apiVersion: operators.coreos.com/v1alpha1 + kind: Subscription + metadata: + labels: + operators.coreos.com/openshift-cert-manager-operator.cert-manager-operator: '' + name: openshift-cert-manager-operator + namespace: cert-manager-operator + spec: + channel: stable-v1 + installPlanApproval: Automatic + name: openshift-cert-manager-operator + source: redhat-operators + sourceNamespace: openshift-marketplace + + - name: create gitlab-system namespace + redhat.openshift.k8s: + name: gitlab-system + api_version: v1 + kind: Namespace + state: present + + - name: create OperatorGroup object for gitlab-operator-kubernetes + redhat.openshift.k8s: + state: present + definition: + apiVersion: operators.coreos.com/v1 + kind: OperatorGroup + metadata: + name: gitlab-operator-kubernetes-operatorgroup + namespace: gitlab-system + spec: + targetNamespaces: + - gitlab-system + + - name: create gitlab subscription + redhat.openshift.k8s: + state: present + definition: + apiVersion: operators.coreos.com/v1alpha1 + kind: Subscription + metadata: + labels: + operators.coreos.com/gitlab-operator-kubernetes.gitlab-system: '' + name: gitlab-operator-kubernetes + namespace: gitlab-system + spec: + channel: stable + installPlanApproval: Automatic + name: gitlab-operator-kubernetes + source: community-operators + sourceNamespace: openshift-marketplace + + - name: wait for gitlab operator to install + k8s_info: + api_version: apiextensions.k8s.io/v1 + kind: CustomResourceDefinition + name: gitlabs.apps.gitlab.com + register: crd_gitlab + until: crd_gitlab.resources | list | length == 1 + retries: 10 + delay: 30 + + - name: Wait until gitlab-operator is up + k8s_info: + api_version: v1 + kind: Deployment + name: gitlab-controller-manager + namespace: gitlab-system + register: pod_list + until: pod_list|json_query('resources[*].status.readyReplicas')|unique >= [1] + retries: 10 + delay: 30 + + - name: Deploy a GitLab instance + redhat.openshift.k8s: + state: present + definition: + apiVersion: apps.gitlab.com/v1beta1 + kind: GitLab + metadata: + name: gitlab + namespace: gitlab-system + spec: + chart: + version: "6.11.0" + values: + nginx-ingress: + enabled: false + certmanager: + install: false + global: + hosts: + domain: "{{ cluster_domain }}" # apps.cluster-9xrlv.9xrlv.sandbox644.opentlc.com + ingress: + class: none + configureCertmanager: true + annotations: + route.openshift.io/termination: "edge" + certmanager-issuer: + email: "{{ cert_email | default('nobody@nowhere.nosite') }}" diff --git a/openshift/setup.yml b/openshift/setup.yml index 14035878b..1f8c5a615 100644 --- a/openshift/setup.yml +++ b/openshift/setup.yml @@ -23,3 +23,24 @@ controller_templates: notification_templates_error: Telemetry credentials: - "OpenShift Credential" + + - name: OpenShift / GitLab + job_type: run + inventory: "Demo Inventory" + project: "Ansible official demo project" + playbook: "openshift/gitlab.yml" + notification_templates_started: Telemetry + notification_templates_success: Telemetry + notification_templates_error: Telemetry + credentials: + - "OpenShift Credential" + survey_enabled: true + survey: + name: '' + description: '' + spec: + - question_name: Enter the base domain for your cluster + default: 'Example: apps.cluster-123ab.123ab.sandbox987.opentlc.com' + type: text + variable: cluster_domain + required: true