add_nfs_client.yml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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: Add nfs client entries
  16. hosts: localhost
  17. connection: local
  18. gather_facts: false
  19. tasks:
  20. - name: Include control_plane_repo vars
  21. include_vars: ../../control_plane_repo/vars/main.yml
  22. - name: Check if idrac inventory file exists
  23. stat:
  24. path: "../../collect_device_info/files/idrac_inventory"
  25. register: provisioned_file_result
  26. - name: Check {{ exports_file_path }}
  27. command: cat {{ exports_file_path }}
  28. register: exports_file_check
  29. changed_when: false
  30. when: provisioned_file_result.stat.exists
  31. - name: Adding NFS share entries in {{ exports_file_path }}
  32. lineinfile:
  33. path: "{{ exports_file_path }}"
  34. line: "{{ nfs_share_offline_repo }} {{ item }}(rw,sync,no_root_squash)"
  35. when:
  36. - provisioned_file_result.stat.exists
  37. - item not in exports_file_check.stdout
  38. loop: "{{ lookup('file', '../../collect_device_info/files/idrac_inventory').splitlines() }}"
  39. - name: Exporting the shared directories
  40. command: /usr/sbin/exportfs -r
  41. changed_when: true
  42. when: provisioned_file_result.stat.exists
  43. - name: Copy exports file to custom_iso role
  44. copy:
  45. src: "{{ exports_file_path }}"
  46. dest: "{{ playbook_dir }}/exports"
  47. mode: preserve
  48. when: provisioned_file_result.stat.exists