Make sure we can copy files correctly to destination

This commit is contained in:
gabriel becker 2025-08-16 19:26:14 +10:00
parent b5af3c9b5d
commit a9623b63f1
4 changed files with 40 additions and 18 deletions

View File

@ -4,5 +4,5 @@ packages:
- rsync
- wget
base_services:
- portainer
- managers
services_configs_dir: ""

View File

@ -1,16 +1,18 @@
file-servers:
file-server:
hosts:
debianpx:
ansible_host: 192.168.122.177
ansible_user: gabriel
ansible_become: yes
ansible_become_method: sudo
vars:
services_dir: /home/gabriel/hosted
services_configs_dir: /home/gabriel/hosted/configs
PERSISTENT_DIRECTORY: /home/gabriel/hosted/persistent
VOLATILE_DIRECTORY: /home/gabriel/hosted/volatile
BACKUPDIR: /home/gabriel/hosted/backup
APPSDIR: /home/gabriel/hosted/apps
MEDIADIR: /home/gabriel/hosted/media
source_services_dir: /home/gabriel/hosted
server_services_dir: /home/srv/services/configs
PERSISTENT_DIRECTORY: /home/srv/services/persistent
# VOLATILE_DIRECTORY: /home/gabriel/hosted/volatile
# BACKUPDIR: /home/gabriel/hosted/backup
# APPSDIR: /home/gabriel/hosted/apps
# MEDIADIR: /home/gabriel/hosted/media
media-servers:
hosts:

View File

@ -1,12 +1,32 @@
---
- name: Ensure services destination directory exists
ansible.builtin.file:
path: "{{ server_services_dir }}"
state: directory
mode: '0755'
owner: "{{ ansible_user | default('root') }}"
group: "{{ ansible_user | default('root') }}"
- name: Copy service folder
ansible.posix.synchronize:
src: "{{ services_dir }}/{{ item }}"
dest: /services/
ansible.builtin.copy:
src: "{{ source_services_dir }}/{{ item }}"
dest: "{{ server_services_dir }}"
mode: '0755'
owner: "{{ ansible_user | default('root') }}"
group: "{{ ansible_user | default('root') }}"
with_items: "{{ services }}"
- name: Start Docker compose
community.docker.docker_compose:
project_src: "/services/{{ item }}"
environment: "{{ compose_env }}"
- name: Docker Compose Start Service
community.docker.docker_compose_v2:
project_src: "{{ server_services_dir }}/{{ item }}"
# environment: "{{ compose_env }}"
check_files_existing: true
assume_yes: true
build: policy
wait: true
register: output
with_items: "{{ services }}"
async: 300
poll: 10

View File

@ -6,12 +6,12 @@
# vars_files:
# - secret
- hosts: file-servers
- hosts: file-server
become: true
roles:
- role: webserver
- hosts: media-servers
- hosts: media-server
become: true
roles:
- role: webserver