diff --git a/README.md b/README.md index 9eb59b2..1753756 100644 --- a/README.md +++ b/README.md @@ -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 DELETE ALL OF YOUR DATA FROM YOUR CONTAINERS** - consider yourself warned. - -`ansible-playbook playbooks/docker_update_containers.yml` \ No newline at end of file +`ansible-playbook playbooks/update_upgrade.yml --ask-become ` \ No newline at end of file diff --git a/inventory.yml b/inventory.yml index d5b5aec..b02092b 100644 --- a/inventory.yml +++ b/inventory.yml @@ -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: # ansible_user: diff --git a/playbooks/clean.yml b/playbooks/clean.yml index af2c14a..73f1e83 100644 --- a/playbooks/clean.yml +++ b/playbooks/clean.yml @@ -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 \ No newline at end of file diff --git a/playbooks/docker_update_containers.yml b/playbooks/docker_update_containers.yml deleted file mode 100644 index e4a0491..0000000 --- a/playbooks/docker_update_containers.yml +++ /dev/null @@ -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 \ No newline at end of file diff --git a/playbooks/update_upgrade.yml b/playbooks/update_upgrade.yml index 99a236d..b557ecc 100644 --- a/playbooks/update_upgrade.yml +++ b/playbooks/update_upgrade.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.