nfs_server_setup.yml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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.path }} {{ item.ip }}(rw,sync,no_root_squash)"
  48. with_items:
  49. - { path: "{{ nfs_share_offline_repo }}", ip: "{{ mngmnt_network_ip }}" }
  50. - { path: "{{ nfs_share_offline_repo }}", ip: "{{ public_ip }}" }
  51. - { path: "{{ nfs_share_awx }}", ip: "{{ mngmnt_network_ip }}" }
  52. - { path: "{{ nfs_share_awx }}", ip: "{{ public_ip }}" }
  53. - { path: "{{ nfs_share_offline_repo }}", ip: "{{ mngmnt_network_subnet }}/{{ mngmnt_network_netmask }}" }
  54. - name: Exporting the shared directories
  55. command: exportfs -r
  56. changed_when: true
  57. - name: Configuring firewall
  58. firewalld:
  59. service: "{{ item }}"
  60. permanent: true
  61. state: enabled
  62. with_items:
  63. - "{{ nfs_services }}"
  64. - name: Reload firewalld
  65. command: firewall-cmd --reload
  66. changed_when: true
  67. - name: Stop and disable firewalld
  68. service:
  69. name: firewalld
  70. state: stopped
  71. enabled: no