Is there any script to cleanup files in /var/openebs?

116 views Asked by At

I tried to look at documentation and code of GitHub, including ee ansible scripts Is there already made script to clean up files in /var/openebs? I mean deleted PVs Something like: kubectl get pv --no-headers -o custom-columns=:metadata.name and then delete the rest of pack

1

There are 1 answers

0
Ajesh On

Looking at this info, looks like you are running on the code below 0.7.2 version. The OpenEBS versions above 0.7.2 code handles with a job which will be scheduled on the node to clear up the data. However if you would want to clenanup in older version got this code from OpenEBS community users, where they have the below sample code

- hosts: localhost
 tasks:
 - name: Get list of volumes
   shell: kubectl get pv --no-headers -o custom-columns=:metadata.name
   args:
     executable: /bin/bash
   check_mode: no
   register: volume_list

 - debug: var=volume_list

- hosts: all
 tasks:

 - name: get files in path
   find:
     path: /var/openebs
     recurse: no
     file_type: directory
     patterns: 'pvc-*'
   register: path_files

 - name: Delete volumes
   file:
     path={{ item.path }}
     state=absent
   with_items: " {{ path_files.files }} "
   when: item.path | basename not in hostvars['localhost']['volume_list']['stdout_lines']