main.yml 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 is succeeded
  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 is 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 }}"
  24. state: directory
  25. mode: 0777
  26. owner: nfsnobody
  27. group: nfsnobody
  28. with_items:
  29. - "{{ openshift_hosted_registry_storage_nfs_directory }}/{{ openshift_hosted_registry_storage_volume_name }}"
  30. - "{{ openshift_metrics_storage_nfs_directory }}/{{ openshift_metrics_storage_volume_name }}"
  31. - "{{ openshift_logging_storage_nfs_directory }}/{{ openshift_logging_storage_volume_name }}"
  32. - "{{ openshift_loggingops_storage_nfs_directory }}/{{ openshift_loggingops_storage_volume_name }}"
  33. - "{{ openshift_hosted_etcd_storage_nfs_directory }}/{{ openshift_hosted_etcd_storage_volume_name }}"
  34. - name: Configure exports
  35. template:
  36. dest: /etc/exports.d/openshift-ansible.exports
  37. src: exports.j2
  38. notify:
  39. - restart nfs-server
  40. # Now that we're putting our exports in our own file clean up the old ones
  41. - name: register exports
  42. command: cat /etc/exports.d/openshift-ansible.exports
  43. register: exports_out
  44. - name: remove exports from /etc/exports
  45. lineinfile:
  46. dest: /etc/exports
  47. line: "{{ item }}"
  48. state: absent
  49. with_items: "{{ exports_out.stdout_lines | default([]) }}"
  50. when: exports_out.rc == 0
  51. notify:
  52. - restart nfs-server
  53. - name: Enable and start services
  54. systemd:
  55. name: nfs-server
  56. state: started
  57. enabled: yes
  58. register: start_result
  59. - set_fact:
  60. nfs_service_status_changed: "{{ start_result is changed }}"