main.yml 1.8 KB

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