Imported from GitHub repo
This commit is contained in:
1 parent
0b041984a2
commit
a161888b8f
7 files changed
+110
No files matched your search
@@ -0,0 +1,2 @@
|
||||
[defaults]
|
||||
interpreter_python=auto_silent
|
||||
@@ -0,0 +1,3 @@
|
||||
collections:
|
||||
# Installs the latest version from Ansible Galaxy
|
||||
- name: ansible.windows
|
||||
@@ -0,0 +1,8 @@
|
||||
all:
|
||||
children:
|
||||
ubuntu:
|
||||
hosts:
|
||||
web01.internal.codetical.com:
|
||||
pelican.internal.codetical.com:
|
||||
pinas.internal.codetical.com:
|
||||
pirateship.internal.codetical.com:
|
||||
@@ -0,0 +1,28 @@
|
||||
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:
|
||||
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:
|
||||
@@ -0,0 +1,35 @@
|
||||
---
|
||||
- name: System maintenance and patching
|
||||
hosts: ubuntu
|
||||
become: true
|
||||
tasks:
|
||||
- name: Update package cache and upgrade all packages (Ubuntu/Debian)
|
||||
ansible.builtin.apt:
|
||||
upgrade: dist
|
||||
update_cache: true
|
||||
when: ansible_facts["os_family"] == "Debian"
|
||||
become: true
|
||||
|
||||
- name: Upgrade all packages (RHEL/CentOS/Rocky)
|
||||
ansible.builtin.dnf:
|
||||
name: "*"
|
||||
state: latest
|
||||
when: ansible_facts["os_family"] == "RedHat"
|
||||
become: true
|
||||
|
||||
- name: Check if a reboot is required (Ubuntu/Debian)
|
||||
ansible.builtin.stat:
|
||||
path: /var/run/reboot-required
|
||||
register: reboot_required_file
|
||||
when: ansible_facts["os_family"] == "Debian"
|
||||
become: true
|
||||
|
||||
- name: Reboot the server if required
|
||||
ansible.builtin.reboot:
|
||||
msg: "Reboot initiated by Ansible due to system updates"
|
||||
connect_timeout: 5
|
||||
reboot_timeout: 300
|
||||
when:
|
||||
- ansible_facts["os_family"] == "Debian"
|
||||
- reboot_required_file.stat.exists
|
||||
become: true
|
||||
@@ -0,0 +1,31 @@
|
||||
- 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,3 @@
|
||||
roles:
|
||||
- name: manala.apt
|
||||
src: manala.apt
|
||||
Reference in new issue
Block a user