main.yml 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ---
  2. - name: Install nfs-utils
  3. package: 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: "{{ item.storage.nfs.directory }}/{{ item.storage.volume.name }}"
  20. state: directory
  21. mode: 0777
  22. owner: nfsnobody
  23. group: nfsnobody
  24. with_items:
  25. - "{{ openshift.hosted.registry }}"
  26. - "{{ openshift.hosted.metrics }}"
  27. - "{{ openshift.hosted.logging }}"
  28. - name: Configure exports
  29. template:
  30. dest: /etc/exports.d/openshift-ansible.exports
  31. src: exports.j2
  32. notify:
  33. - restart nfs-server
  34. # Now that we're putting our exports in our own file clean up the old ones
  35. - name: register exports
  36. command: cat /etc/exports.d/openshift-ansible.exports
  37. register: exports_out
  38. - name: remove exports from /etc/exports
  39. lineinfile:
  40. dest: /etc/exports
  41. line: "{{ item }}"
  42. state: absent
  43. with_items: "{{ exports_out.stdout_lines | default([]) }}"
  44. when: exports_out.rc == 0
  45. notify:
  46. - restart nfs-server
  47. - name: Enable and start services
  48. service:
  49. name: "{{ item }}"
  50. state: started
  51. enabled: yes
  52. register: start_result
  53. with_items:
  54. - nfs-server
  55. - set_fact:
  56. nfs_service_status_changed: "{{ start_result | changed }}"