v.1.5.0 docker-compose-update.yaml; apt clean

This commit is contained in:
2025-06-24 10:06:19 +02:00
parent 9875f15990
commit 437afd41b3
5 changed files with 60 additions and 0 deletions

View File

@@ -10,3 +10,7 @@ ansible-playbook system-upgrade.yml
```bash
ansible-playbook local-upgrade.yaml --become --ask-become-pass
```
```bash
ansible-playbook docker-compose-update.yaml
```

View File

@@ -1,4 +1,5 @@
[defaults]
interpreter_python = /usr/bin/python3
inventory=inventory
private_key_file=~/.ssh/id_ed25519
remote_user=ansible

View File

@@ -0,0 +1,47 @@
### noch nicht ok !!!!
### keine Rechte fuer User ansible
- name: Manage Docker Compose services
hosts: wiki, paperless, mongodb, gitea, newt-pangolin, jenkins
# hosts: wiki
become: true
vars:
host_compose_dirs:
wiki: "/home/admin/wikijs"
paperless: "/home/admin"
mongodb: "/home/admin/mongodb"
gitea: "/home/admin"
newt-pangolin: "/home/admin/newt"
jenkins: "/home/admin/jenkins"
force_pull: false
force_recreate: false
tasks:
- name: Stop and remove containers
community.docker.docker_compose_v2:
project_src: "{{ host_compose_dirs[inventory_hostname] }}"
state: absent
register: compose_down
- name: Pull latest images
community.docker.docker_compose_v2_pull:
project_src: "{{ host_compose_dirs[inventory_hostname] }}"
# Remove the 'pull' parameter - the module always pulls by default
# Add policy if you want to control pull behavior
policy: "always" # or "missing" or "build"
when: compose_down.changed or force_pull
register: compose_pull
- name: Start services
community.docker.docker_compose_v2:
project_src: "{{ host_compose_dirs[inventory_hostname] }}"
state: present
recreate: "{{ 'always' if force_recreate else 'auto' }}"
register: compose_up
- name: Display operation results
debug:
msg: |
Host: {{ inventory_hostname }}
Services down: {{ compose_down.changed }}
Images pulled: {{ compose_pull.changed if compose_pull is defined else 'skipped' }}
Services up: {{ compose_up.changed }}

View File

@@ -8,3 +8,7 @@
ansible.builtin.apt:
update_cache: yes
upgrade: safe
- name: Run the equivalent of "apt clean"
ansible.builtin.apt:
clean: yes

View File

@@ -10,6 +10,10 @@
update_cache: yes
upgrade: safe
- name: Run the equivalent of "apt clean"
ansible.builtin.apt:
clean: yes
- hosts: homelab
become: true
gather_facts: yes