main.yml 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. ---
  2. - name: Install nfs-utils
  3. action: "{{ ansible_pkg_mgr }} name=nfs-utils state=present"
  4. - name: Configure NFS
  5. lineinfile:
  6. dest: /etc/sysconfig/nfs
  7. regexp: '^RPCNFSDARGS=.*$'
  8. line: 'RPCNFSDARGS="-N 2 -N 3"'
  9. register: nfs_config
  10. - name: Restart nfs-config
  11. service: name=nfs-config state=restarted
  12. when: nfs_config | changed
  13. - name: Ensure exports directory exists
  14. file:
  15. path: "{{ openshift.hosted.registry.storage.nfs.directory }}"
  16. state: directory
  17. - name: Ensure export directories exist
  18. file:
  19. path: "{{ openshift.hosted.registry.storage.nfs.directory }}/{{ item }}"
  20. state: directory
  21. mode: 0777
  22. owner: nfsnobody
  23. group: nfsnobody
  24. with_items:
  25. - "{{ openshift.hosted.registry.storage.volume.name }}"
  26. - name: Configure exports
  27. template:
  28. dest: /etc/exports.d/openshift-ansible.exports
  29. src: exports.j2
  30. notify:
  31. - restart nfs-server
  32. # Now that we're putting our exports in our own file clean up the old ones
  33. - name: register exports
  34. command: cat /etc/exports.d/openshift-ansible.exports
  35. register: exports_out
  36. - name: remove exports from /etc/exports
  37. lineinfile:
  38. dest: /etc/exports
  39. line: "{{ item }}"
  40. state: absent
  41. with_items: "{{ exports_out.stdout_lines | default([]) }}"
  42. when: exports_out.rc == 0
  43. notify:
  44. - restart nfs-server
  45. - name: Enable and start services
  46. service:
  47. name: "{{ item }}"
  48. state: started
  49. enabled: yes
  50. register: start_result
  51. with_items:
  52. - nfs-server
  53. - set_fact:
  54. nfs_service_status_changed: "{{ start_result | changed }}"