only create files on hosts that need them

pull/29/head
Cian Hatton 3 years ago
parent cff95e0e44
commit 82cccc01d9

@ -3,21 +3,8 @@ backups:
monthly: monthly monthly: monthly
nightly: nightly nightly: nightly
# dashy related config
dashy:
source_file: dashboards/dashy-config.yml
config_file: dashy-config.yml
config_directory: /etc/config/dashy
# olivetin related config
olivetin:
source_file: olivetin/config.yml
config_file: config.yml
config_directory: /etc/config/OliveTin
homelab_user: cianhatton homelab_user: cianhatton
configure_mergerfs: false configure_mergerfs: false
configure_samba: false configure_samba: false
samba_group: smbgroup samba_group: smbgroup
@ -56,3 +43,4 @@ portainer_endpoint: -1
portainer_host: false portainer_host: false
portainer_base_url: "http://qnap:9000" portainer_base_url: "http://qnap:9000"
external_docker_networks: [] external_docker_networks: []
portainer_required_files: []

@ -34,8 +34,28 @@ external_docker_networks:
ansible_pull_path: /home/{{ homelab_user }}/.local/bin/ansible-pull ansible_pull_path: /home/{{ homelab_user }}/.local/bin/ansible-pull
portainer_endpoint: 2 dashy:
source_file: dashboards/dashy-config.yml
config_file: dashy-config.yml
config_directory: /etc/config/dashy
# olivetin related config
olivetin:
source_file: olivetin/config.yml
config_file: config.yml
config_directory: /etc/config/OliveTin
portainer_required_files:
- source_file: dashboards/dashy-config.yml
dest_file_name: dashy-config.yml
dest_directory: /etc/config/dashy
handler: restart-dashy
- source_file: olivetin/config.yml
dest_file_name: config.yml
dest_directory: /etc/config/OliveTin
handler: restart-olivetin
portainer_endpoint: 2
services: services:
- name: gitea - name: gitea
template_vars: template_vars:

@ -22,35 +22,35 @@
mode: '0755' mode: '0755'
with_items: "{{ portainer_stack_directories }}" with_items: "{{ portainer_stack_directories }}"
#- name: "Stack {{ portainer_stack_name }} | Find docker volumes" - name: "Stack {{ portainer_stack_name }} | Find docker volumes"
# ansible.builtin.shell: docker volume ls -f name={{ portainer_stack_name }} --format '{{ '{{' }} .Name {{ '}}' }}' ansible.builtin.shell: docker volume ls -f name={{ portainer_stack_name }} --format '{{ '{{' }} .Name {{ '}}' }}'
# register: find_volumes register: find_volumes
# changed_when: false changed_when: false
#- name: "Stack {{ portainer_stack_name }} | Find docker volumes that need to be restored" - name: "Stack {{ portainer_stack_name }} | Find docker volumes that need to be restored"
# ansible.builtin.script: scripts/find-volumes-to-restore.py ansible.builtin.script: scripts/find-volumes-to-restore.py
# environment: environment:
# EXISTING_VOLUMES: "{{ find_volumes.stdout_lines }}" EXISTING_VOLUMES: "{{ find_volumes.stdout_lines }}"
# STACK_NAME: '{{ portainer_stack_name }}' STACK_NAME: '{{ portainer_stack_name }}'
# DOCKER_COMPOSE_DIR: '{{ directories.docker_compose_directory }}' DOCKER_COMPOSE_DIR: '{{ directories.docker_compose_directory }}'
# args: args:
# executable: python3 executable: python3
# register: python_output register: python_output
# changed_when: false changed_when: false
#- name: "Stack {{ portainer_stack_name }} | Build list of volumes to restore." - name: "Stack {{ portainer_stack_name }} | Build list of volumes to restore."
# ansible.builtin.set_fact: ansible.builtin.set_fact:
# restore_volumes: "{{ restore_volumes | default([]) + [{'volume_name':item}] }}" restore_volumes: "{{ restore_volumes | default([]) + [{'volume_name':item}] }}"
# with_items: "{{ python_output.stdout_lines | list }}" with_items: "{{ python_output.stdout_lines | list }}"
#- name: "Stack {{ portainer_stack_name }} | Restore any missing volumes from S3" - name: "Stack {{ portainer_stack_name }} | Restore any missing volumes from S3"
# ansible.builtin.include_role: ansible.builtin.include_role:
# name: chatton.docker_backup.docker_s3_volume_restore name: chatton.docker_backup.docker_s3_volume_restore
# when: restore_volumes is defined when: restore_volumes is defined
# vars: vars:
# docker_backup_restore_force: false docker_backup_restore_force: false
# docker_backup_restore_latest_s3_key: true docker_backup_restore_latest_s3_key: true
# docker_backup_s3_restores: "{{ restore_volumes }}" docker_backup_s3_restores: "{{ restore_volumes }}"
- name: "Stack {{ portainer_stack_name }} | Update Portainer." - name: "Stack {{ portainer_stack_name }} | Update Portainer."
chatton.portainer.portainer_stack: chatton.portainer.portainer_stack:

