112 lines
3.7 KiB
YAML
112 lines
3.7 KiB
YAML
---
|
|
# ==========================
|
|
# WINDOWS DETECTION
|
|
# ==========================
|
|
- name: "Windows | Detect AD DS feature (DC)"
|
|
when: ansible_facts['os_family'] == "Windows"
|
|
ansible.windows.win_feature_info:
|
|
name: "{{ ad_ds_feature_name }}"
|
|
register: _win_dc_feature
|
|
failed_when: false
|
|
|
|
- name: "Windows | Fallback: check NTDS service (DC)"
|
|
when: ansible_facts['os_family'] == "Windows"
|
|
ansible.windows.win_service_info:
|
|
name: "NTDS"
|
|
register: _win_ntds_svc
|
|
failed_when: false
|
|
|
|
- name: "Windows | Check DHCP service"
|
|
when: ansible_facts['os_family'] == "Windows"
|
|
ansible.windows.win_service_info:
|
|
name: "{{ dhcp_windows_service_name }}"
|
|
register: _win_dhcp_svc
|
|
failed_when: false
|
|
|
|
- name: "Windows | Check Veeam VBR service"
|
|
when: ansible_facts['os_family'] == "Windows"
|
|
ansible.windows.win_service_info:
|
|
name: "{{ veeam_services.vbr }}"
|
|
register: _veeam_vbr
|
|
failed_when: false
|
|
|
|
- name: "Windows | Check Veeam VBO service"
|
|
when: ansible_facts['os_family'] == "Windows"
|
|
ansible.windows.win_service_info:
|
|
name: "{{ veeam_services.vbo }}"
|
|
register: _veeam_vbo
|
|
failed_when: false
|
|
|
|
- name: "Windows | Check Veeam Enterprise Manager service"
|
|
when: ansible_facts['os_family'] == "Windows"
|
|
ansible.windows.win_service_info:
|
|
name: "{{ veeam_services.em }}"
|
|
register: _veeam_em
|
|
failed_when: false
|
|
|
|
- name: "Windows | Check Hyper-V service"
|
|
when: ansible_facts['os_family'] == "Windows"
|
|
ansible.windows.win_service_info:
|
|
name: "vmms"
|
|
register: _win_hyperv_svc
|
|
failed_when: false
|
|
|
|
- name: "Windows | Set detection booleans"
|
|
when: ansible_facts['os_family'] == "Windows"
|
|
ansible.builtin.set_fact:
|
|
is_dc: >-
|
|
{{
|
|
(((_win_dc_feature.features | default([])) | selectattr('installed') | list | length) > 0)
|
|
or (_win_ntds_svc.exists | default(false))
|
|
}}
|
|
is_dhcp_server: "{{ _win_dhcp_svc.exists | default(false) }}"
|
|
has_veeam_vbr: "{{ _veeam_vbr.exists | default(false) }}"
|
|
has_veeam_vbo: "{{ _veeam_vbo.exists | default(false) }}"
|
|
has_veeam_em: "{{ _veeam_em.exists | default(false) }}"
|
|
is_hyperv_host: "{{ _win_hyperv_svc.exists | default(false) }}"
|
|
|
|
- name: "Windows | Debug summary"
|
|
when: ansible_facts['os_family'] == "Windows"
|
|
ansible.builtin.debug:
|
|
msg:
|
|
is_dc: "{{ is_dc }}"
|
|
is_dhcp_server: "{{ is_dhcp_server }}"
|
|
has_veeam_vbr: "{{ has_veeam_vbr }}"
|
|
has_veeam_vbo: "{{ has_veeam_vbo }}"
|
|
has_veeam_em: "{{ has_veeam_em }}"
|
|
is_hyperv_host: "{{ is_hyperv_host }}"
|
|
|
|
# ==========================
|
|
# LINUX DETECTION
|
|
# ==========================
|
|
- name: "Linux | Collect service facts"
|
|
when: ansible_facts['os_family'] != "Windows"
|
|
ansible.builtin.service_facts:
|
|
|
|
- name: "Linux | Collect package facts"
|
|
when: ansible_facts['os_family'] != "Windows"
|
|
ansible.builtin.package_facts:
|
|
manager: auto
|
|
|
|
- name: "Linux | Set UniFi flag"
|
|
when: ansible_facts['os_family'] != "Windows"
|
|
vars:
|
|
svcs: "{{ ansible_facts.services | default({}) }}"
|
|
pkgs: "{{ ansible_facts.packages | default({}) | list }}"
|
|
ansible.builtin.set_fact:
|
|
is_unifi_controller: >-
|
|
{{
|
|
(unifi_linux_services | select('in', svcs.keys()) | list | length > 0)
|
|
or (pkgs | intersect(unifi_linux_packages) | length > 0)
|
|
}}
|
|
|
|
- name: "Normalize detection booleans"
|
|
ansible.builtin.set_fact:
|
|
is_dc: "{{ is_dc | default(false) }}"
|
|
is_dhcp_server: "{{ is_dhcp_server | default(false) }}"
|
|
has_veeam_vbr: "{{ has_veeam_vbr | default(false) }}"
|
|
has_veeam_vbo: "{{ has_veeam_vbo | default(false) }}"
|
|
has_veeam_em: "{{ has_veeam_em | default(false) }}"
|
|
is_hyperv_host: "{{ is_hyperv_host | default(false) }}"
|
|
is_unifi_controller: "{{ is_unifi_controller | default(false) }}"
|