Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

58 lines
1.8 KiB

  1. # SPDX-FileCopyrightText: 2020 - 2022 Slavi Pantaleev
  2. # SPDX-FileCopyrightText: 2022 Marko Weltzer
  3. #
  4. # SPDX-License-Identifier: AGPL-3.0-or-later
  5. ---
  6. - name: Fail if playbook called incorrectly
  7. ansible.builtin.fail:
  8. msg: "The `one_time` variable needs to be provided to this playbook, via --extra-vars"
  9. when: "one_time is not defined or one_time not in ['yes', 'no']"
  10. - name: Fail if playbook called incorrectly
  11. ansible.builtin.fail:
  12. msg: "The `ex_date` variable (expiration date) needs to be provided to this playbook, via --extra-vars"
  13. when: "ex_date is not defined or ex_date == '<date>'"
  14. - name: Call matrix-registration token creation API
  15. ansible.builtin.uri:
  16. url: "{{ matrix_registration_api_token_endpoint }}"
  17. follow_redirects: none
  18. validate_certs: "{{ matrix_registration_api_validate_certs }}"
  19. headers:
  20. Content-Type: application/json
  21. Authorization: "SharedSecret {{ matrix_registration_admin_secret }}"
  22. method: POST
  23. body_format: json
  24. body: |
  25. {
  26. "one_time": {{ 'true' if one_time == 'yes' else 'false' }},
  27. "ex_date": {{ ex_date | to_json }}
  28. }
  29. check_mode: false
  30. register: matrix_registration_api_result
  31. - ansible.builtin.set_fact:
  32. matrix_registration_api_result_message: >-
  33. matrix-registration result:
  34. Direct registration link (with the token prefilled):
  35. {{ matrix_registration_api_register_endpoint }}?token={{ matrix_registration_api_result.json.name }}
  36. Full token details are:
  37. {{ matrix_registration_api_result.json }}
  38. check_mode: false
  39. - name: Inject result message into devture_playbook_runtime_messages_list
  40. ansible.builtin.set_fact:
  41. devture_playbook_runtime_messages_list: |
  42. {{
  43. devture_playbook_runtime_messages_list | default([])
  44. +
  45. [matrix_registration_api_result_message]
  46. }}
  47. check_mode: false