fetch_password.yml 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # Copyright 2020 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 if input config file is encrypted
  16. command: cat {{ role_path }}/../../appliance/{{ input_config_filename }}
  17. changed_when: false
  18. register: config_content
  19. no_log: True
  20. - name: Decrpyt input_config.yml
  21. command: >-
  22. ansible-vault decrypt {{ role_path }}/../../appliance/{{ input_config_filename }}
  23. --vault-password-file {{ role_path }}/../../appliance/roles/common/files/{{ vault_filename }}
  24. when: "'$ANSIBLE_VAULT;' in config_content.stdout"
  25. - name: Include variable file input_config.yml
  26. include_vars: "{{ role_path }}/../../appliance/{{ input_config_filename }}"
  27. no_log: True
  28. - name: Save input variables from file
  29. set_fact:
  30. cobbler_password: "{{ provision_password }}"
  31. db_password: "{{ mariadb_password }}"
  32. k8s_cni: "{{ k8s_cni }}"
  33. no_log: True
  34. - name: Encrypt input config file
  35. command: >-
  36. ansible-vault encrypt {{ role_path }}/../../appliance/{{ input_config_filename }}
  37. --vault-password-file {{ role_path }}/../../appliance/roles/common/files/{{ vault_filename }}
  38. when: "'$ANSIBLE_VAULT;' not in config_content.stdout"