262 lines
7.9 KiB
YAML
262 lines
7.9 KiB
YAML
---
|
|
|
|
###############################################
|
|
# Gather Facts for Playbook
|
|
###############################################
|
|
|
|
- name: run if gather_only
|
|
when: gather_only | bool
|
|
block:
|
|
|
|
- name: Check CPU Arch
|
|
shell: "dpkg --print-architecture"
|
|
register: cpu_architecture_output
|
|
|
|
- name: Set cpu_architecture variable
|
|
set_fact:
|
|
cpu_architecture: "{{ cpu_architecture_output.stdout_lines[0] }}"
|
|
|
|
# Install Prereq Packages
|
|
- name: Install Prereq Packages
|
|
when: not init_light | bool
|
|
apt:
|
|
name:
|
|
- "{{ gather_facts_packages_item }}"
|
|
state: present
|
|
loop: "{{ gather_facts_packages }}"
|
|
register: apt_result
|
|
loop_control:
|
|
loop_var: gather_facts_packages_item
|
|
|
|
- name: Apply permissions on /opt/cosmos
|
|
file:
|
|
path: /opt/cosmos
|
|
state: directory
|
|
mode: '0755'
|
|
|
|
###############################################
|
|
# Check for GPU
|
|
###############################################
|
|
|
|
- name: GPU - Gather information
|
|
command:
|
|
cmd: lshw -C display
|
|
register: lshw_output
|
|
|
|
- name: GPU - Set install_nvidia variable
|
|
set_fact:
|
|
install_nvidia: "{{ 'NVIDIA' in lshw_output.stdout }}"
|
|
|
|
###############################################
|
|
# Check for wireless network
|
|
###############################################
|
|
|
|
- name: WiFi - Gather devices
|
|
command: iw dev
|
|
register: iw_dev_output
|
|
changed_when: false
|
|
|
|
- name: WiFi - Set wireless_present variable
|
|
set_fact:
|
|
wireless_present: "{{ iw_dev_output.stdout is search('Interface') }}"
|
|
|
|
###############################################
|
|
# Check for realtek interfaces
|
|
###############################################
|
|
|
|
- name: Realtek - Gather devices
|
|
command: lspci -d10ec::02xx
|
|
register: lspci_rltk_output
|
|
ignore_errors: true
|
|
|
|
- name: skip when lspci fails
|
|
when: lspci_rltk_output.failed
|
|
block:
|
|
- name: Realtek - Set realtek_adapters variable
|
|
set_fact:
|
|
realtek_adapters: "{{ lspci_rltk_output.stdout_lines }}"
|
|
|
|
- name: Realtek - Set realtek_present variable
|
|
set_fact:
|
|
realtek_present: "{{ lspci_rltk_output.stdout != '' }}"
|
|
|
|
- name: Realtek - Gather devices again but different
|
|
command: lspci
|
|
register: lspci_rltk_output
|
|
ignore_errors: true
|
|
|
|
- name: check for rtl8821ce
|
|
when: '"RTL8821CE" in lspci_rltk_output'
|
|
set_fact:
|
|
rtl8821ce_present: true
|
|
|
|
###############################################
|
|
# Check for supported fingerprint sensor
|
|
###############################################
|
|
|
|
- name: Fingerprint - Fetch supported device list
|
|
shell: "curl -s {{ fprint_device_url }}"
|
|
register: website_content
|
|
|
|
- name: Fingerprint - Parse Website for Device IDs
|
|
set_fact:
|
|
device_list: "{{ website_content.stdout_lines | map('trim') | regex_findall('([0-9a-fA-F]{4}:[0-9a-fA-F]{4})') }}"
|
|
|
|
- name: Fingerprint - get lsusb output
|
|
command: lsusb
|
|
register: lsusb_output
|
|
ignore_errors: yes
|
|
|
|
- name: Fingerprint - Parse lsusb output for Device IDs
|
|
set_fact:
|
|
lsusb_devices: "{{ lsusb_output.stdout_lines | map('trim') | regex_findall('([0-9a-fA-F]{4}:[0-9a-fA-F]{4})') }}"
|
|
when: lsusb_output is defined
|
|
|
|
- name: Fingerprint - set fprint_sensor
|
|
set_fact:
|
|
fprint_sensor: "{{ lsusb_devices | intersect(device_list) }}"
|
|
when: lsusb_output is defined
|
|
|
|
- name: Fingerprint - prime fprint_present variable
|
|
set_fact:
|
|
fprint_present: false
|
|
|
|
- name: Fingerprint - set fprint_present variable
|
|
set_fact:
|
|
fprint_present: true
|
|
when: lsusb_devices | intersect(device_list) | length > 0 and lsusb_output is defined
|
|
|
|
- name: Fingerprint - display fact statements
|
|
debug:
|
|
msg: "{{ 'Compatible fingerprint sensor detected' if fprint_present else 'No compatible fingerprint sensor detected' }}"
|
|
|
|
###############################################
|
|
# Check if webcam is present
|
|
###############################################
|
|
|
|
- name: ustreamer - check for webcam
|
|
shell: "ls /dev/vid*"
|
|
register: vid_output
|
|
ignore_errors: yes
|
|
|
|
- name: ustreamer - set webcam_present variable
|
|
set_fact:
|
|
webcam_present: "{{ vid_output.rc == 0 }}"
|
|
|
|
- name: ustreamer - display fact statements
|
|
debug:
|
|
msg: "{{ 'Webcam present' if webcam_present else 'No webcam present' }}"
|
|
|
|
###############################################
|
|
# Check for supported howdycam
|
|
###############################################
|
|
|
|
- name: howdycam - get lsusb output
|
|
command: lsusb
|
|
register: lsusb_output
|
|
ignore_errors: yes
|
|
|
|
- name: howdycam - Parse lsusb output for Device IDs
|
|
set_fact:
|
|
lsusb_devices: "{{ lsusb_output.stdout_lines | map('trim') | regex_findall('([0-9a-fA-F]{4}:[0-9a-fA-F]{4})') }}"
|
|
when: lsusb_output is defined
|
|
|
|
- name: howdycam - set howdycam_deviceID
|
|
set_fact:
|
|
howdycam_deviceID: "{{ lsusb_devices | intersect(howdy_webcams) }}"
|
|
when: lsusb_output is defined
|
|
|
|
- name: howdycam - prime howdycam_present variable
|
|
set_fact:
|
|
howdycam_present: false
|
|
|
|
- name: howdycam - set howdycam_present variable
|
|
set_fact:
|
|
howdycam_present: true
|
|
when: lsusb_devices | intersect(howdy_webcams) | length > 0 and lsusb_output is defined
|
|
|
|
- name: howdycam - display fact statements
|
|
debug:
|
|
msg: "{{ 'Compatible biometric webcam detected' if howdycam_present else 'No compatible biometric webcam detected' }}"
|
|
|
|
###############################################
|
|
# Check if smb is configured
|
|
###############################################
|
|
|
|
- name: Check smb.conf
|
|
shell: |
|
|
cat /etc/samba/smb.conf | grep "matt-cloud default"
|
|
ignore_errors: yes
|
|
register: smbconf_output
|
|
|
|
- name: Set SMB Conf'd var
|
|
set_fact:
|
|
smb_configured: true
|
|
when: '"matt-cloud default" in smbconf_output.stdout'
|
|
ignore_errors: yes
|
|
|
|
- name: SMB - display fact statements
|
|
debug:
|
|
msg: "{{ 'SMB configured' if smb_configured else 'SMB not yet configured' }}"
|
|
|
|
###############################################
|
|
# Check client located at home
|
|
###############################################
|
|
|
|
- name: Check ip ad
|
|
shell: ip ad
|
|
register: ip_ad_output
|
|
|
|
- name: Check for terra
|
|
shell: dig +short terra.home.cosmos
|
|
register: dig_terra_output
|
|
|
|
- name: Set home location var
|
|
set_fact:
|
|
home_endpoint: true
|
|
when: '"172.20.255.255" in ip_ad_output.stdout and "172.20.25.10" in dig_terra_output.stdout'
|
|
|
|
- name: location check - display fact statements
|
|
debug:
|
|
msg: "{{ 'Endpoint at home' if home_endpoint else 'Remote endpoint' }}"
|
|
|
|
###############################################
|
|
# Output debug summary
|
|
###############################################
|
|
|
|
- name: Fact Summary - Set fact statements
|
|
set_fact:
|
|
system_info:
|
|
- "{{ 'NVIDIA GPU is present' if install_nvidia else 'No NVIDIA GPU found' }}"
|
|
- "{{ 'Wireless card present' if wireless_present else 'No Wireless Card' }}"
|
|
- "{{ 'Webcam is present' if webcam_present else 'No webcam present' }}"
|
|
- "{{ 'Realtek network card detected' if realtek_present else 'No realtek network devices detected' }}"
|
|
- "{{ 'Special Realtek wifi found' if rtl8821ce_present else 'No special realtek wifi' }}"
|
|
- "{{ 'Compatible fingerprint sensor detected' if fprint_present else 'No compatible fingerprint sensor detected' }}"
|
|
- "{{ 'Compatible biometric webcam detected' if howdycam_present else 'No compatible biometric webcam detected' }}"
|
|
- "{{ 'smb already configred' if smb_configured else 'smb not yet configured, will perform' }}"
|
|
- "CPU Architecture: {{ cpu_architecture }}"
|
|
- "{{ 'Endpoint located at home' if home_endpoint else 'endpoint not home, skipping matt profile setup' }}"
|
|
|
|
- name: Fact Summary - Collect booleans for test
|
|
set_fact:
|
|
system_bools:
|
|
- "{{ install_nvidia }}"
|
|
- "{{ wireless_present }}"
|
|
- "{{ webcam_present }}"
|
|
- "{{ realtek_present }}"
|
|
- "{{ rtl8821ce_present }}"
|
|
- "{{ fprint_present }}"
|
|
- "{{ howdycam_present }}"
|
|
- "{{ smb_configured }}"
|
|
- "{{ cpu_architecture }}"
|
|
- "{{ home_endpoint }}"
|
|
|
|
- name: Fact Summary - Output Summary
|
|
debug:
|
|
msg: "{{ system_info_item }}"
|
|
loop: "{{ system_info }}"
|
|
loop_control:
|
|
loop_var: system_info_item
|
|
|
|
... |