nfs_server_setup.yml 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. # Copyright 2022 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: "{{ public_ip }}" }
  50. - { path: "{{ nfs_share_awx }}", ip: "{{ public_ip }}" }
  51. - name: Adding NFS share entries in /etc/exports when device_config_support
  52. lineinfile:
  53. path: "{{ exports_file_path }}"
  54. line: "{{ item.path }} {{ item.ip }}(rw,sync,no_root_squash)"
  55. with_items:
  56. - { path: "{{ nfs_share_offline_repo }}", ip: "{{ mngmnt_network_ip }}" }
  57. - { path: "{{ nfs_share_awx }}", ip: "{{ mngmnt_network_ip }}" }
  58. - { path: "{{ nfs_share_offline_repo }}", ip: "{{ mngmnt_network_subnet }}/{{ mngmnt_network_netmask }}" }
  59. when: device_config_support
  60. - name: Adding NFS share entries in /etc/exports when device_config_support
  61. lineinfile:
  62. path: "{{ exports_file_path }}"
  63. line: "{{ nfs_share_offline_repo }} {{ item }}(rw,sync,no_root_squash)"
  64. with_items: "{{ device_ip }}"
  65. when:
  66. - idrac_support
  67. - device_config_ip_file
  68. - name: Exporting the shared directories
  69. command: exportfs -r
  70. changed_when: true
  71. - name: Configuring firewall
  72. firewalld:
  73. service: "{{ item }}"
  74. permanent: true
  75. state: enabled
  76. with_items:
  77. - "{{ nfs_services }}"
  78. - name: Reload firewalld
  79. command: firewall-cmd --reload
  80. changed_when: true
  81. - name: Stop and disable firewalld
  82. service:
  83. name: firewalld
  84. state: stopped
  85. enabled: no