@ -12,36 +12,26 @@
- ubuntu - ubuntu
- busybox - busybox
- name: Directories | Ensure required directories - name: Create required directories.
ansible.builtin.file: ansible.builtin.file:
path: '{{ item }}' path: '{{ file_item.dest_directory }}'
state: directory state: directory
mode: '0755' mode: '0755'
with_items: with_items: "{{ portainer_required_files }}"
- '{{ dashy.config_directory }}' loop_control:
- '{{ olivetin.config_directory }}' loop_var: file_item
- '{{ directories.backups_dir }}/.s3tmp'
- name: Dashy | Config Files
ansible.builtin.copy:
src: '{{ dashy.source_file }}'
dest: '{{ dashy.config_directory }}/{{ dashy.config_file }}'
owner: root
group: root
mode: 0440
ignore_errors: true
notify:
- restart-dashy
- name: Olivetin | Config Files - name: Create required files.
ansible.builtin.copy: ansible.builtin.copy:
src: '{{ olivetin.source_file }}' src: "{{ file_item.source_file }}"
dest: '{{ olivetin.config_directory }}/{{ olivetin.config_file }}' dest: '{{ file_item.dest_directory }}/{{ file_item.dest_file_name }}'
owner: root owner: root
group: root group: root
mode: 0440 mode: 0440
notify: with_items: "{{ portainer_required_files }}"
- restart-olivetin loop_control:
loop_var: file_item
notify: "{{ file_item.handler }}"
- name: Create external docker networks. - name: Create external docker networks.
docker_network: docker_network:
@ -52,10 +42,12 @@
ansible.builtin.include_role: ansible.builtin.include_role:
name: deploy_portainer_stack name: deploy_portainer_stack
vars: vars:
portainer_stack_name: "{{ item.name }}" portainer_stack_name: "{{ portainer_stack.name }}"
portainer_stack_endpoint_id: "{{ portainer_endpoint }}" portainer_stack_endpoint_id: "{{ portainer_endpoint }}"
portainer_stack_template_vars: "{{ item.template_vars | default({}) }}" portainer_stack_template_vars: "{{ portainer_stack.template_vars | default({}) }}"
with_items: "{{ services }}" with_items: "{{ services }}"
loop_control:
loop_var: portainer_stack
- name: Install Ansible pull - name: Install Ansible pull
tags: ["cron"] tags: ["cron"]

@ -1,4 +1,5 @@
--- ---
version: "3.8" version: "3.8"
services: services:
olivetin: olivetin:
@ -6,7 +7,7 @@ services:
image: jamesread/olivetin image: jamesread/olivetin
user: root user: root
volumes: volumes:
- {{olivetin.config_directory}}/{{olivetin.config_file}}:/config/config.yaml - /etc/config/OliveTin/config.yml:/config/config.yaml
- /var/run/docker.sock:/var/run/docker.sock - /var/run/docker.sock:/var/run/docker.sock
ports: ports:
- "1337:1337" - "1337:1337"

Loading…
Cancel
Save