Add Windows Host
This commit is contained in:
@@ -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`
|
||||
|
||||
## 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.
|
||||
|
||||
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`
|
||||
`ansible-playbook playbooks/update_upgrade.yml --ask-become `
|
||||
@@ -32,6 +32,10 @@ all:
|
||||
ansible_host: oracle.madereddy.com
|
||||
ansible_user: ubuntu
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
Gaming:
|
||||
ansible_host: 192.168.1.13
|
||||
ansible_connection: ssh
|
||||
ansible_shell_type: powershell
|
||||
# host2:
|
||||
# ansible_host: <ip>
|
||||
# ansible_user: <user>
|
||||
|
||||
+2
-2
@@ -6,11 +6,11 @@
|
||||
- name: Stop containers using Docker Compose
|
||||
ansible.builtin.command:
|
||||
cmd: docker compose down
|
||||
chdir: /home/jeet/docker
|
||||
chdir: ~/docker
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Remove build folder
|
||||
ansible.builtin.file:
|
||||
state: absent
|
||||
path: /home/jeet/docker/
|
||||
path: ~/docker/
|
||||
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
|
||||
@@ -23,5 +23,12 @@
|
||||
state: latest
|
||||
when: ansible_distribution == "Fedora"
|
||||
|
||||
# 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"
|
||||
|
||||
# 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.
|
||||
|
||||
Reference in New Issue
Block a user