2022-02-05 21:32:54 +01:00
|
|
|
---
|
2021-10-19 11:45:15 +02:00
|
|
|
|
|
|
|
- name: Record Bridge Discord AppService variables locally on AWX
|
|
|
|
delegate_to: 127.0.0.1
|
|
|
|
lineinfile:
|
|
|
|
path: '{{ awx_cached_matrix_vars }}'
|
|
|
|
regexp: "^#? *{{ item.key | regex_escape() }}:"
|
|
|
|
line: "{{ item.key }}: {{ item.value }}"
|
|
|
|
insertafter: '# Bridge Discord AppService Start'
|
|
|
|
with_dict:
|
|
|
|
'matrix_appservice_discord_enabled': '{{ matrix_appservice_discord_enabled }}'
|
|
|
|
'matrix_appservice_discord_client_id': '{{ matrix_appservice_discord_client_id }}'
|
|
|
|
'matrix_appservice_discord_bot_token': '{{ matrix_appservice_discord_bot_token }}'
|
|
|
|
|
|
|
|
- name: If the raw inputs is not empty start constructing parsed awx_appservice_discord_admin_rooms list
|
|
|
|
set_fact:
|
|
|
|
awx_appservice_discord_admin_rooms_array: |-
|
|
|
|
{{ awx_appservice_discord_admin_rooms.splitlines() | to_json }}
|
|
|
|
when: awx_appservice_discord_admin_rooms | trim | length > 0
|
|
|
|
|
|
|
|
- name: Promote user to administer (PL100) of each room
|
|
|
|
command: |
|
|
|
|
docker exec -i matrix-appservice-discord /bin/sh -c 'cp /cfg/registration.yaml /tmp/discord-registration.yaml && cd /tmp && node /build/tools/adminme.js -c /cfg/config.yaml -m "{{ item.1 }}" -u "@{{ awx_appservice_discord_admin_user }}:{{ matrix_domain }}" -p 100'
|
|
|
|
with_indexed_items:
|
|
|
|
- "{{ awx_appservice_discord_admin_rooms_array }}"
|
|
|
|
when: ( awx_appservice_discord_admin_rooms | trim | length > 0 ) and ( awx_appservice_discord_admin_user is defined )
|
|
|
|
|
|
|
|
- name: Save new 'Bridge Discord Appservice' survey.json to the AWX tower, template
|
|
|
|
delegate_to: 127.0.0.1
|
|
|
|
template:
|
|
|
|
src: 'roles/matrix-awx/surveys/bridge_discord_appservice.json.j2'
|
|
|
|
dest: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}//bridge_discord_appservice.json'
|
|
|
|
|
|
|
|
- name: Copy new 'Bridge Discord Appservice' survey.json to target machine
|
|
|
|
copy:
|
|
|
|
src: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/bridge_discord_appservice.json'
|
2022-02-05 21:32:54 +01:00
|
|
|
dest: '/matrix/awx/bridge_discord_appservice.json'
|
2021-10-19 11:45:15 +02:00
|
|
|
mode: '0660'
|
|
|
|
|
|
|
|
- name: Recreate 'Bridge Discord Appservice' job template
|
|
|
|
delegate_to: 127.0.0.1
|
|
|
|
awx.awx.tower_job_template:
|
|
|
|
name: "{{ matrix_domain }} - 3 - Bridge Discord AppService"
|
|
|
|
description: "Enables a private bridge you can use to connect Matrix rooms to Discord."
|
|
|
|
extra_vars: "{{ lookup('file', '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/extra_vars.json') }}"
|
|
|
|
job_type: run
|
|
|
|
job_tags: "start,setup-all,bridge-discord-appservice"
|
|
|
|
inventory: "{{ member_id }}"
|
|
|
|
project: "{{ member_id }} - Matrix Docker Ansible Deploy"
|
|
|
|
playbook: setup.yml
|
|
|
|
credential: "{{ member_id }} - AWX SSH Key"
|
|
|
|
survey_enabled: true
|
|
|
|
survey_spec: "{{ lookup('file', '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/bridge_discord_appservice.json') }}"
|
|
|
|
state: present
|
|
|
|
verbosity: 1
|
|
|
|
tower_host: "https://{{ awx_host }}"
|
|
|
|
tower_oauthtoken: "{{ awx_session_token.ansible_facts.tower_token.token }}"
|
2022-02-05 21:32:54 +01:00
|
|
|
validate_certs: true
|