Files
env-ansible/tasks/general/tests/services.yml
T
2026-07-31 12:56:53 -07:00

38 lines
1.4 KiB
YAML

---
# List all the services under the Reports folder.
- name: General | Tests | Services | Set Facts
set_fact:
services_report_file: "{{ user_user.home }}/Reports/{{ ansible_hostname }}.services.txt"
services_enabled_file: "{{ user_user.home }}/Reports/{{ ansible_hostname }}.services-enabled.txt"
services_command: "echo 'Service Manager {{ ansible_service_mgr }} Not Recognized'"
- name: General | Tests | Services | Set Facts | SystemD
set_fact:
services_command: "systemctl list-unit-files"
when: ansible_service_mgr == "systemd"
- name: General | Tests | Services | Set Facts | runit
set_fact:
services_command: 'for s in /var/service/*; do sv status "$s"; done'
when: ansible_service_mgr == "runit"
- name: General | Tests | Services | Create Main Report
shell: "{{ item }}"
loop:
- "date > {{ services_report_file }}"
- "echo '\n-= {{ services_command }} =-\n' >> {{ services_report_file }}"
- "{{ services_command }} >> {{ services_report_file }}"
- name: General | Tests | Services | Create Enabled Report
shell: "{{ item }}"
loop:
- "date > {{ services_enabled_file }}"
- "echo '\n-= Enabled + Sorted =-\n' >> {{ services_enabled_file }}"
- "grep 'enabled' {{ services_report_file }} | sort >> {{ services_enabled_file }}"
- name: General | Tests | Services | Make Viewable
file:
path: "{{ services_report_file }}"
mode: '0644'