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
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
configure_mergerfs: false
configure_samba: false
samba_group: smbgroup
@ -56,3 +43,4 @@ portainer_endpoint: -1
portainer_host: false
portainer_base_url: "http://qnap:9000"
external_docker_networks: []
portainer_required_files: []

@ -34,8 +34,28 @@ external_docker_networks:
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:
- name: gitea
template_vars:

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

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

@ -1,4 +1,5 @@
---
version: "3.8"
services:
olivetin:
@ -6,7 +7,7 @@ services:
image: jamesread/olivetin
user: root
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
ports:
- "1337:1337"

Loading…
Cancel
Save