use ansible blocks with tags, also use standard layout

This commit is contained in:
abrown38 committed 2024-08-05 11:39:36 +01:00
1 parent cba1130bd9
commit a86a6ba964
2 files changed
+39 -54

No files matched your search

+13 -27
View File
@@ -1,29 +1,15 @@
--- ---
- name: Rebooting hosts - name: Reboot VM
ansible.windows.win_reboot: tags: reboot_vm
msg: "rebooting VM, initiated by ansible" block:
reboot_timeout: 3600 - name: Rebooting hosts
register: status ansible.windows.win_reboot:
msg: "rebooting VM, initiated by ansible"
reboot_timeout: 3600
- name: Delay WinRM - name: Logging action
ansible.windows.win_service: vars:
name: WinRM ansible_connection: local
start_mode: delayed ansible.builtin.shell:
cmd: echo "Reboot {{ os_project }}-{{ ansible_hostname }} $(date '+%Y-%m-%d %H:%M:%S')" >> /deployments/{{ os_project }}-{{ win_project }}/action.log
#- name: Force Openstack Reboot delegate_to: localhost
# openstack.cloud.server_action:
# action: "reboot_hard"
#name: "{{ ansible_hostname }}"
# when: not status | bool
#- name: Delay WinRM
# ansible.windows.win_service:
# name: WinRM
# start_mode: delayed
- name: Logging action
vars:
ansible_connection: local
ansible.builtin.shell:
cmd: echo "Reboot {{ os_project }}-{{ ansible_hostname }} $(date '+%Y-%m-%d %H:%M:%S')" >> /deployments/{{ os_project }}-{{ win_project }}/action.log
delegate_to: localhost
+26 -27
View File
@@ -1,31 +1,30 @@
--- ---
- name: Clear update cache - name: Update VM
win_shell: | tags: update_vm
UsoClient RefreshSettings block:
UsoClient ScanInstallWait - name: Clear update cache
win_shell: |
UsoClient RefreshSettings
UsoClient ScanInstallWait
- name: Update Windows - name: Update Windows
ansible.windows.win_updates: ansible.windows.win_updates:
category_names: '*' category_names: '*'
skip_optional: true skip_optional: true
reboot: true reboot: true
reboot_timeout: 3600 reboot_timeout: 3600
vars: ignore_errors: true
ansible_become: true
ansible_become_pass: "{{ ansible_password }}"
ansible_become_user: Administrator
ignore_errors: true
- name: Update Windows (again) - name: Update Windows (again)
ansible.windows.win_updates: ansible.windows.win_updates:
category_names: '*' category_names: '*'
reboot: true reboot: true
reboot_timeout: 3600 reboot_timeout: 3600
ignore_errors: true ignore_errors: true
- name: Logging action - name: Logging action
vars: vars:
ansible_connection: local ansible_connection: local
ansible.builtin.shell: ansible.builtin.shell:
cmd: echo "Update {{ os_project }}-{{ ansible_hostname }} $(date '+%Y-%m-%d %H:%M:%S')" >> /deployments/{{ os_project }}-{{ win_project }}/action.log cmd: echo "Update {{ os_project }}-{{ ansible_hostname }} $(date '+%Y-%m-%d %H:%M:%S')" >> /deployments/{{ os_project }}-{{ win_project }}/action.log
delegate_to: localhost delegate_to: localhost