fetch_ipa_password.yml 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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: Include base_vars of control plane
  16. include_vars: "{{ role_path }}/../../control_plane/input_params/base_vars.yml"
  17. - name: Unset ipa server status on MS
  18. set_fact:
  19. ipa_server_ms: false
  20. - name: Check if ipa server file of MS exists
  21. stat:
  22. path: "{{ ipa_secret_file }}"
  23. register: ms_file_exists
  24. - name: Check if ipa server is installed on MS
  25. block:
  26. - name: Check login_vars file is encrypted
  27. command: cat "{{ role_path }}/../../control_plane/{{ login_vars_filename }}"
  28. changed_when: false
  29. register: config_content
  30. no_log: true
  31. - name: Decrpyt login_vars.yml
  32. command: >-
  33. ansible-vault decrypt "{{ role_path }}/../../control_plane/{{ login_vars_filename }}"
  34. --vault-password-file "{{ role_path }}/../../control_plane/{{ vault_filename }}"
  35. changed_when: false
  36. when: "'$ANSIBLE_VAULT;' in config_content.stdout"
  37. - name: Include variable file login_vars.yml
  38. include_vars: "{{ role_path }}/../../control_plane/{{ login_vars_filename }}"
  39. no_log: true
  40. - name: Save variables of ipa server from Management Station
  41. set_fact:
  42. ms_ipa_admin_password: '{{ ipa_admin_password }}'
  43. - name: Create ansible vault key
  44. set_fact:
  45. vault_key: "{{ lookup('password', '/dev/null chars=ascii_letters') }}"
  46. when: "'$ANSIBLE_VAULT;' not in config_content.stdout"
  47. - name: Save vault key
  48. copy:
  49. dest: "{{ role_path }}/../../control_plane/{{ vault_filename }}"
  50. content: |
  51. {{ vault_key }}
  52. owner: root
  53. force: yes
  54. mode: "{{ vault_file_perm }}"
  55. when: "'$ANSIBLE_VAULT;' not in config_content.stdout"
  56. - name: Encrypt input config file
  57. command: >-
  58. ansible-vault encrypt "{{ role_path }}/../../control_plane/{{ login_vars_filename }}"
  59. --vault-password-file "{{ role_path }}/../../control_plane/{{ vault_filename }}"
  60. changed_when: false
  61. - name: Update login_vars.yml permission
  62. file:
  63. path: "{{ role_path }}/../../control_plane/{{ login_vars_filename }}"
  64. mode: "{{ vault_file_perm }}"
  65. - name: Include ipa server hostname and domain name
  66. include_vars: "{{ ipa_secret_file }}"
  67. - name: Set ipa server status on MS
  68. set_fact:
  69. ipa_server_ms: true
  70. when:
  71. - enable_security_support
  72. - ms_file_exists.stat.exists