fetch_control_plane_credentials.yml 2.5 KB

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