I'm facing a weird issue while executing Ansible play to un-install hadoop clusters (based on flags passed as arguement) from K8s environment.
I've written the below playbook which will install Hadoop clusters using Helm Chart and will uninstall Hadoop clusters
- name: Unistalling hadoop from K8s block: - name: Uninstall Hadoop Cluster usning helm command: "{{helm_location}}/helm uninstall --namespace {{hadoop_namespace}} {{hadoop_release_name}}" register: helm_hadoop_result - debug: var: helm_hadoop_result.stdout_lines - name: Checking PVC status in "{{hadoop_namespace}}" action: shell kubectl get pvc -n "{{hadoop_namespace}}" | grep -v NAME | cut -d ' ' -f1 register: hadoop_pvc_status until: hadoop_pvc_status.stdout_lines != '' - debug: var: hadoop_pvc_status.stdout_lines
- name: Remove PVC for Hadoop Clusters (Cleanup occupied storages)
command: "kubectl delete pvc -n {{hadoop_namespace}} {{hadoop_pvc_status.stdout}}"
register: hadoop_pvc_delete_status
when: hadoop_pvc_status.stdout_lines != ''
- debug:
var: hadoop_pvc_delete_status.stdout_lines
when: "'uninstall' == task_type and 'hadoop' in if_hadoop.stdout and 'deployed' in if_hadoop.stdout"
- name: Playbook Signature block: - debug: msg: "No 'task_type' supplied. Playbook signature: ansible-playbook -i <hosts file> <playbook> --extra-vars 'task_type=<install/uninstall>'" when: "task_type == '' or ('install' or 'uninstall') not in task_type"
I'm getting the below error while the kubectl get pvc with condtional options are executed.
"stderr": "Error from server (NotFound): persistentvolumeclaims \"hadoop-hadoop-hdfs-dn\" not found\nError from server (NotFound): persistentvolumeclaims \"hadoop-hadoop-hdfs-nn\" not found", "stderr_lines": ["Error from server (NotFound): persistentvolumeclaims \"hadoop-hadoop-hdfs-dn\" not found", "Error from server (NotFound): persistentvolumeclaims \"hadoop-hadoop-hdfs-nn\" not found"]
However, the pvc status already captured after Helm Uninstall. ok: [127.0.0.1] => { "hadoop_pvc_status.stdout_lines": [ "hadoop-hadoop-hdfs-dn", "hadoop-hadoop-hdfs-nn" ] }
Can someone help me on this ?