You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible-homelab/roles/setup_hosted_services/tasks/main.yml

93 lines
2.4 KiB
YAML

---
- name: Install Modules for Python
ansible.builtin.pip:
name:
- boto3
- name: Docker | Pull images
docker_image:
name: '{{ item }}'
source: pull
with_items:
- ubuntu
- busybox
- name: Directories | Ensure required directories
ansible.builtin.file:
path: '{{ item }}'
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
- name: Olivetin | Config Files
ansible.builtin.copy:
src: '{{ olivetin.source_file }}'
dest: '{{ olivetin.config_directory }}/{{ olivetin.config_file }}'
owner: root
group: root
mode: 0440
notify:
- restart-olivetin
- name: Create external docker networks.
docker_network:
name: '{{ item }}'
with_items: '{{ external_docker_networks }}'
- name: Deploy Portainer stacks.
ansible.builtin.include_role:
name: deploy_portainer_stack
vars:
portainer_stack_name: "{{ item.name }}"
portainer_stack_endpoint_id: "{{ portainer_endpoint }}"
portainer_stack_template_vars: "{{ item.template_vars | default({}) }}"
with_items: "{{ services }}"
- name: Install Ansible pull
tags: ["cron"]
ansible.builtin.pip:
name:
- ansible
# TODO: need to specify ansible pull directly, it doesn't find it when it's in PATH
- name: Ensure Nightly Cron Backups
tags: ["cron"]
ansible.builtin.cron:
name: backup docker volumes (nightly)
weekday: "*"
minute: "0"
hour: "{{ cron_hour }}"
user: "{{ homelab_user }}"
job: >
{{ ansible_pull_path }}
-U https://github.com/chatton/ansible-homelab playbooks/backup-docker-volumes.yml -e schedule=nightly >> ~/logs/nightly.log 2>&1
cron_file: ansible_nightly_docker_volume_backup
state: present
- name: Ensure Monthly Cron Backups
tags: ["cron"]
ansible.builtin.cron:
name: backup docker volumes (monthly)
month: "*"
day: "0"
user: "{{ homelab_user }}"
job: >
{{ ansible_pull_path }}
-U https://github.com/chatton/ansible-homelab playbooks/backup-docker-volumes.yml -e schedule=monthly >> ~/logs/monthly.log 2>&1
cron_file: ansible_monthly_docker_volume_backup
state: present