updating playbook for 2nd vps
This commit is contained in:
@@ -9,10 +9,10 @@ all:
|
|||||||
#vps2:
|
#vps2:
|
||||||
# ansible_host: 203.0.113.11
|
# ansible_host: 203.0.113.11
|
||||||
|
|
||||||
dbservers:
|
archivewarrior:
|
||||||
hosts:
|
hosts:
|
||||||
#vps3:
|
chi2:
|
||||||
# ansible_host: 203.0.113.12
|
ansible_host: 107.175.70.69
|
||||||
|
|
||||||
authelia:
|
authelia:
|
||||||
hosts:
|
hosts:
|
||||||
|
|||||||
13
roles/archivewarrior/defaults/main.yml
Normal file
13
roles/archivewarrior/defaults/main.yml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# User config
|
||||||
|
archive_user: jester45
|
||||||
|
archive_uid: 1024
|
||||||
|
archive_gid: 1024
|
||||||
|
|
||||||
|
# Path Configurations
|
||||||
|
base_app_dir: "/app/archivewarrior"
|
||||||
|
docker_dir: "/app/docker/archivewarrior"
|
||||||
|
data_dir: "/app/data/archivewarrior"
|
||||||
|
|
||||||
|
# Container Configuration
|
||||||
|
container_name: "archivewarrior"
|
||||||
|
image_version: "latest"
|
||||||
78
roles/archivewarrior/tasks/main.yml
Normal file
78
roles/archivewarrior/tasks/main.yml
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Remove nginx, avoids port 80 conflict
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: nginx
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Remove nginx service, avoids port 80 conflict
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: nginx
|
||||||
|
state: stopped
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
- name: Create authelia directories
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: directory
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0750"
|
||||||
|
loop:
|
||||||
|
- "{{ authelia_base_dir }}"
|
||||||
|
- "{{ authelia_config_dir }}"
|
||||||
|
- "{{ authelia_data_dir }}"
|
||||||
|
|
||||||
|
- name: Check if Caddyfile path is wrongly a directory
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: "{{ authelia_base_dir }}/Caddyfile"
|
||||||
|
register: caddyfile_stat
|
||||||
|
|
||||||
|
- name: Remove Caddyfile if it was created as a directory
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ authelia_base_dir }}/Caddyfile"
|
||||||
|
state: absent
|
||||||
|
when: caddyfile_stat.stat.exists and caddyfile_stat.stat.isdir
|
||||||
|
|
||||||
|
- name: Deploy Caddyfile
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: Caddyfile.j2
|
||||||
|
dest: "{{ authelia_base_dir }}/Caddyfile"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0640"
|
||||||
|
notify: restart authelia
|
||||||
|
|
||||||
|
- name: Deploy configuration.yml
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: configuration.yml.j2
|
||||||
|
dest: "{{ authelia_config_dir }}/configuration.yml"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0640"
|
||||||
|
notify: restart authelia
|
||||||
|
|
||||||
|
- name: Deploy users_database.yml
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: users_database.yml.j2
|
||||||
|
dest: "{{ authelia_config_dir }}/users_database.yml"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0640"
|
||||||
|
notify: restart authelia
|
||||||
|
when: authelia_users is defined
|
||||||
|
|
||||||
|
- name: Deploy docker-compose.yml
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: docker-compose.yml.j2
|
||||||
|
dest: "{{ authelia_base_dir }}/docker-compose.yml"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0640"
|
||||||
|
register: compose_file
|
||||||
|
|
||||||
|
- name: Pull and start authelia via docker compose
|
||||||
|
community.docker.docker_compose_v2:
|
||||||
|
project_src: "{{ authelia_base_dir }}"
|
||||||
|
state: present
|
||||||
|
pull: missing
|
||||||
98
roles/archivewarrior/templates/docker-compose.yml.j2
Normal file
98
roles/archivewarrior/templates/docker-compose.yml.j2
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
---
|
||||||
|
- name: Deploy ArchiveWarrior Docker Container
|
||||||
|
hosts: all
|
||||||
|
become: true
|
||||||
|
vars:
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
# ----------------------------------------------------
|
||||||
|
# 1. PREREQUISITES & DOCKER INSTALLATION
|
||||||
|
# ----------------------------------------------------
|
||||||
|
- name: Check if Docker is already installed
|
||||||
|
ansible.builtin.command: docker --version
|
||||||
|
register: docker_check
|
||||||
|
changed_when: false
|
||||||
|
failed_when: false
|
||||||
|
|
||||||
|
- name: Install Docker via convenience script if missing
|
||||||
|
ansible.builtin.shell: |
|
||||||
|
set -o pipefail
|
||||||
|
curl -fsSL https://docker.com | sh
|
||||||
|
args:
|
||||||
|
executable: /bin/bash
|
||||||
|
when: docker_check.rc != 0
|
||||||
|
changed_when: true
|
||||||
|
|
||||||
|
- name: Ensure Docker service is running and enabled
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: docker
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# ----------------------------------------------------
|
||||||
|
# 2. USER & DIRECTORY CONFIGURATION
|
||||||
|
# ----------------------------------------------------
|
||||||
|
- name: Create dedicated group for ArchiveWarrior
|
||||||
|
ansible.builtin.group:
|
||||||
|
name: "{{ archive_user }}"
|
||||||
|
gid: "{{ archive_gid }}"
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Create dedicated system user for ArchiveWarrior
|
||||||
|
ansible.builtin.user:
|
||||||
|
name: "{{ archive_user }}"
|
||||||
|
uid: "{{ archive_uid }}"
|
||||||
|
group: "{{ archive_user }}"
|
||||||
|
groups: docker
|
||||||
|
append: true
|
||||||
|
shell: /usr/sbin/nologin
|
||||||
|
system: true
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Create persistent storage and layout directories
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: directory
|
||||||
|
owner: "{{ archive_user }}"
|
||||||
|
group: "{{ archive_user }}"
|
||||||
|
mode: '0755'
|
||||||
|
loop:
|
||||||
|
- "{{ base_app_dir }}"
|
||||||
|
- "{{ docker_dir }}"
|
||||||
|
- "{{ data_dir }}"
|
||||||
|
|
||||||
|
# ----------------------------------------------------
|
||||||
|
# 3. DOCKER COMPOSE DEPLOYMENT
|
||||||
|
# ----------------------------------------------------
|
||||||
|
- name: Write docker-compose.yml configuration file
|
||||||
|
ansible.builtin.copy:
|
||||||
|
dest: "{{ docker_dir }}/docker-compose.yml"
|
||||||
|
owner: "{{ archive_user }}"
|
||||||
|
group: "{{ archive_user }}"
|
||||||
|
mode: '0640'
|
||||||
|
content: |
|
||||||
|
version: '3.8'
|
||||||
|
services:
|
||||||
|
archivewarrior:
|
||||||
|
image: atdr.meo.ws/archiveteam/archivewarrior:${image_version}
|
||||||
|
container_name: ${container_name}
|
||||||
|
restart: unless-stopped
|
||||||
|
user: "${archive_uid}:${archive_gid}"
|
||||||
|
logging:
|
||||||
|
driver: "json-file"
|
||||||
|
options:
|
||||||
|
max-size: "10m"
|
||||||
|
max-file: "3"
|
||||||
|
volumes:
|
||||||
|
- ${data_dir}:/home/warrior/data
|
||||||
|
environment:
|
||||||
|
- DOWNLOADER=YourNameOrNickname
|
||||||
|
- SELECTED_PROJECT=auto
|
||||||
|
- CONCURRENT_ITEMS=6
|
||||||
|
|
||||||
|
- name: Pull and start ArchiveWarrior Docker container
|
||||||
|
# Using community.docker.docker_compose_v2 to handle stack management safely
|
||||||
|
community.docker.docker_compose_v2:
|
||||||
|
project_src: "{{ docker_dir }}"
|
||||||
|
state: present
|
||||||
|
pull: always
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Install postgresql
|
|
||||||
ansible.builtin.apt:
|
|
||||||
name:
|
|
||||||
- "postgresql-{{ postgres_version }}"
|
|
||||||
- python3-psycopg2
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: Ensure postgresql is running and enabled
|
|
||||||
ansible.builtin.service:
|
|
||||||
name: postgresql
|
|
||||||
state: started
|
|
||||||
enabled: true
|
|
||||||
|
|
||||||
# - name: Create databases
|
|
||||||
# become_user: postgres
|
|
||||||
# community.postgresql.postgresql_db:
|
|
||||||
# name: "{{ item.name }}"
|
|
||||||
# loop: "{{ postgres_databases }}"
|
|
||||||
|
|
||||||
# - name: Create users
|
|
||||||
# become_user: postgres
|
|
||||||
# community.postgresql.postgresql_user:
|
|
||||||
# name: "{{ item.name }}"
|
|
||||||
# password: "{{ item.password }}"
|
|
||||||
# loop: "{{ postgres_users }}"
|
|
||||||
# no_log: true
|
|
||||||
7
site.yml
7
site.yml
@@ -20,11 +20,12 @@
|
|||||||
- docker
|
- docker
|
||||||
- nginx
|
- nginx
|
||||||
|
|
||||||
- name: Database servers
|
- name: archivewarrior servers
|
||||||
hosts: dbservers
|
hosts: archivewarrior
|
||||||
become: true
|
become: true
|
||||||
roles:
|
roles:
|
||||||
- postgres
|
- docker
|
||||||
|
- archivewarrior
|
||||||
|
|
||||||
- name: authelia servers
|
- name: authelia servers
|
||||||
hosts: authelia
|
hosts: authelia
|
||||||
|
|||||||
Reference in New Issue
Block a user