mirror of
https://git.ecdf.ed.ac.uk/win_automation/windows-ansible.git
synced 2026-10-26 14:07:21 +00:00
update stuff
This commit is contained in:
1 parent
0ea597180c
commit
66c83a2014
7 files changed
+72
-109
No files matched your search
@@ -3,4 +3,3 @@
|
|||||||
- import_tasks: chocolatey.yml
|
- import_tasks: chocolatey.yml
|
||||||
- import_tasks: rdgw.yml
|
- import_tasks: rdgw.yml
|
||||||
- import_tasks: start_menu.yml
|
- import_tasks: start_menu.yml
|
||||||
- import_tasks: update.yml
|
|
||||||
@@ -38,6 +38,24 @@
|
|||||||
when: inventory_hostname in groups['meta-variant_gpu']
|
when: inventory_hostname in groups['meta-variant_gpu']
|
||||||
when: groups['meta-variant_gpu'] is defined
|
when: groups['meta-variant_gpu'] is defined
|
||||||
|
|
||||||
|
- name: Update Start Menu Shortcutsm
|
||||||
|
tags: update_start_menu
|
||||||
|
block:
|
||||||
|
- name: Copy Python script to target machine
|
||||||
|
ansible.windows.win_template:
|
||||||
|
src: '{{ script_name }}'
|
||||||
|
dest: '{{ script_path }}'
|
||||||
|
force: true
|
||||||
|
|
||||||
|
- name: Copy current XML to backup location
|
||||||
|
win_copy:
|
||||||
|
remote_src: true
|
||||||
|
src: '{{ start_menu_xml }}'
|
||||||
|
dest: '{{ backup_xml }}'
|
||||||
|
|
||||||
|
- name: Run Python script on remote machine
|
||||||
|
win_command: python "{{ script_path }}"
|
||||||
|
|
||||||
- name: Update Group Policy
|
- name: Update Group Policy
|
||||||
win_shell: gpupdate /force /boot /logoff
|
win_shell: gpupdate /force /boot /logoff
|
||||||
tags:
|
tags:
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Install all updates and reboot as many times as needed
|
|
||||||
tags: update_windows
|
|
||||||
block:
|
|
||||||
- name: Install Windows updates (looped)
|
|
||||||
ansible.windows.win_updates:
|
|
||||||
category_names: '*'
|
|
||||||
reboot: true
|
|
||||||
register: update_result
|
|
||||||
retries: 5
|
|
||||||
delay: 30
|
|
||||||
until: update_result.reboot_required == false
|
|
||||||
|
|
||||||
- name: Wait for host to come back online
|
|
||||||
ansible.builtin.wait_for_connection:
|
|
||||||
timeout: 600
|
|
||||||
|
|
||||||
- name: Install all Windows updates and reboot if required
|
|
||||||
tags: update_windows1
|
|
||||||
block:
|
|
||||||
- name: Install Windows updates (no auto reboot)
|
|
||||||
ansible.windows.win_updates:
|
|
||||||
category_names: '*'
|
|
||||||
reboot: false
|
|
||||||
register: update_result
|
|
||||||
|
|
||||||
- name: Reboot the machine if updates require it
|
|
||||||
ansible.windows.win_reboot:
|
|
||||||
when: update_result.reboot_required
|
|
||||||
|
|
||||||
- name: Wait for the host to come back online
|
|
||||||
ansible.builtin.wait_for_connection:
|
|
||||||
timeout: 600
|
|
||||||
- name: Update all choco packages
|
|
||||||
win_command: choco upgrade all -y
|
|
||||||
tags: update_choco
|
|
||||||
|
|
||||||
- name: Update Start Menu Shortcuts in XML on remote Windows machines
|
|
||||||
tags: update_start_menu
|
|
||||||
block:
|
|
||||||
- name: Copy Python script to target machine
|
|
||||||
ansible.windows.win_template:
|
|
||||||
src: "{{ script_name }}"
|
|
||||||
dest: "{{ script_path }}"
|
|
||||||
force: true
|
|
||||||
|
|
||||||
- name: Copy current XML to backup location
|
|
||||||
win_copy:
|
|
||||||
remote_src: true
|
|
||||||
src: "{{ start_menu_xml }}"
|
|
||||||
dest: "{{ backup_xml }}"
|
|
||||||
|
|
||||||
- name: Run Python script on remote machine
|
|
||||||
win_command: python "{{ script_path }}"
|
|
||||||
register: output
|
|
||||||
|
|
||||||
- name: debug
|
|
||||||
debug:
|
|
||||||
var: output
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
repo_url: 'http://{{ win_project }}-choc.{{ win_project }}.loc/chocolatey'
|
repo_url: 'http://{{ win_project }}-choc.{{ win_project }}.loc/chocolatey'
|
||||||
start_menu_xml: "C:\\\\eidf\\\\{{ win_project }}.xml"
|
start_menu_xml: "C:\\eidf\\{{ win_project }}.xml"
|
||||||
backup_xml: "C:\\\\eidf\\\\{{ win_project }}-old.xml"
|
backup_xml: "C:\\eidf\\{{ win_project }}-old.xml"
|
||||||
script_name: newXML.py
|
script_name: newXML.py
|
||||||
script_path: "C:\\eidf\\{{ script_name }}"
|
script_path: "C:\\eidf\\{{ script_name }}"
|
||||||
@@ -1,14 +1,10 @@
|
|||||||
---
|
---
|
||||||
- name: Install client VM updates and reboot as much as needed
|
- name: Install all updates and reboot as many times as needed
|
||||||
|
tags: update_windows1
|
||||||
block:
|
block:
|
||||||
- name: Install Windows updates (looped)
|
- name: Install Windows updates (looped)
|
||||||
tags: update_windows
|
|
||||||
ansible.windows.win_updates:
|
ansible.windows.win_updates:
|
||||||
category_names:
|
category_names: '*'
|
||||||
- CriticalUpdates
|
|
||||||
- DefinitionUpdates
|
|
||||||
- SecurityUpdates
|
|
||||||
- UpdateRollups
|
|
||||||
reboot: true
|
reboot: true
|
||||||
register: update_result
|
register: update_result
|
||||||
retries: 5
|
retries: 5
|
||||||
@@ -16,50 +12,59 @@
|
|||||||
until: update_result.reboot_required == false
|
until: update_result.reboot_required == false
|
||||||
|
|
||||||
- name: Wait for host to come back online
|
- name: Wait for host to come back online
|
||||||
tags: update_windows
|
|
||||||
ansible.builtin.wait_for_connection:
|
ansible.builtin.wait_for_connection:
|
||||||
timeout: 600
|
timeout: 600
|
||||||
|
|
||||||
- name: Update all choco packages
|
- name: Install all Windows updates and reboot if required
|
||||||
win_command: choco upgrade all -y
|
|
||||||
tags: update_choco
|
|
||||||
|
|
||||||
- name: Update Start Menu Shortcuts in XML on remote Windows machines
|
|
||||||
tags: update_start_menu
|
|
||||||
block:
|
|
||||||
- name: Copy Python script to target machine
|
|
||||||
ansible.windows.win_template:
|
|
||||||
src: "{{ script_name }}"
|
|
||||||
dest: "{{ script_path }}"
|
|
||||||
force: true
|
|
||||||
|
|
||||||
- name: Copy current XML to backup location
|
|
||||||
win_copy:
|
|
||||||
remote_src: true
|
|
||||||
src: "{{ start_menu_xml }}"
|
|
||||||
dest: "{{ backup_xml }}"
|
|
||||||
|
|
||||||
- name: Run Python script on remote machine
|
|
||||||
win_command: python "{{ script_path }}.xml"
|
|
||||||
when: "inventory_hostname in groups['meta-type_client']|default([])"
|
|
||||||
|
|
||||||
- name: Install Server VM updates and reboot as much as needed
|
|
||||||
tags: update_windows
|
tags: update_windows
|
||||||
block:
|
block:
|
||||||
- name: Install Windows updates (looped)
|
- name: Install Windows updates (no auto reboot)
|
||||||
ansible.windows.win_updates:
|
ansible.windows.win_updates:
|
||||||
category_names:
|
category_names: '*'
|
||||||
- CriticalUpdates
|
reboot: false
|
||||||
- DefinitionUpdates
|
|
||||||
- SecurityUpdates
|
|
||||||
- UpdateRollups
|
|
||||||
reboot: true
|
|
||||||
register: update_result
|
register: update_result
|
||||||
retries: 5
|
|
||||||
delay: 30
|
|
||||||
until: update_result.reboot_required == false
|
|
||||||
|
|
||||||
- name: Wait for host to come back online
|
- name: Reboot the machine if updates require it
|
||||||
|
ansible.windows.win_reboot:
|
||||||
|
when: update_result.reboot_required
|
||||||
|
|
||||||
|
- name: Wait for the host to come back online
|
||||||
ansible.builtin.wait_for_connection:
|
ansible.builtin.wait_for_connection:
|
||||||
timeout: 600
|
timeout: 600
|
||||||
when: "inventory_hostname in groups['meta-type_server']"
|
|
||||||
|
- name: Update all choco packages
|
||||||
|
tags: update_choco
|
||||||
|
block:
|
||||||
|
- name: Run Chocolatey upgrade (allow failure, don't mark as failed)
|
||||||
|
win_command: choco upgrade all -y --ignore-checksums --failonunfound --continue-on-failure
|
||||||
|
register: choco_result
|
||||||
|
ignore_errors: true
|
||||||
|
failed_when: false # << This prevents Ansible from treating it as a failed task
|
||||||
|
|
||||||
|
- name: Show Chocolatey output
|
||||||
|
debug:
|
||||||
|
var: choco_result
|
||||||
|
|
||||||
|
- name: Update Start Menu Shortcuts in XML on remote Windows machines
|
||||||
|
tags: update_start_menu
|
||||||
|
block:
|
||||||
|
- name: Copy Python script to target machine
|
||||||
|
ansible.windows.win_template:
|
||||||
|
src: "{{ script_name }}"
|
||||||
|
dest: "{{ script_path }}"
|
||||||
|
force: true
|
||||||
|
|
||||||
|
- name: Copy current XML to backup location
|
||||||
|
win_copy:
|
||||||
|
remote_src: true
|
||||||
|
src: "{{ start_menu_xml }}"
|
||||||
|
dest: "{{ backup_xml }}"
|
||||||
|
|
||||||
|
- name: Run Python script on remote machine
|
||||||
|
win_command: python "{{ script_path }}"
|
||||||
|
register: output
|
||||||
|
|
||||||
|
- name: debug
|
||||||
|
debug:
|
||||||
|
var: output
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
start_menu_xml: "C:\\eidf\\{{ win_project }}.xml"
|
start_menu_xml: "C:\\\\eidf\\\\{{ win_project }}.xml"
|
||||||
backup_xml: "C:\\eidf\\{{ win_project }}-old.xml"
|
backup_xml: "C:\\\\eidf\\\\{{ win_project }}-old.xml"
|
||||||
script_name: newXML.py
|
script_name: newXML.py
|
||||||
script_path: "C:\\eidf\\{{ script_name }}"
|
script_path: "C:\\eidf\\{{ script_name }}"
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
tags: copy_wsus_optimization_script
|
tags: copy_wsus_optimization_script
|
||||||
|
|
||||||
- name: Apply WSUS script
|
- name: Apply WSUS script
|
||||||
win_shell: "powershell {{ script_dir }}\\{{ wsus_script }}"
|
win_shell: "powershell -windowstyle hidden -file \"{{ script_dir }}\\{{ wsus_script }}\""
|
||||||
tags:
|
tags:
|
||||||
- apply_wsus_script
|
- apply_wsus_script
|
||||||
- never
|
- never
|
||||||
|
|||||||
Reference in new issue
Block a user