Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Externalize pict-rs configuration, start centralizing configuration variables #160

Merged
merged 15 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ To run this ansible playbook, you need to:

You can use [the PGTune tool](https://pgtune.leopard.in.ua) to tune your postgres to meet your server memory and CPU.

6. Run the playbook:
6. Copy the sample `vars.yml` file

`cp examples/vars.yml inventory/host_vars/<your-domain>/vars.yml`

Edit the `inventory/host_vars/<your-domain>/vars.yml` file to your liking.

7. Run the playbook:

`ansible-playbook -i inventory/hosts lemmy.yml`

Expand Down
3 changes: 2 additions & 1 deletion examples/hosts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[lemmy]
# to get started, copy this file to `inventory` and adjust the values below.
# - `myuser@example.com`: replace with the destination you use to connect to your server via ssh
# - `ansible_user=root`: replace `root` with your the username you use to connect to your ssh server
# - `domain=example.com`: replace `example.com` with your lemmy domain
# - `letsencrypt_contact_email=your@email.com` replace `your@email.com` with your email address,
# to get notifications if your ssl cert expires
# - `lemmy_base_dir=/srv/lemmy`: the location on the server where lemmy can be installed, can be any folder
# if you are upgrading from a previous version, set this to `/lemmy`
# - `lemmy_version`: <Optional> The back end version.
# - `lemmy_ui_version`: <Optional> overrides the front end version.
myuser@example.com domain=example.com letsencrypt_contact_email=your@email.com lemmy_base_dir=/srv/lemmy
example.com ansible_user=root domain=example.com letsencrypt_contact_email=your@email.com lemmy_base_dir=/srv/lemmy
codyro marked this conversation as resolved.
Show resolved Hide resolved

[all:vars]
ansible_connection=ssh
25 changes: 25 additions & 0 deletions examples/vars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
postgres_password: "{{ lookup('password', 'inventory/host_vars/{{domain}}/passwords/postgres.psk chars=ascii_letters,digits') }}"

# You can set any pict-rs environmental variables here. They will populate the templates/docker-compose.yml file.
# https://git.asonix.dog/asonix/pict-rs
pictrs_env_vars:
- PICTRS__SERVER__API_KEY: "{{ postgres_password }}"
- PICTRS__MEDIA__VIDEO_CODEC: vp9
- PICTRS__MEDIA__GIF__MAX_WIDTH: 256
- PICTRS__MEDIA__GIF__MAX_HEIGHT: 256
- PICTRS__MEDIA__GIF__MAX_AREA: 65536
- PICTRS__MEDIA__GIF__MAX_FRAME_COUNT: 400
- PICTRS_OPENTELEMETRY_URL: http://otel:4137
- RUST_LOG: debug
- RUST_BACKTRACE: full
codyro marked this conversation as resolved.
Show resolved Hide resolved
# - PICTRS__STORE__TYPE: object_storage
codyro marked this conversation as resolved.
Show resolved Hide resolved
# - PICTRS__STORE__ENDPOINT: '<S3 endpoint>'
# - PICTRS__STORE__BUCKET_NAME: '<bucket name>'
# - PICTRS__STORE__REGION: '<region>'
# - PICTRS__STORE__USE_PATH_STYLE: false
# - PICTRS__STORE__ACCESS_KEY: '<access key>'
# - PICTRS__STORE__SECRET_KEY: '<secret key>'


codyro marked this conversation as resolved.
Show resolved Hide resolved


1 change: 0 additions & 1 deletion lemmy-almalinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
ansible.builtin.command: nginx -s reload
vars:
lemmy_port: "{{ 32767 | random(start=1024) }}"
postgres_password: "{{ lookup('password', 'host_vars/{{ domain }}/passwords/postgres chars=ascii_letters,digits') }}"
tasks:
- name: Ensure target system is >= EL9
ansible.builtin.fail:
Expand Down
3 changes: 0 additions & 3 deletions lemmy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,6 @@
owner: "1000"
group: "1000"

vars:
codyro marked this conversation as resolved.
Show resolved Hide resolved
postgres_password: "{{ lookup('password', 'inventory/host_vars/{{domain}}/passwords/postgres chars=ascii_letters,digits') }}"

- name: enable and start docker service
systemd:
name: docker
Expand Down
16 changes: 7 additions & 9 deletions templates/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,13 @@ services:
# we can set options to pictrs like this, here we set max. image size and forced format for conversion
# entrypoint: /sbin/tini -- /usr/local/bin/pict-rs -p /mnt -m 4 --image-format webp
environment:
- PICTRS_OPENTELEMETRY_URL=http://otel:4137
- PICTRS__SERVER__API_KEY={{ postgres_password }}
- RUST_LOG=debug
- RUST_BACKTRACE=full
- PICTRS__MEDIA__VIDEO_CODEC=vp9
- PICTRS__MEDIA__GIF__MAX_WIDTH=256
- PICTRS__MEDIA__GIF__MAX_HEIGHT=256
- PICTRS__MEDIA__GIF__MAX_AREA=65536
- PICTRS__MEDIA__GIF__MAX_FRAME_COUNT=400
{% if pictrs_env_vars is defined and pictrs_env_vars|length > 0 %}
{%- for item in pictrs_env_vars %}
{%- for key, value in item.items() %}
- {{ key }}={{ value }}
{% endfor -%}
{% endfor %}
codyro marked this conversation as resolved.
Show resolved Hide resolved
{% endif %}
user: 991:991
volumes:
- ./volumes/pictrs:/mnt:Z
Expand Down