diff --git a/group_vars/all.yml b/group_vars/all.yml index 7821854..3cdedde 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -4,5 +4,5 @@ packages: - rsync - wget base_services: - - portainer + - managers services_configs_dir: "" \ No newline at end of file diff --git a/inventory.yml b/inventory.yml index c7f5cb3..60f7393 100644 --- a/inventory.yml +++ b/inventory.yml @@ -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: diff --git a/roles/webserver/tasks/start_service.yml b/roles/webserver/tasks/start_service.yml index ba88541..62da8e1 100644 --- a/roles/webserver/tasks/start_service.yml +++ b/roles/webserver/tasks/start_service.yml @@ -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 + + diff --git a/run.yml b/run.yml index 9e61df7..d547f63 100644 --- a/run.yml +++ b/run.yml @@ -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