github.com/jlmeeker/kismatic@v1.10.1-0.20180612190640-57f9005a1f1a/ansible/roles/nfs-volume/tasks/new-share.yaml (about)

     1  # - debug:
     2  #     var: item.1
     3  - set_fact:
     4      nfs_index: "{{item.0}}"
     5      nfs_host: "{{item.1.host}}"
     6      nfs_path: "{{item.1.path}}"
     7  
     8  - name: mount share read/write
     9    mount:
    10      name: "/mnt/test-{{nfs_index}}"
    11      src: "{{nfs_host}}:{{nfs_path}}"
    12      fstype: nfs
    13      state: mounted
    14  
    15  #Backslash escaped Regex to find the available size in df output such as this:
    16  #Filesystem      1K-blocks   Used Available Use% Mounted on
    17  #/mnt/test-0      12246332 882716  10760892   8% /
    18  - name: Grab share size
    19    shell: "df /mnt/test-{{nfs_index}} | grep -oP '\\K\\d+(?=\\s+\\d+%)'"
    20    register: nfs_size_blob
    21  
    22  # - debug:
    23  #     var: nfs_size_blob
    24  
    25  - set_fact:
    26      nfs_size: "{{nfs_size_blob.stdout}}"
    27  
    28  # - debug:
    29  #     var: nfs_size
    30  
    31  - name: unmount share read/write
    32    mount:
    33      name: "/mnt/test-{{nfs_index}}"
    34      src: "{{nfs_host}}:{{nfs_path}}"
    35      fstype: nfs
    36      state: unmounted
    37  
    38  - name: copy PV.yaml to remote
    39    template:
    40      src: add-persistent-volume.yaml
    41      dest: "{{ kubernetes_spec_dir }}/add-persistent-volume-{{nfs_index}}.yaml"
    42  
    43  - name: create pv pv{{ nfs_index }}
    44    command: kubectl --kubeconfig {{ kubernetes_kubeconfig.kubectl }} apply -f {{ kubernetes_spec_dir }}/add-persistent-volume-{{nfs_index}}.yaml