Deployment automation for oran-o2ims operator on OKD/Stolostron
The oran-o2ims operator (https://github.com/openshift-kni/oran-o2ims)
provides O2 IMS and DMS API interfaces for OKD/Stolostron clusters.
Issue-ID: INF-480
Change-Id: I5800245971e85cb97a13d08d27d1586528979a70
Signed-off-by: Chris Wheeler <chwheele@redhat.com>
diff --git a/okd/roles/ocloud/tasks/main.yml b/okd/roles/ocloud/tasks/main.yml
index 6820b37..c1a565e 100644
--- a/okd/roles/ocloud/tasks/main.yml
+++ b/okd/roles/ocloud/tasks/main.yml
@@ -18,3 +18,9 @@
name: "ocloud_platform_stolostron"
delegate_to: "{{ groups['deployer'][0] }}"
when: ocloud_platform == "okd"
+
+- name: Include platform role - oran-o2ims
+ ansible.builtin.import_role:
+ name: "ocloud_platform_o2ims"
+ delegate_to: "{{ groups['deployer'][0] }}"
+ when: ocloud_platform == "okd"
diff --git a/okd/roles/ocloud_platform_o2ims/defaults/main.yml b/okd/roles/ocloud_platform_o2ims/defaults/main.yml
new file mode 100644
index 0000000..1b1d126
--- /dev/null
+++ b/okd/roles/ocloud_platform_o2ims/defaults/main.yml
@@ -0,0 +1,6 @@
+---
+ocloud_platform_o2ims_golang_url: "https://go.dev/dl/go1.23.2.linux-amd64.tar.gz"
+ocloud_platform_o2ims_kubeconfig: "{{ ocloud_platform_okd_kubeconfig }}"
+ocloud_platform_o2ims_repo_url: "https://github.com/openshift-kni/oran-o2ims.git"
+ocloud_platform_o2ims_repo_version: "main"
+ocloud_platform_o2ims_service: "o2ims"
diff --git a/okd/roles/ocloud_platform_o2ims/tasks/main.yml b/okd/roles/ocloud_platform_o2ims/tasks/main.yml
new file mode 100644
index 0000000..4ab2085
--- /dev/null
+++ b/okd/roles/ocloud_platform_o2ims/tasks/main.yml
@@ -0,0 +1,87 @@
+---
+- name: Gather facts
+ ansible.builtin.setup:
+ gather_subset: all
+
+- name: Create staging dir for orano2ims installation
+ ansible.builtin.tempfile:
+ state: directory
+ register: ocloud_platform_o2ims_staging_dir
+
+- name: Create staging subdirs
+ ansible.builtin.file:
+ path: "{{ ocloud_platform_o2ims_staging_dir['path'] }}/{{ item }}"
+ state: directory
+ loop:
+ - go
+ - git
+
+- name: Download golang
+ ansible.builtin.get_url:
+ url: "{{ ocloud_platform_o2ims_golang_url }}"
+ dest: "{{ ocloud_platform_o2ims_staging_dir['path'] }}/go.linux-amd64.tar.gz"
+
+- name: Extract golang
+ ansible.builtin.unarchive:
+ src: "{{ ocloud_platform_o2ims_staging_dir['path'] }}/go.linux-amd64.tar.gz"
+ dest: "{{ ocloud_platform_o2ims_staging_dir['path'] }}"
+ remote_src: true
+
+- name: Clone oran-o2ims repo
+ ansible.builtin.git:
+ repo: "{{ ocloud_platform_o2ims_repo_url }}"
+ version: "{{ ocloud_platform_o2ims_repo_version }}"
+ dest: "{{ ocloud_platform_o2ims_staging_dir['path'] }}/git"
+
+- name: Deploy oran-o2ims operator
+ ansible.builtin.shell:
+ chdir: "{{ ocloud_platform_o2ims_staging_dir['path'] }}/git"
+ cmd: "make deploy"
+ environment:
+ PATH: "{{ ocloud_platform_o2ims_staging_dir['path'] }}/go/bin:{{ ansible_env.PATH }}"
+ KUBECONFIG: "{{ ocloud_platform_o2ims_kubeconfig }}"
+
+- name: Install oran-o2ims custom resource definitions
+ ansible.builtin.shell:
+ chdir: "{{ ocloud_platform_o2ims_staging_dir['path'] }}/git"
+ cmd: "make install"
+ environment:
+ PATH: "{{ ocloud_platform_o2ims_staging_dir['path'] }}/go/bin:{{ ansible_env.PATH }}"
+ KUBECONFIG: "{{ ocloud_platform_o2ims_kubeconfig }}"
+
+- name: Get Infrastructure config
+ kubernetes.core.k8s_info:
+ api_version: config.openshift.io/v1
+ kind: Infrastructure
+ name: cluster
+ kubeconfig: "{{ ocloud_platform_o2ims_kubeconfig }}"
+ register: ocloud_platform_o2ims_infrastructure_info
+
+- name: Get IngressController config
+ kubernetes.core.k8s_info:
+ api_version: operator.openshift.io/v1
+ kind: IngressController
+ name: default
+ namespace: openshift-ingress-operator
+ kubeconfig: "{{ ocloud_platform_o2ims_kubeconfig }}"
+ register: ocloud_platform_o2ims_ingresscontroller_info
+
+- name: Get search-api Route config
+ kubernetes.core.k8s_info:
+ api_version: route.openshift.io/v1
+ kind: Route
+ name: search-api
+ namespace: open-cluster-management
+ kubeconfig: "{{ ocloud_platform_o2ims_kubeconfig }}"
+ register: ocloud_platform_o2ims_search_api_route_info
+
+- set_fact:
+ ocloud_platform_o2ims_api_url: "{{ ocloud_platform_o2ims_infrastructure_info['resources'][0]['status']['apiServerURL'] }}"
+ ocloud_platform_o2ims_ingress_host: "{{ ocloud_platform_o2ims_service }}.{{ ocloud_platform_o2ims_ingresscontroller_info['resources'][0]['status']['domain'] }}"
+ ocloud_platform_o2ims_search_api_url: "https://{{ ocloud_platform_o2ims_search_api_route_info['resources'][0]['spec']['host'] }}"
+
+- name: Create Inventory resource
+ kubernetes.core.k8s:
+ template: v1alpha1_inventory.yaml.j2
+ state: present
+ kubeconfig: "{{ ocloud_platform_o2ims_kubeconfig }}"
diff --git a/okd/roles/ocloud_platform_o2ims/templates/v1alpha1_inventory.yaml.j2 b/okd/roles/ocloud_platform_o2ims/templates/v1alpha1_inventory.yaml.j2
new file mode 100644
index 0000000..284dbf5
--- /dev/null
+++ b/okd/roles/ocloud_platform_o2ims/templates/v1alpha1_inventory.yaml.j2
@@ -0,0 +1,25 @@
+apiVersion: o2ims.oran.openshift.io/v1alpha1
+kind: Inventory
+metadata:
+ labels:
+ app.kubernetes.io/name: inventory
+ app.kubernetes.io/instance: inventory-sample
+ app.kubernetes.io/part-of: oran-o2ims
+ app.kubernetes.io/managed-by: kustomize
+ app.kubernetes.io/created-by: oran-o2ims
+ name: default
+ namespace: oran-o2ims
+spec:
+ cloudID: {{ ocloud_platform_o2ims_ingress_host | to_uuid }}
+ ingressHost: {{ ocloud_platform_o2ims_ingress_host }}
+ alarmSubscriptionServerConfig:
+ enabled: false
+ metadataServerConfig:
+ enabled: true
+ deploymentManagerServerConfig:
+ enabled: true
+ backendURL: "{{ ocloud_platform_o2ims_api_url }}"
+ backendType: regular-hub
+ resourceServerConfig:
+ enabled: true
+ backendURL: "{{ocloud_platform_o2ims_search_api_url }}"