Updated with proper linting and verifications
This commit is contained in:
1 parent
3dc6e55e6f
commit
ac135ec5a3
12 files changed
+82
-69
No files matched your search
@@ -1,3 +0,0 @@
|
|||||||
collections:
|
|
||||||
# Installs the latest version from Ansible Galaxy
|
|
||||||
- name: ansible.windows
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
ansible_connection: winrm
|
||||||
|
ansible_port: 5986
|
||||||
|
ansible_winrm_transport: ntlm
|
||||||
|
ansible_winrm_scheme: https
|
||||||
|
ansible_winrm_server_cert_validation: ignore
|
||||||
|
ansible_winrm_kinit_mode: managed
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
ansible_connection: winrm
|
||||||
|
ansible_port: 5986
|
||||||
|
#ansible_winrm_transport: kerberos
|
||||||
|
ansible_winrm_transport: ntlm
|
||||||
|
ansible_winrm_scheme: https
|
||||||
|
ansible_winrm_server_cert_validation: ignore
|
||||||
|
ansible_winrm_kinit_mode: managed
|
||||||
@@ -5,4 +5,6 @@ all:
|
|||||||
web01.internal.codetical.com:
|
web01.internal.codetical.com:
|
||||||
pelican.internal.codetical.com:
|
pelican.internal.codetical.com:
|
||||||
pinas.internal.codetical.com:
|
pinas.internal.codetical.com:
|
||||||
pirateship.internal.codetical.com:
|
pirateship.internal.codetical.com:
|
||||||
|
cloud.internal.codetical.com:
|
||||||
|
dev01.internal.codetical.com:
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
all:
|
||||||
|
children:
|
||||||
|
domain_controllers:
|
||||||
|
hosts:
|
||||||
|
dc01.internal.codetical.com:
|
||||||
|
windows:
|
||||||
|
hosts:
|
||||||
|
dc02.internal.codetical.com:
|
||||||
|
win_all:
|
||||||
|
children:
|
||||||
|
domain_controllers:
|
||||||
|
windows:
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
all:
|
|
||||||
children:
|
|
||||||
domain_controllers:
|
|
||||||
hosts:
|
|
||||||
dc01.internal.codetical.com:
|
|
||||||
vars:
|
|
||||||
ansible_connection: winrm
|
|
||||||
ansible_port: 5986
|
|
||||||
#ansible_winrm_transport: kerberos
|
|
||||||
ansible_winrm_transport: ntlm
|
|
||||||
ansible_winrm_scheme: https
|
|
||||||
ansible_winrm_server_cert_validation: ignore
|
|
||||||
ansible_winrm_kinit_mode: managed
|
|
||||||
windows:
|
|
||||||
hosts:
|
|
||||||
dc02.internal.codetical.com:
|
|
||||||
backup.internal.codetical.com:
|
|
||||||
vars:
|
|
||||||
ansible_connection: winrm
|
|
||||||
ansible_port: 5986
|
|
||||||
#ansible_winrm_transport: kerberos
|
|
||||||
ansible_winrm_transport: ntlm
|
|
||||||
ansible_winrm_scheme: https
|
|
||||||
ansible_winrm_server_cert_validation: ignore
|
|
||||||
ansible_winrm_kinit_mode: managed
|
|
||||||
win_all:
|
|
||||||
children:
|
|
||||||
domain_controllers:
|
|
||||||
windows:
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
- name: Apply Windows Updates
|
|
||||||
hosts: win_all
|
|
||||||
gather_facts: yes
|
|
||||||
vars:
|
|
||||||
initial_reboot: |-
|
|
||||||
{{ 86400 <
|
|
||||||
(( ((ansible_date_time.date+" "+ansible_date_time.time)|to_datetime('%Y-%m-%d %H:%M:%S')) -
|
|
||||||
ansible_facts.lastboot|to_datetime('%Y-%m-%d %H:%M:%SZ')).total_seconds())|abs }}
|
|
||||||
tasks:
|
|
||||||
- block:
|
|
||||||
- name: Install Updates And Reboot
|
|
||||||
ansible.windows.win_updates:
|
|
||||||
category_names:
|
|
||||||
- SecurityUpdates
|
|
||||||
- CriticalUpdates
|
|
||||||
- UpdateRollups
|
|
||||||
- DefinitionUpdates
|
|
||||||
- Updates
|
|
||||||
reboot: false
|
|
||||||
state: installed
|
|
||||||
become: yes
|
|
||||||
become_method: runas
|
|
||||||
become_user: SYSTEM
|
|
||||||
register: update_results
|
|
||||||
|
|
||||||
- name: Reboot explicitly if required
|
|
||||||
ansible.windows.win_reboot:
|
|
||||||
reboot_timeout: 3600
|
|
||||||
post_reboot_delay: 120
|
|
||||||
test_command: 'powershell.exe -Command "Get-Service WinRM"'
|
|
||||||
when: update_results.reboot_required
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
- name: All Servers Test Windows Connectivity And Output Facts
|
||||||
|
hosts: all
|
||||||
|
gather_facts: true
|
||||||
|
tasks:
|
||||||
|
- name: Ping The Windows Hosts
|
||||||
|
ansible.windows.win_ping:
|
||||||
|
- name: Export Facts
|
||||||
|
ansible.builtin.copy:
|
||||||
|
mode: "0644"
|
||||||
|
content: "{{ ansible_facts | to_nice_json }}"
|
||||||
|
dest: "{{ playbook_dir }}../facts/{{ inventory_hostname }}.json"
|
||||||
|
delegate_to: localhost
|
||||||
|
tags: ["never", "debug"]
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
- name: Upgrade all packages (RHEL/CentOS/Rocky)
|
- name: Upgrade all packages (RHEL/CentOS/Rocky)
|
||||||
ansible.builtin.dnf:
|
ansible.builtin.dnf:
|
||||||
name: "*"
|
name: "*"
|
||||||
state: latest
|
state: present
|
||||||
when: ansible_facts["os_family"] == "RedHat"
|
when: ansible_facts["os_family"] == "RedHat"
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
msg: "Reboot initiated by Ansible due to system updates"
|
msg: "Reboot initiated by Ansible due to system updates"
|
||||||
connect_timeout: 5
|
connect_timeout: 5
|
||||||
reboot_timeout: 300
|
reboot_timeout: 300
|
||||||
when:
|
when:
|
||||||
- ansible_facts["os_family"] == "Debian"
|
- ansible_facts["os_family"] == "Debian"
|
||||||
- reboot_required_file.stat.exists
|
- reboot_required_file.stat.exists
|
||||||
become: true
|
become: true
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
- name: Apply Windows Updates
|
||||||
|
hosts: win_all
|
||||||
|
gather_facts: true
|
||||||
|
vars:
|
||||||
|
initial_reboot: |-
|
||||||
|
{{ 86400 <
|
||||||
|
(( ((ansible_date_time.date+" "+ansible_date_time.time)|to_datetime('%Y-%m-%d %H:%M:%S')) -
|
||||||
|
ansible_facts.lastboot|to_datetime('%Y-%m-%d %H:%M:%SZ')).total_seconds())|abs }}
|
||||||
|
tasks:
|
||||||
|
- name: Run Windows Updates
|
||||||
|
block:
|
||||||
|
- name: Install Updates And Reboot
|
||||||
|
ansible.windows.win_updates:
|
||||||
|
category_names:
|
||||||
|
- "*"
|
||||||
|
reboot: false
|
||||||
|
state: installed
|
||||||
|
become: true
|
||||||
|
become_method: ansible.builtin.runas
|
||||||
|
become_user: SYSTEM
|
||||||
|
register: update_results
|
||||||
|
|
||||||
|
- name: Reboot explicitly if required
|
||||||
|
ansible.windows.win_reboot:
|
||||||
|
reboot_timeout: 3600
|
||||||
|
post_reboot_delay: 120
|
||||||
|
test_command: 'powershell.exe -Command "Get-Service WinRM"'
|
||||||
|
when: update_results.reboot_required
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
collections:
|
||||||
|
- name: ansible.windows
|
||||||
|
- name: community.general
|
||||||
|
roles:
|
||||||
|
- name: manala.apt
|
||||||
|
src: manala.apt
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
roles:
|
|
||||||
- name: manala.apt
|
|
||||||
src: manala.apt
|
|
||||||
Reference in new issue
Block a user