main.yml 1.7 KB

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