initial commit
This commit is contained in:
9
roles/docker/tasks/cleanup-all.yml
Normal file
9
roles/docker/tasks/cleanup-all.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
- name: Prune everything
|
||||
community.docker.docker_prune:
|
||||
containers: true
|
||||
images: true
|
||||
networks: true
|
||||
volumes: true
|
||||
builder_cache: true
|
||||
register: result
|
||||
|
||||
4
roles/docker/tasks/cleanup-images.yml
Normal file
4
roles/docker/tasks/cleanup-images.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
- name: Prune images only
|
||||
community.docker.docker_prune:
|
||||
images: true
|
||||
register: result
|
||||
12
roles/docker/tasks/get-containerstatus.yml
Normal file
12
roles/docker/tasks/get-containerstatus.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
- name: Ensure Docker Compose project is up
|
||||
community.docker.docker_compose_v2:
|
||||
project_src: "{{ docker_compose_path }}"
|
||||
state: present
|
||||
register: compose_status
|
||||
|
||||
- name: Set fact for container status
|
||||
set_fact:
|
||||
container_status: "{{ container_status | default({}) | combine({item.Name: (item.State == 'running')}) }}"
|
||||
verbosity: 0
|
||||
with_items: "{{ compose_status.containers }}"
|
||||
5
roles/docker/tasks/restart-daemon.yml
Normal file
5
roles/docker/tasks/restart-daemon.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
- name: Restart Docker Daemon
|
||||
ansible.builtin.systemd:
|
||||
name: docker
|
||||
state: restarted
|
||||
14
roles/managed-mailcow/tasks/find-mailcow-composedir.yml
Normal file
14
roles/managed-mailcow/tasks/find-mailcow-composedir.yml
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: Find mailcow-dockerized directory
|
||||
vars:
|
||||
mailcow_search_paths:
|
||||
- /opt
|
||||
- /data
|
||||
- /root
|
||||
ansible.builtin.find:
|
||||
file_type: directory
|
||||
paths: "{{ mailcow_search_paths }}"
|
||||
patterns: mailcow-dockerized
|
||||
recurse: yes
|
||||
register: mailcow_dir_result
|
||||
ignore_errors: true
|
||||
12
roles/managed-mailcow/tasks/start-mailcow.yml
Normal file
12
roles/managed-mailcow/tasks/start-mailcow.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
- name: Start mailcow stack
|
||||
community.docker.docker_compose_v2:
|
||||
project_src: "{{ docker_compose_path }}"
|
||||
state: present
|
||||
register: output
|
||||
|
||||
- name: Print Replay
|
||||
debug:
|
||||
var: output
|
||||
when: verbose | bool
|
||||
|
||||
11
roles/managed-mailcow/tasks/stop-mailcow.yml
Normal file
11
roles/managed-mailcow/tasks/stop-mailcow.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
---
|
||||
- name: Stop mailcow stack
|
||||
community.docker.docker_compose_v2:
|
||||
project_src: "{{ docker_compose_path }}"
|
||||
state: absent
|
||||
register: output
|
||||
|
||||
- name: Print Replay
|
||||
debug:
|
||||
var: output
|
||||
when: verbose | bool
|
||||
22
roles/managed-mailcow/tasks/update-mailcow.yml
Normal file
22
roles/managed-mailcow/tasks/update-mailcow.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
- name: Check if mailcow.conf exists
|
||||
ansible.builtin.stat:
|
||||
path: "{{ mailcow_dir_result.files[0].path }}/mailcow.conf"
|
||||
register: mailcow_conf
|
||||
when: mailcow_dir_result.files[0].path is defined
|
||||
|
||||
- name: Check mailcow Version
|
||||
ansible.builtin.shell: |
|
||||
cd {{ mailcow_dir_result.files[0].path }}/data/web/inc
|
||||
grep -oP '\$MAILCOW_GIT_VERSION="\K[^"]+' app_info.inc.php
|
||||
register: local_mailcow_version
|
||||
when: mailcow_conf.stat.exists
|
||||
|
||||
- name: Check Disk Utilization
|
||||
import_role:
|
||||
name: roles/system
|
||||
tasks_from: check-disk-utilization.yaml
|
||||
|
||||
- name: Update mailcow
|
||||
shell: "cd {{ mailcow_dir_result.files[0].path }} && git fetch && git checkout origin/master update.sh && ./update.sh --force"
|
||||
when: local_mailcow_version.stdout != github_mailcow_ver and mailcow_conf.stat.exists and disk_space_output | bool
|
||||
4
roles/requirements.yml
Normal file
4
roles/requirements.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
collections:
|
||||
- name: community.docker
|
||||
version: 3.11.0
|
||||
9
roles/system/tasks/check-disk-utilization.yaml
Normal file
9
roles/system/tasks/check-disk-utilization.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
- name: Run disk space command
|
||||
ansible.builtin.shell: "df --output=used,avail / | awk 'NR==2 {used=$1; available=$2; total=used+available; percentage=used*100/total; if (percentage < {{ disk_space_percent_max }} ) printf \"true\"; else printf \"false\"}'"
|
||||
# System uses the disk_space_percent_max variable to determine condition this check is getting. Over the amount defined in the var causes the check to fail!
|
||||
register: disk_space_output
|
||||
|
||||
- name: "**DEBUG**: Server disk Utilization condition"
|
||||
ansible.builtin.debug:
|
||||
var: disk_space_output.stdout
|
||||
when: debug | bool
|
||||
8
roles/updates/tasks/apk-based-update.yaml
Normal file
8
roles/updates/tasks/apk-based-update.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
- name: Run apk update
|
||||
ansible.builtin.apk:
|
||||
update_cache: yes
|
||||
register: apk_result
|
||||
|
||||
- name: Run Package Upgrade (apk)
|
||||
ansible.builtin.apk:
|
||||
upgrade: yes
|
||||
10
roles/updates/tasks/apt-based-update.yaml
Normal file
10
roles/updates/tasks/apt-based-update.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
- name: Run Cache refresh (apt)
|
||||
ansible.builtin.apt:
|
||||
update_cache: yes
|
||||
register: apt_result
|
||||
|
||||
- name: Run Package Upgrade (apt)
|
||||
ansible.builtin.apt:
|
||||
upgrade: dist
|
||||
force: true
|
||||
autoclean: true
|
||||
15
roles/updates/tasks/apt-cleaning.yaml
Normal file
15
roles/updates/tasks/apt-cleaning.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
- name: APT run autoremove with purge
|
||||
ansible.builtin.apt:
|
||||
autoremove: yes
|
||||
purge: yes
|
||||
when: purge_autoremove | bool
|
||||
|
||||
- name: APT run autoremove without purge
|
||||
ansible.builtin.apt:
|
||||
autoremove: yes
|
||||
purge: no
|
||||
when: not purge_autoremove
|
||||
|
||||
- name: APT run autoclean
|
||||
ansible.builtin.apt:
|
||||
autoclean: yes
|
||||
3
roles/updates/tasks/debian-major-upgrade-apt.yaml
Normal file
3
roles/updates/tasks/debian-major-upgrade-apt.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
- name: Upgrade Debian Repos to newest Major Version
|
||||
task:
|
||||
a
|
||||
Reference in New Issue
Block a user