nfs_server_setup.yml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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: Creating NFS share directory
  37. file:
  38. path: "{{ item }}"
  39. state: directory
  40. mode: "{{ nfs_share_dir_mode }}"
  41. with_items:
  42. - "{{ nfs_share_offline_repo }}"
  43. - "{{ nfs_share_awx }}"
  44. - name: Adding NFS share entries in /etc/exports
  45. lineinfile:
  46. path: "{{ exports_file_path }}"
  47. line: "{{ item }} {{ ansible_default_ipv4.address }}(rw,sync,no_root_squash)"
  48. with_items:
  49. - "{{ nfs_share_offline_repo }}"
  50. - "{{ nfs_share_awx }}"
  51. - name: Exporting the shared directories
  52. command: exportfs -r
  53. changed_when: true
  54. - name: Configuring firewall
  55. firewalld:
  56. service: "{{ item }}"
  57. permanent: true
  58. state: enabled
  59. with_items:
  60. - "{{ nfs_services }}"
  61. - name: Reload firewalld
  62. command: firewall-cmd --reload
  63. changed_when: true
  64. - name: Stop and disable firewalld
  65. service:
  66. name: firewalld
  67. state: stopped
  68. enabled: no