This commit is contained in:
Jack
2025-08-03 17:56:59 +01:00
commit 9792d05450
8 changed files with 105 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.DS_Store

2
ansible.cfg Normal file
View File

@@ -0,0 +1,2 @@
[defaults]
inventory = hosts

31
docker-update.yml Normal file
View File

@@ -0,0 +1,31 @@
---
- hosts: docker_servers
gather_facts: yes
become: yes
tasks:
- name: Pull Docker files
community.docker.docker_compose_v2_pull:
project_src: "{{ docker_folder }}"
register: output
# - name: Pull results
# ansible.builtin.debug:
# var: output
- name: Up Docker Stack
community.docker.docker_compose_v2:
project_src: "{{ docker_folder }}"
build: never
remove_orphans: true
register: output
# - name: Up results
# ansible.builtin.debug:
# var: output
- name: Prune images
community.docker.docker_prune:
images: true
networks: true
builder_cache: true

6
group_vars/all.yml Normal file
View File

@@ -0,0 +1,6 @@
---
ansible_user: "jack"
ansible_port: "22"
ansible_host: "{{ inventory_hostname }}.internal.tgj.services"
ansible_python_interpreter: "/usr/bin/python3"
ansible_ssh_private_key_file: "~/.ssh/id_rsa-nopass"

6
hosts Normal file
View File

@@ -0,0 +1,6 @@
[servers]
<hostname> ansible_user="<user>"
[docker_servers]
<Serverhostname> ansible_user="<user>" docker_folder="Pathtodocker"

24
readme.md Normal file
View File

@@ -0,0 +1,24 @@
## Upgrade Packages On system Without reboot
```
ansible-playbook update.yml -D --skip-tags "reboot" --limit <Server>
```
# Update servers packages & reboot if needed
```
ansible-playbook update.yml -D --limit <server>
```
# Check update changes
```
ansible-playbook update.yml -C -D --skip-tags "reboot" --limit <Server>
```
# Check docker update changes
```
ansible-playbook docker.yml -C -D --limit <Server>
```
# Check docker pull and up
```
ansible-playbook docker.yml --limit <Server>
```

6
ssh_config Normal file
View File

@@ -0,0 +1,6 @@
## INFRA
Host node-1
HostName tgj-node-1.internal.tgj.services
User root
IdentityFile ~/.ssh/id_rsa
Port 22

29
update.yml Normal file
View File

@@ -0,0 +1,29 @@
---
- hosts: all
gather_facts: yes
become: yes
tasks:
- name: Update and upgrade apt packages
become: true
apt:
upgrade: yes
update_cache: yes
cache_valid_time: 86400 #One day
- name: Remove dependencies that are no longer required.
ansible.builtin.apt:
autoremove: yes
- name: Check if a reboot is required.
become: true
ansible.builtin.stat:
path: /var/run/reboot-required
get_checksum: no
register: reboot_required_file
- name: Reboot the server (if required).
become: true
tags: reboot
ansible.builtin.reboot:
when: reboot_required_file.stat.exists == true