add mastodon

This commit is contained in:
ace
2021-02-10 02:28:01 +03:00
parent 5c1eafeeec
commit 49249dcd6a
17 changed files with 328 additions and 9 deletions

View File

@ -55,3 +55,6 @@
- include_tasks: tsig.yaml
- include_tasks: dkim.yaml
- include_tasks: vapid.yaml
loop: "{{ vapid_keys }}"

View File

@ -0,0 +1,47 @@
- name: Test if VAPID private key exists
shell: grep -c "^{{ item.name }}_vapid_private_key_base64" "{{ inventory_dir }}/group_vars/all/passwords.yaml" || true
register: vapid_private_key_test_grep
- name: Test if VAPID public key exists
shell: grep -c "^{{ item.name }}_vapid_public_key_base64" "{{ inventory_dir }}/group_vars/all/passwords.yaml" || true
register: vapid_public_key_test_grep
- name: Create VAPID keys
docker_container:
name: vapid
image: "{{ docker_registry }}/pwgen"
cleanup: true
detach: false
container_default_behavior: no_defaults
command: "/vapid"
register: vapid_container_output
when: vapid_private_key_test_grep.stdout == '0' or vapid_public_key_test_grep.stdout == '0'
- name: Set VAPID keys fact
set_fact:
vapid_keys: "{{ vapid_container_output.ansible_facts.docker_container.Output | from_yaml }}"
when: vapid_private_key_test_grep.stdout == '0' or vapid_public_key_test_grep.stdout == '0'
- name: Show VAPID private key
debug:
msg: "vapid private key: {{ vapid_keys['vapidPrivateKey'] }}"
verbosity: 2
when: vapid_private_key_test_grep.stdout == '0'
- name: Show VAPID public key
debug:
msg: "vapid public key: {{ vapid_keys['vapidPublicKey'] }}"
verbosity: 2
when: vapid_public_key_test_grep.stdout == '0'
- name: Write VAPID private key
lineinfile:
path: "{{ inventory_dir }}/group_vars/all/passwords.yaml"
line: "{{ item.name }}_vapid_private_key_base64: \"{{ vapid_keys['vapidPrivateKey'] | b64encode }}\""
when: vapid_private_key_test_grep.stdout == '0'
- name: Write VAPID public key
lineinfile:
path: "{{ inventory_dir }}/group_vars/all/passwords.yaml"
line: "{{ item.name }}_vapid_public_key_base64: \"{{ vapid_keys['vapidPublicKey'] | b64encode }}\""
when: vapid_public_key_test_grep.stdout == '0'