nfs_server_setup.yml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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: Creating NFS share directory
  16. file:
  17. path: "{{ item }}"
  18. state: directory
  19. mode: "{{ nfs_share_dir_mode }}"
  20. with_items:
  21. - "{{ nfs_share_offline_repo }}"
  22. - "{{ nfs_share_awx }}"
  23. - name: Install nfs-utils
  24. package:
  25. name: nfs-utils
  26. state: present
  27. - name: Install firewalld
  28. package:
  29. name: firewalld
  30. state: present
  31. - name: Start and enable firewalld
  32. service:
  33. name: firewalld
  34. state: started
  35. enabled: yes
  36. - name: Start and enable rpcbind and nfs-server service
  37. service:
  38. name: "{{ item }}"
  39. state: restarted
  40. enabled: yes
  41. with_items:
  42. - rpcbind
  43. - nfs-server
  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 idrac_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