2022-06-05 16:48:06 -05:00

93 lines
3.0 KiB
YAML

---
# tasks file for ensure_os_patch
- name: 'include vendor / version specific tasks'
when:
- ansible_system == 'Linux'
include_tasks:
file: '{{ lookup("first_found", findme ) }}'
vars:
findme:
files:
- '{{ ansible_distribution }}-{{ ansible_distribution_major_version }}-{{ ansible_architecture }}.yml'
- '{{ ansible_distribution }}-{{ ansible_distribution_major_version }}-default.yml'
- '{{ ansible_distribution }}-default.yml'
- '{{ ansible_os_family }}-{{ ansible_distribution_major_version }}-{{ ansible_architecture }}.yml'
- '{{ ansible_os_family }}-{{ ansible_distribution_major_version }}-default.yml'
- '{{ ansible_os_family }}-default.yml'
- 'default.yml'
errors: 'ignore'
- name: 'include variables'
when:
- ansible_system == 'Linux'
include_vars:
file: '{{ lookup("first_found", findme ) }}'
name: 'ensure_os_patch'
vars:
findme:
files:
- '{{ ansible_distribution }}-{{ ansible_distribution_major_version }}-{{ ansible_architecture }}.yml'
- '{{ ansible_distribution }}-{{ ansible_distribution_major_version }}-default.yml'
- '{{ ansible_distribution }}-default.yml'
- '{{ ansible_os_family }}-{{ ansible_distribution_major_version }}-{{ ansible_architecture }}.yml'
- '{{ ansible_os_family }}-{{ ansible_distribution_major_version }}-default.yml'
- '{{ ansible_os_family }}-default.yml'
- 'default.yml'
paths:
- '../vars/'
errors: 'ignore'
- name: 'package discovery'
when:
- ansible_system == 'Linux'
- packages is not defined
ansible.builtin.package_facts:
- name: 'service discovery'
when:
- ansible_system == 'Linux'
- services is not defined
ansible.builtin.service_facts:
- name: 'ensure packages'
when:
- ansible_system == 'Linux'
- ensure_os_patch is defined
- ensure_os_patch.package_list is defined
- ensure_os_patch.package_list is iterable
ansible.builtin.package:
name: '{{ item.name }}'
state: '{{ item.state }}'
loop: '{{ ensure_os_patch.package_list }}'
loop_control:
label: '{{ item.name }} will be {{ item.state }}'
notify:
- 'ensure_os_patch.package_facts'
- 'ensure_os_patch.service_facts'
- name: 'ensure Debian patch'
when:
- ansible_system == 'Linux'
- ansible_pkg_mgr == 'apt'
ansible.builtin.apt:
autoclean: 'yes'
autoremove: 'yes'
upgrade: 'dist'
notify:
- 'ensure_os_patch.package_facts'
- 'ensure_os_patch.service_facts'
- name: 'ensure services'
when:
- ansible_system == 'Linux'
- ensure_os_patch is defined
- ensure_os_patch.service_list is defined
- ensure_os_patch.service_list is iterable
ansible.builtin.service:
enabled: '{{ item.enabled }}'
name: '{{ item.name }}'
state: '{{ item.state }}'
loop: '{{ ensure_os_patch.service_list }}'
loop_control:
label: '{{ item.name }} will be {{ item.state }}'
notify:
- 'ensure_os_patch.package_facts'
- 'ensure_os_patch.service_facts'
- name: 'flush handlers'
meta: 'flush_handlers'