Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ebf275af8f | |||
| f8c025863b | |||
| 6e1d432314 | |||
| 90623e6977 | |||
| 28e3fc9b20 | |||
| 574fa1517a | |||
| a80fba6b8b | |||
| 606b041b7a | |||
| 2d079918d4 | |||
| c61b3c6ef3 |
@@ -140,14 +140,8 @@ To clean up the build you can run `clean.yml` against the docker hosts.
|
|||||||
|
|
||||||
`ansible-playbook playbooks/clean.yml --ask-become`
|
`ansible-playbook playbooks/clean.yml --ask-become`
|
||||||
|
|
||||||
## Section 6: Keeping Docker Containers Up-to-Date
|
## Section 6: Updating hosts
|
||||||
|
|
||||||
Lastly, we have the `docker_update_containers.yml` playbook. This playbook is crucial for updating your Docker containers with the latest images. It also re-imports the docker_status.yml playbook to check the status of containers after the update.
|
Lastly, we have the `update_upgrade.yml` playbook. This playbook is crucial for updating underlying host machines.
|
||||||
|
|
||||||
At this point you should have all of your hosts running docker containers in the `Docker` group of your `inventory.yml` file.
|
`ansible-playbook playbooks/update_upgrade.yml --ask-become `
|
||||||
|
|
||||||
To update your containers this playbook brings your containers down, deletes their images, and brings them back up to pull the updated images.
|
|
||||||
|
|
||||||
**YOU MUST HAVE PERSISTANT STORAGE SETUP! IF YOU DON'T THEN THIS PLAYBOOK WILL <u>DELETE ALL OF YOUR DATA FROM YOUR CONTAINERS**</u> - consider yourself warned.
|
|
||||||
|
|
||||||
`ansible-playbook playbooks/docker_update_containers.yml`
|
|
||||||
+24
-1
@@ -13,7 +13,7 @@ all:
|
|||||||
Docker:
|
Docker:
|
||||||
hosts:
|
hosts:
|
||||||
test-host:
|
test-host:
|
||||||
ansible_host: oracle.madereddy.com
|
ansible_host: 192.168.1.218
|
||||||
ansible_user: jeet
|
ansible_user: jeet
|
||||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||||
# host2:
|
# host2:
|
||||||
@@ -24,3 +24,26 @@ all:
|
|||||||
# - /path/to/docker-compose.yml
|
# - /path/to/docker-compose.yml
|
||||||
# - /path/to/docker-compose.yml
|
# - /path/to/docker-compose.yml
|
||||||
# - /path/to/docker-compose.yml
|
# - /path/to/docker-compose.yml
|
||||||
|
Prod:
|
||||||
|
hosts:
|
||||||
|
Ansible:
|
||||||
|
ansible_connection: local
|
||||||
|
OCI-Uptime-Kuma:
|
||||||
|
ansible_host: oracle.madereddy.com
|
||||||
|
ansible_user: ubuntu
|
||||||
|
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||||
|
# host2:
|
||||||
|
# ansible_host: <ip>
|
||||||
|
# ansible_user: <user>
|
||||||
|
# ansible_ssh_private_key_file: ~/.ssh/<private key>
|
||||||
|
# compose_file_paths:
|
||||||
|
# - /path/to/docker-compose.yml
|
||||||
|
# - /path/to/docker-compose.yml
|
||||||
|
# - /path/to/docker-compose.yml
|
||||||
|
VirtualBox:
|
||||||
|
hosts:
|
||||||
|
Gaming:
|
||||||
|
ansible_host: 192.168.1.13
|
||||||
|
ansible_connection: ssh
|
||||||
|
ansible_user: jeet
|
||||||
|
ansible_shell_type: cmd
|
||||||
+2
-2
@@ -6,11 +6,11 @@
|
|||||||
- name: Stop containers using Docker Compose
|
- name: Stop containers using Docker Compose
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
cmd: docker compose down
|
cmd: docker compose down
|
||||||
chdir: /home/jeet/docker
|
chdir: ~/docker
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
|
|
||||||
- name: Remove build folder
|
- name: Remove build folder
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
state: absent
|
state: absent
|
||||||
path: /home/jeet/docker/
|
path: ~/docker/
|
||||||
force: true
|
force: true
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Update Docker Containers With New Images
|
|
||||||
hosts: Docker
|
|
||||||
gather_facts: yes
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
- name: Stop and remove Docker containers
|
|
||||||
ansible.builtin.command: docker compose down
|
|
||||||
args:
|
|
||||||
chdir: "{{ compose_file_path | dirname }}"
|
|
||||||
loop: "{{ compose_file_paths }}"
|
|
||||||
ignore_errors: yes
|
|
||||||
loop_control:
|
|
||||||
loop_var: compose_file_path
|
|
||||||
|
|
||||||
- name: Run docker compose up
|
|
||||||
ansible.builtin.command: docker compose up -d
|
|
||||||
args:
|
|
||||||
chdir: "{{ compose_file_path | dirname }}"
|
|
||||||
loop: "{{ compose_file_paths }}"
|
|
||||||
loop_control:
|
|
||||||
loop_var: compose_file_path
|
|
||||||
|
|
||||||
- name: Pause for 60 seconds to allow containers to stabilize
|
|
||||||
ansible.builtin.pause:
|
|
||||||
seconds: 60
|
|
||||||
|
|
||||||
- name: Check container status
|
|
||||||
ansible.builtin.shell: docker compose ps -q | xargs -n1 docker container inspect --format '{{ "{{" }} .State.Running {{ "}}" }}'
|
|
||||||
args:
|
|
||||||
chdir: "{{ compose_file_path | dirname }}"
|
|
||||||
loop: "{{ compose_file_paths }}"
|
|
||||||
register: container_status
|
|
||||||
ignore_errors: yes
|
|
||||||
loop_control:
|
|
||||||
loop_var: compose_file_path
|
|
||||||
|
|
||||||
- name: Conditional restart of containers
|
|
||||||
ansible.builtin.command: docker compose up -d
|
|
||||||
args:
|
|
||||||
chdir: "{{ result_item.item.path | dirname }}"
|
|
||||||
loop: "{{ container_status.results }}"
|
|
||||||
when: "'false' in result_item.stdout"
|
|
||||||
register: restart_status
|
|
||||||
loop_control:
|
|
||||||
loop_var: result_item
|
|
||||||
|
|
||||||
- name: Pause for 60 seconds to allow containers to stabilize
|
|
||||||
ansible.builtin.pause:
|
|
||||||
seconds: 60
|
|
||||||
|
|
||||||
- import_playbook: docker_status.yml
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
---
|
---
|
||||||
- hosts: all
|
- hosts: all
|
||||||
become: yes
|
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
@@ -9,12 +8,14 @@
|
|||||||
update_cache: yes
|
update_cache: yes
|
||||||
upgrade: safe
|
upgrade: safe
|
||||||
when: ansible_os_family == "Debian"
|
when: ansible_os_family == "Debian"
|
||||||
|
become: true
|
||||||
|
|
||||||
- name: "Updating and Upgrading Yum Packages"
|
- name: "Updating and Upgrading Yum Packages"
|
||||||
yum:
|
yum:
|
||||||
name: '*'
|
name: '*'
|
||||||
state: latest
|
state: latest
|
||||||
when: ansible_os_family == "RedHat"
|
when: ansible_os_family == "RedHat"
|
||||||
|
become: true
|
||||||
|
|
||||||
# For DNF-based systems (e.g., Fedora), you can add a similar task:
|
# For DNF-based systems (e.g., Fedora), you can add a similar task:
|
||||||
- name: "Updating and Upgrading Dnf Packages"
|
- name: "Updating and Upgrading Dnf Packages"
|
||||||
@@ -22,6 +23,19 @@
|
|||||||
name: '*'
|
name: '*'
|
||||||
state: latest
|
state: latest
|
||||||
when: ansible_distribution == "Fedora"
|
when: ansible_distribution == "Fedora"
|
||||||
|
become: true
|
||||||
|
|
||||||
|
# For Windows Hosts
|
||||||
|
- name: Install all updates and reboot as many times as needed
|
||||||
|
ansible.windows.win_updates:
|
||||||
|
category_names: '*'
|
||||||
|
reboot: true
|
||||||
|
when: ansible_os_family == "Windows"
|
||||||
|
|
||||||
|
- name: Upgrade installed packages
|
||||||
|
win_chocolatey:
|
||||||
|
name: all
|
||||||
|
state: latest
|
||||||
|
when: ansible_os_family == "Windows"
|
||||||
# Specific adjustments for Raspbian can be made here, if necessary
|
# Specific adjustments for Raspbian can be made here, if necessary
|
||||||
# Raspbian will typically be covered by the Debian task, but if you have specific needs, you can specify them here.
|
# Raspbian will typically be covered by the Debian task, but if you have specific needs, you can specify them here.
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
- name: Build OCI Stack
|
||||||
|
hosts: VirtualBox
|
||||||
|
tasks:
|
||||||
|
- name: Start Virtual Box Deployment
|
||||||
|
win_shell: multipass launch 23.04 --bridged
|
||||||
|
ignore_errors: yes
|
||||||
Reference in New Issue
Block a user