133 lines
4.7 KiB
YAML
133 lines
4.7 KiB
YAML
---
|
|
# Read-only capability discovery. This does not assign inventory groups.
|
|
- name: Windows | Detect AD DS feature (DC)
|
|
when: ansible_facts['os_family'] == "Windows"
|
|
ansible.windows.win_feature_info:
|
|
name: '{{ ad_ds_feature_name | default(''AD-Domain-Services'') }}'
|
|
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 | default(''DHCPServer'') }}'
|
|
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 | default(''VeeamBackupSvc'') }}'
|
|
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 | default(''Veeam.Archiver.Service'') }}'
|
|
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 | default(''VeeamEnterpriseManagerSvc'') }}'
|
|
register: _veeam_em
|
|
failed_when: false
|
|
- name: Windows | Detect Hyper-V feature
|
|
when: ansible_facts['os_family'] == "Windows"
|
|
ansible.windows.win_feature_info:
|
|
name: '{{ hyperv_feature_name | default(''Hyper-V'') }}'
|
|
register: _win_hyperv_feature
|
|
failed_when: false
|
|
- name: 'Windows | Fallback: check Hyper-V VMMS service'
|
|
when: ansible_facts['os_family'] == "Windows"
|
|
ansible.windows.win_service_info:
|
|
name: '{{ hyperv_vmms_service_name | default(''vmms'') }}'
|
|
register: _win_hyperv_vmms_svc
|
|
failed_when: false
|
|
- name: Windows | Set Veeam/DC/DHCP booleans (base)
|
|
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_feature.features | default([]))
|
|
| selectattr('installed')
|
|
| list
|
|
| length > 0
|
|
)
|
|
or
|
|
(_win_hyperv_vmms_svc.exists | default(false))
|
|
}}
|
|
- name: Windows | Debug summary
|
|
when:
|
|
- ansible_facts['os_family'] == "Windows"
|
|
- aim_debug | default(false) | bool
|
|
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 }}'
|
|
- name: Linux | Collect service facts
|
|
when: ansible_facts['os_family'] != "Windows"
|
|
ansible.builtin.service_facts: null
|
|
- name: Linux | Collect package facts
|
|
when: ansible_facts['os_family'] != "Windows"
|
|
ansible.builtin.package_facts:
|
|
manager: auto
|
|
- name: Linux | Set UniFi flags
|
|
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)
|
|
}}
|
|
is_unifi_os_server: |-
|
|
{{
|
|
'uosserver.service' in svcs
|
|
}}
|
|
- name: Linux | Debug summary
|
|
when:
|
|
- ansible_facts['os_family'] != "Windows"
|
|
- aim_debug | default(false) | bool
|
|
ansible.builtin.debug:
|
|
msg:
|
|
is_unifi_controller: '{{ is_unifi_controller }}'
|
|
is_unifi_os_server: '{{ is_unifi_os_server }}'
|
|
- 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_unifi_controller: '{{ is_unifi_controller | default(false) }}'
|
|
is_unifi_os_server: '{{ is_unifi_os_server | default(false) }}'
|
|
is_hyperv_host: '{{ is_hyperv_host | default(false) }}'
|