ansible-role-mastodon/tasks/docker/docker.yml

88 lines
2.6 KiB
YAML
Raw Normal View History

2022-11-19 16:31:16 +01:00
---
2022-11-19 17:30:33 +01:00
- name: Clone Mastodon repo
git:
repo: https://github.com/mastodon/mastodon.git
2022-11-19 18:00:40 +01:00
dest: "{{ mastodon_composer_folder }}"
2022-11-19 17:30:33 +01:00
depth: 1
- name: Copy Dockerfile from Mastodon repo
copy:
2022-11-19 17:56:21 +01:00
src: files/Dockerfile
2022-11-19 17:30:33 +01:00
dest: "{{ mastodon_composer_folder }}/Dockerfile"
2022-11-19 17:24:45 +01:00
- name: Ensure mastodon folder exists
file:
path: "{{ mastodon_composer_folder }}"
state: directory
- name: Create docker-compose.yaml file
copy:
src: files/docker-compose.yml
dest: "{{ mastodon_composer_folder }}/docker-compose.yml"
2022-11-19 16:31:16 +01:00
2022-11-19 16:47:52 +01:00
- name: Ensure mastodon configuration is present
template:
src: templates/env.j2
2022-11-19 17:24:45 +01:00
dest: "{{ mastodon_composer_folder }}/.env.production"
2022-11-19 16:47:52 +01:00
2022-11-19 19:06:51 +01:00
- name: Build Mastodon container
2022-11-19 16:31:16 +01:00
community.docker.docker_compose:
project_name: mastodon
2022-11-19 17:24:45 +01:00
project_src: "{{ mastodon_composer_folder }}/"
2022-11-19 16:31:16 +01:00
state: present
2022-11-19 19:06:51 +01:00
- name: Generate secret key
shell: docker-compose run --rm web bundle exec rake secret
register: secret_key_cmd
when: mastodon_secret_key_base == ''
- name: Add secret key to Mastodon config
lineinfile:
path: "{{ mastodon_composer_folder }}/.env.production"
line: "SECRET_KEY_BASE={{ secret_key_cmd.stdout }}"
regexp: "^SECRET_KEY_BASE="
backup: yes
- name: Generate OTP secret key
shell: docker-compose run --rm web bundle exec rake secret
register: otp_key_cmd
when: mastodon_otp_secret == ''
- name: Add OTP key to Mastodon config
lineinfile:
path: "{{ mastodon_composer_folder }}/.env.production"
line: "OTP_SECRET={{ otp_key_cmd.stdout }}"
regexp: "^OTP_SECRET="
backup: yes
- name: Generate Paperclip secret key
shell: docker-compose run --rm web bundle exec rake secret
register: paperclip_key_cmd
when: mastodon_paperclip_secret == ''
- name: Add Paperclip key to Mastodon config
lineinfile:
path: "{{ mastodon_composer_folder }}/.env.production"
line: "PAPERCLIP_SECRET={{ paperclip_key_cmd.stdout }}"
regexp: "^PAPERCLIP_SECRET="
backup: yes
- name: Generate VAPID keypair
shell: docker-compose run --rm web bundle exec rake mastodon:webpush:generate_vapid_key
register: vapid_key_cmd
when: vapid_public_key == ''
- name: Add Paperclip private key to Mastodon config
lineinfile:
path: "{{ mastodon_composer_folder }}/.env.production"
line: "{{ vapid_key_cmd.stdout_lines[0] }}"
regexp: "^VAPID_PRIVATE_KEY="
backup: yes
- name: Add Paperclip public key to Mastodon config
lineinfile:
path: "{{ mastodon_composer_folder }}/.env.production"
line: "{{ vapid_key_cmd.stdout_lines[1] }}"
regexp: "^VAPID_PUBLIC_KEY="
backup: yes