add function to get acpi power saving modes
This commit is contained in:
parent
51226ff994
commit
3e8e077164
@ -31,6 +31,12 @@ DOCUMENTATION = '''
|
||||
default: True
|
||||
description:
|
||||
- return a list of devices of the pci gpu class (0x030000)
|
||||
|
||||
acpi_power_modes:
|
||||
required: False
|
||||
default: True
|
||||
description:
|
||||
- return a list of supported acpi power saving modes
|
||||
notes:
|
||||
- requres python-pyusb and python-kmodpy
|
||||
requirements: [ ]
|
||||
@ -43,6 +49,7 @@ EXAMPLES = '''
|
||||
usb: True
|
||||
pci: True
|
||||
modules: True
|
||||
acpi_power_modes: True
|
||||
- debug:
|
||||
var: usb
|
||||
- debug
|
||||
@ -97,11 +104,21 @@ def format_gpu_device_list(iterator):
|
||||
"VendorID": d.idVendor, "ProductID": d.idProduct}
|
||||
return [entry for entry in get_entries(iterator)]
|
||||
|
||||
def list_acpi_power_modes():
|
||||
acpi_power_modes = []
|
||||
try:
|
||||
with open('/sys/power/state') as f:
|
||||
acpi_power_modes = [l for l in f.readline().split()]
|
||||
except IOError:
|
||||
pass
|
||||
return acpi_power_modes
|
||||
|
||||
arg_specs = {
|
||||
'usb': dict(default=True, type='bool', required=False),
|
||||
'pci': dict(default=True, type='bool', required=False),
|
||||
'modules': dict(default=True, type='bool', required=False),
|
||||
'gpus': dict(default=True, type='bool', required=False),
|
||||
'acpi_power_modes': dict(default=True, type='bool', required=False),
|
||||
}
|
||||
|
||||
|
||||
@ -111,24 +128,32 @@ def main():
|
||||
collect_pci = module.params['pci']
|
||||
collect_modules = module.params['modules']
|
||||
collect_gpus = module.params['gpus']
|
||||
collect_acpi_power_modes = module.params['acpi_power_modes']
|
||||
|
||||
usb_devices = []
|
||||
pci_devices = []
|
||||
modules = []
|
||||
gpus = []
|
||||
acpi_power_modes = []
|
||||
|
||||
if collect_usb:
|
||||
usb_devices = format_device_list(usb.core.find(find_all=True))
|
||||
else:
|
||||
usb_device = []
|
||||
|
||||
if collect_pci:
|
||||
pci_devices = format_device_list(get_pci_devices())
|
||||
else:
|
||||
pci_devices = []
|
||||
|
||||
if collect_modules:
|
||||
k = kmodpy.Kmod()
|
||||
modules = [m[0] for m in k.loaded()]
|
||||
else:
|
||||
modules = []
|
||||
|
||||
if collect_gpus:
|
||||
gpus = format_gpu_device_list(get_pci_devices())
|
||||
else:
|
||||
gpus = []
|
||||
data = {'usb': usb_devices, 'pci': pci_devices, 'modules': modules, 'gpus': gpus}
|
||||
|
||||
if collect_acpi_power_modes:
|
||||
acpi_power_modes = list_acpi_power_modes()
|
||||
|
||||
data = {'usb': usb_devices, 'pci': pci_devices, 'modules': modules, 'gpus': gpus,
|
||||
'acpi_power_modes': acpi_power_modes}
|
||||
module.exit_json(changed=False, ansible_facts=data, msg=data)
|
||||
|
||||
|
||||
|
17
roles/yavdr-common/tasks/configure_apt.yml
Normal file
17
roles/yavdr-common/tasks/configure_apt.yml
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
|
||||
- name: apt | prevent automatic installation of recommended packages
|
||||
template:
|
||||
src: templates/90-norecommends.j2
|
||||
dest: /etc/apt/apt.conf.d/90norecommends
|
||||
- name: add PPAs
|
||||
apt_repository:
|
||||
repo: '{{ item }}'
|
||||
state: present
|
||||
update_cache: yes
|
||||
with_items: '{{ repositories }}'
|
||||
|
||||
- name: run apt-get dist-upgrade
|
||||
apt:
|
||||
upgrade: dist
|
||||
update_cache: yes
|
57
roles/yavdr-common/tasks/configure_system.yml
Normal file
57
roles/yavdr-common/tasks/configure_system.yml
Normal file
@ -0,0 +1,57 @@
|
||||
- name: use bash instead of dash
|
||||
shell: |
|
||||
echo "set dash/sh false" | debconf-communicate
|
||||
dpkg-reconfigure -f noninteractive dash
|
||||
- name: create vdr group
|
||||
group:
|
||||
gid: '{{ vdr.gid }}'
|
||||
state: present
|
||||
name: '{{ vdr.group }}'
|
||||
|
||||
- name: create vdr user
|
||||
user:
|
||||
name: '{{ vdr.user }}'
|
||||
group: '{{ vdr.group }}'
|
||||
uid: '{{ vdr.uid }}'
|
||||
home: '{{ vdr.home }}'
|
||||
shell: '/bin/bash'
|
||||
state: present
|
||||
append: true
|
||||
- name: disable release-upgrade notifications
|
||||
lineinfile:
|
||||
dest: /etc/update-manager/release-upgrades
|
||||
backrefs: yes
|
||||
state: present
|
||||
regexp: '^(Prompt=).*$'
|
||||
line: '\1never'
|
||||
- name: apt | install basic packages
|
||||
apt:
|
||||
name: '{{ item }}'
|
||||
state: present
|
||||
install_recommends: no
|
||||
with_items:
|
||||
- anacron
|
||||
- acl
|
||||
- at
|
||||
- bash-completion
|
||||
#- biosdevname # caution: may change device names after a minimal installation!
|
||||
- debconf-utils
|
||||
- linux-firmware
|
||||
- psmisc
|
||||
- python-kmodpy
|
||||
- python-requests
|
||||
- python-usb
|
||||
- python3-usb
|
||||
- software-properties-common
|
||||
- ssh
|
||||
- wget
|
||||
- wpasupplicant
|
||||
- usbutils
|
||||
- xfsprogs
|
||||
- name: apt | install extra packages
|
||||
apt:
|
||||
name: '{{ item }}'
|
||||
state: present
|
||||
install_recommends: no
|
||||
with_items:
|
||||
'{{ extra_packages }}'
|
8
roles/yavdr-common/tasks/create_directories.yml
Normal file
8
roles/yavdr-common/tasks/create_directories.yml
Normal file
@ -0,0 +1,8 @@
|
||||
- name: create media directories
|
||||
file:
|
||||
dest: '{{ item.value }}'
|
||||
owner: '{{ vdr.user }}'
|
||||
group: '{{ vdr.group }}'
|
||||
state: directory
|
||||
mode: '0777'
|
||||
with_dict: '{{ media_dirs }}'
|
15
roles/yavdr-common/tasks/gather_facts.yml
Normal file
15
roles/yavdr-common/tasks/gather_facts.yml
Normal file
@ -0,0 +1,15 @@
|
||||
- name: get information about usb and pci hardware and loaded kernel modules
|
||||
hardware_facts:
|
||||
usb: True
|
||||
pci: True
|
||||
modules: True
|
||||
gpus: True
|
||||
|
||||
- debug:
|
||||
var: '{{ item }}'
|
||||
verbosity: 1
|
||||
with_items:
|
||||
- usb
|
||||
- pci
|
||||
- gpus
|
||||
- modules
|
Loading…
Reference in New Issue
Block a user