me4_nfs_server_setup.yml 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # Copyright 2021 Dell Inc. or its subsidiaries. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. ---
  15. - name: Install nfs-utils
  16. package:
  17. name: nfs-utils
  18. state: present
  19. - name: Install firewalld
  20. package:
  21. name: firewalld
  22. state: present
  23. - name: Start and enable firewalld
  24. service:
  25. name: firewalld
  26. state: started
  27. enabled: yes
  28. - name: Start and enable rpcbind and nfs-server service
  29. service:
  30. name: "{{ item }}"
  31. state: restarted
  32. enabled: yes
  33. with_items:
  34. - rpcbind
  35. - nfs-server
  36. - name: Adding K8s NFS share entries in /etc/exports
  37. lineinfile:
  38. path: "{{ exports_file_path }}"
  39. line: "{{ me4_nfs_share_k8s }} {{ item }}(rw,sync,no_root_squash)"
  40. with_items:
  41. - "{{ groups['manager'] }}"
  42. - "{{ groups['compute'] }}"
  43. - name: Adding K8s NFS share entries in /etc/exports
  44. lineinfile:
  45. path: "{{ exports_file_path }}"
  46. line: "{{ me4_nfs_share_k8s }} {{ item }}(rw,sync,no_root_squash)"
  47. with_items:
  48. - "{{ groups['manager'] }}"
  49. - "{{ groups['compute'] }}"
  50. - name: Adding Slurm NFS share entries in /etc/exports
  51. lineinfile:
  52. path: "{{ exports_file_path }}"
  53. line: "{{ me4_nfs_share_slurm }} {{ item }}(rw,sync,no_root_squash)"
  54. with_items:
  55. - "{{ groups['manager'] }}"
  56. - "{{ groups['compute'] }}"
  57. - name: Exporting the shared directories
  58. command: exportfs -ra
  59. changed_when: true
  60. - name: Configuring firewall
  61. firewalld:
  62. service: "{{ item }}"
  63. permanent: true
  64. state: enabled
  65. with_items:
  66. - "{{ nfs_services }}"
  67. - name: Reload firewalld
  68. command: firewall-cmd --reload
  69. changed_when: true