main.yml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # Copyright 2020 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. tags: nfs_server
  20. - name: Install firewalld
  21. package:
  22. name: firewalld
  23. state: present
  24. tags: firewalld
  25. - name: Start and enable firewalld
  26. service:
  27. name: firewalld
  28. state: started
  29. enabled: yes
  30. tags: firewalld
  31. - name: Start and enable rpcbind and nfs-server service
  32. service:
  33. name: "{{ item }}"
  34. state: restarted
  35. enabled: yes
  36. with_items:
  37. - rpcbind
  38. - nfs-server
  39. tags: nfs_server
  40. - name: Creating NFS share directory
  41. file:
  42. path: "{{ nfs_share_dir }}"
  43. state: directory
  44. mode: "{{ nfs_share_dir_mode }}"
  45. tags: nfs_server
  46. - name: Adding NFS share entries in /etc/exports
  47. lineinfile:
  48. path: "{{ exports_file_path }}"
  49. line: "{{ nfs_share_dir }} {{ item }}(rw,sync,no_root_squash)"
  50. with_items:
  51. - "{{ groups['compute'] }}"
  52. tags: nfs_server
  53. - name: Exporting the shared directories
  54. command: exportfs -r
  55. changed_when: true
  56. tags: nfs_server
  57. - name: Configuring firewall
  58. firewalld:
  59. service: "{{ item }}"
  60. permanent: true
  61. state: enabled
  62. with_items:
  63. - "{{ nfs_services }}"
  64. tags: nfs_server
  65. - name: Reload firewalld
  66. command: firewall-cmd --reload
  67. changed_when: true
  68. tags: nfs_server
  69. - name: Stop and disable firewalld
  70. service:
  71. name: firewalld
  72. state: stopped
  73. enabled: no
  74. tags: firewalld