86 lines
3.2 KiB
YAML
86 lines
3.2 KiB
YAML
---
|
|
|
|
# Terraform Vultr provider doesn't have a VFS resource/datasource yet.
|
|
# This is a workaround for that missing feature.
|
|
#
|
|
# @see https://github.com/vultr/terraform-provider-vultr/issues/560
|
|
- name: Get the VFS id
|
|
ansible.builtin.uri:
|
|
url: https://api.vultr.com/v2/vfs
|
|
method: GET
|
|
status_code: 200
|
|
headers:
|
|
Authorization: "Bearer {{ lookup('dotenv', 'VULTR_API_KEY', file='../.env') }}"
|
|
register: vfs_list
|
|
|
|
- name: Get VFS variables
|
|
ansible.builtin.set_fact:
|
|
bright_vfs_id: "{{ vfs_list.json.vfs | selectattr('label', 'equalto', 'bright') | map(attribute='id') | first }}"
|
|
|
|
- name: Debug the bright VFS id
|
|
ansible.builtin.debug:
|
|
msg: "The VFS ID for 'bright' is {{ bright_vfs_id }}"
|
|
|
|
- name: Attach VFS to Vultr instance
|
|
ansible.builtin.uri:
|
|
url: https://api.vultr.com/v2/vfs/{{ bright_vfs_id }}/attachments/{{ hostvars[inventory_hostname]['vultr_instance_id'] }}
|
|
method: PUT
|
|
status_code:
|
|
- 200
|
|
- 201
|
|
- 409
|
|
headers:
|
|
Authorization: "Bearer {{ lookup('dotenv', 'VULTR_API_KEY', file='../.env') }}"
|
|
register: vfs_attach
|
|
changed_when:
|
|
- vfs_attach.json is defined
|
|
- "'state' in vfs_attach.json"
|
|
- vfs_attach.json.state == "ATTACHED"
|
|
notify:
|
|
- Mount vfs
|
|
- Restart bright
|
|
|
|
- name: Debug vfs_attach
|
|
ansible.builtin.debug:
|
|
var: vfs_attach
|
|
|
|
- name: Get the VFS mount_tag
|
|
ansible.builtin.set_fact:
|
|
vfs_mount_tag: "{{ vfs_attach.json.mount_tag | default('') }}"
|
|
|
|
|
|
- name: Setup docker container
|
|
community.docker.docker_container:
|
|
name: bright
|
|
image: gitea.futureporn.net/futureporn/bright:latest
|
|
pull: always
|
|
state: started
|
|
ports:
|
|
- "4000:4000"
|
|
volumes:
|
|
- "/mnt/vfs/futureporn:/mnt/vfs/futureporn"
|
|
env:
|
|
DB_HOST: "{{ hostvars['fp-db-0']['internal_ip'] }}"
|
|
DB_USER: "{{ lookup('dotenv', 'DB_USER', file='../.env') }}"
|
|
DB_NAME: "bright"
|
|
DB_PORT: "5432"
|
|
DB_PASS: "{{ lookup('dotenv', 'DB_PASS', file='../.env') }}"
|
|
MIX_ENV: prod
|
|
PUBLIC_S3_ENDPOINT: https://futureporn-b2.b-cdn.net
|
|
PATREON_REDIRECT_URI: https://bright.futureporn.net/auth/patreon/callback
|
|
SITE_URL: https://bright.futureporn.net
|
|
PHX_HOST: bright.futureporn.net
|
|
AWS_BUCKET: futureporn
|
|
AWS_REGION: us-west-000
|
|
AWS_HOST: s3.us-west-000.backblazeb2.com
|
|
SECRET_KEY_BASE: "{{ lookup('dotenv', 'SECRET_KEY_BASE', file='../.env') }}"
|
|
PATREON_CLIENT_SECRET: "{{ lookup('dotenv', 'PATREON_CLIENT_SECRET', file='../.env') }}"
|
|
PATREON_CLIENT_ID: "{{ lookup('dotenv', 'PATREON_CLIENT_ID', file='../.env') }}"
|
|
AWS_ACCESS_KEY_ID: "{{ lookup('dotenv', 'AWS_ACCESS_KEY_ID', file='../.env') }}"
|
|
AWS_SECRET_ACCESS_KEY: "{{ lookup('dotenv', 'AWS_SECRET_ACCESS_KEY', file='../.env') }}"
|
|
TRACKER_HELPER_ACCESSLIST_URL: https://tracker.futureporn.net/accesslist
|
|
TRACKER_HELPER_USERNAME: "{{ lookup('dotenv', 'TRACKER_HELPER_USERNAME', file='../.env') }}"
|
|
TRACKER_HELPER_PASSWORD: "{{ lookup('dotenv', 'TRACKER_HELPER_PASSWORD', file='../.env') }}"
|
|
TRACKER_URL: https://tracker.futureporn.net:6969
|
|
CACHE_DIR: /mnt/vfs/futureporn # we use Vultr File System to share cache among all Phoenix instances
|