Skip to content

Commit

Permalink
OCTOPUS-697: OCP login operation is invoked before NFS deployment
Browse files Browse the repository at this point in the history
Signed-off-by: Chandan Abhyankar <[email protected]>
  • Loading branch information
Chandan-Abhyankar authored and prb112 committed Apr 16, 2024
1 parent 76c7e7a commit 3597583
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 47 deletions.
6 changes: 1 addition & 5 deletions ansible/post/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@
labels: "{{ node_labels }}"
with_items: "{{ node_names.stdout_lines }}"

- name: Setup NFS storage if NFS_SERVER is provided
import_tasks: nfs_provisioner.yaml
when: nfs_server != "none"

- name: Cleanup events in openshift-etcd for cicd
when: cicd == "true"
shell: |
export HTTPS_PROXY=http://{{ nfs_server }}:3128 && oc delete events --all=true -n openshift-etcd
export HTTPS_PROXY=http://{{ nfs_server }}:3128 && oc delete events --all=true -n openshift-etcd
4 changes: 0 additions & 4 deletions ansible/support/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,3 @@
delay: 30
timeout: 600

- name: Setup NFS storage if NFS_SERVER is provided
import_tasks: nfs_provisioner.yaml
when: nfs_server != "none"

38 changes: 0 additions & 38 deletions ansible/support/tasks/nfs_provisioner.yaml

This file was deleted.

47 changes: 47 additions & 0 deletions ansible/support/tasks/nfs_provisioner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
- hosts: all

handlers:
- import_tasks: ../handlers/main.yml

tasks:

- name: Create nfs-provisioner Project
kubernetes.core.k8s:
state: present
proxy: "http://{{ nfs_server }}:3128"
definition: "{{ lookup('template', '../templates/nfs-ns.yml') }}"

- name: Create RBAC for nfs-provisioner
kubernetes.core.k8s:
state: present
proxy: "http://{{ nfs_server }}:3128"
definition: "{{ lookup('template', '../templates/nfs-rbac.yml') }}"

- name: Setup Authorization
shell: "export HTTPS_PROXY=http://{{ nfs_server }}:3128 && oc adm policy add-scc-to-user hostmount-anyuid system:serviceaccount:nfs-provisioner:nfs-client-provisioner"

- name: Create Deployment for nfs-provisioner
kubernetes.core.k8s:
state: present
proxy: "http://{{ nfs_server }}:3128"
definition: "{{ lookup('template', '../templates/nfs-deployment.yml.j2') }}"

- name: Create Storage Class for nfs
kubernetes.core.k8s:
state: present
proxy: "http://{{ nfs_server }}:3128"
definition: "{{ lookup('template', '../templates/nfs-sc.yml') }}"

- name: Ensure nfs-provisioner Pod is up and running fine
shell: "export HTTPS_PROXY=http://{{ nfs_server }}:3128 && oc get pods -n nfs-provisioner"
register: pod_output
until: pod_output.stdout.find("Running") != -1
retries: 10
delay: 30

- name: Remove the block storage as the default.
shell: |
export HTTPS_PROXY=http://{{ nfs_server }}:3128 \
&& oc patch storageclass ibmc-vpc-block-10iops-tier -p '{"metadata": {"annotations": {"storageclass.kubernetes.io/is-default-class": "false"}}}'
22 changes: 22 additions & 0 deletions modules/4_pvs_support/pvs_support.tf
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,28 @@ EOF
}
}

# Dev Note: setup nfs deployment
resource "null_resource" "nfs_deployment" {
depends_on = [null_resource.config_login]
connection {
type = "ssh"
user = var.rhel_username
host = var.bastion_public_ip
private_key = file(var.private_key_file)
agent = var.ssh_agent
timeout = "${var.connection_timeout}m"
}

provisioner "remote-exec" {
inline = [<<EOF
echo 'Running ocp4-upi-compute-powervs playbook...'
cd ocp4-upi-compute-powervs/support
ANSIBLE_LOG_PATH=/root/.openshift/ocp4-upi-compute-powervs-support-nfs-deploy.log ansible-playbook -e @vars/vars.yaml tasks/nfs_provisioner.yml --become || true
EOF
]
}
}

resource "null_resource" "config_csi" {
depends_on = [null_resource.config_login, null_resource.config]
connection {
Expand Down

0 comments on commit 3597583

Please sign in to comment.