Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
Add documentation for facts that require root or admin permissions. U…
Browse files Browse the repository at this point in the history
…pdate commands so they can be run with sudo. Closes #73.
  • Loading branch information
chambridge committed Jul 24, 2017
1 parent 4ba575a commit b32415a
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 9 deletions.
22 changes: 22 additions & 0 deletions doc/command_syntax_usage.rst
Expand Up @@ -148,3 +148,25 @@ scan identified by the timestamp.

For further details of the command usage view the following
`example <command_example.rst>`_.

^^^^^^^
Scan User Permissions
^^^^^^^
Some of the output facts will report an error if the user used to perform the
scan does not have the appropriate permissions to execute the command used to
gather the targeted facts. The following set of facts require *admin/root*
permissions to collect the facts:

- ``dmi.x``
- ``subman.x``
- ``virt-what.x``

The scan user can successful collect these values if the user is **root** or
has the ability to perform a ``sudo`` without a password. The following
provides the necessary content for the ``/etc/sudoers`` file where *scanuser*
represents the username used for the scan.

::

Cmnd_Alias SCAN = /sbin/subscription-manager, /usr/sbin/dmidecode, /usr/sbin/virt-what
scanuser ALL=NOPASSWD: SCAN
2 changes: 1 addition & 1 deletion module_utils/cpu_command.py
Expand Up @@ -69,7 +69,7 @@ def parse_data_cpu(self, results):
"""
data = {}
cpu_count = 0
process = sp.Popen("/usr/sbin/dmidecode -t 4",
process = sp.Popen("sudo -n /usr/sbin/dmidecode -t 4",
shell=True,
stdout=sp.PIPE,
stderr=sp.PIPE)
Expand Down
11 changes: 6 additions & 5 deletions module_utils/dmi_command.py
Expand Up @@ -42,16 +42,17 @@ def __init__(self):
self.cmd_names["bios_sys_manu"] = ['dmi.system-manufacturer']
self.cmd_names["bios_processor_fam"] = ['dmi.processor-family']

self.cmd_strings["bios_vendor"] = "/usr/sbin/dmidecode -s bios-vendor"
self.cmd_strings["bios_version"] = "/usr/sbin/dmidecode " \
self.cmd_strings["bios_vendor"] = "sudo -n /usr/sbin/dmidecode -s " \
"bios-vendor"
self.cmd_strings["bios_version"] = "sudo -n /usr/sbin/dmidecode " \
"-s bios-version"
self.cmd_strings["bios_sys_manu"] = (
"/usr/sbin/dmidecode "
"sudo -n /usr/sbin/dmidecode "
"| grep -A4 'System Information' "
"| grep 'Manufacturer' "
"| sed -n -e 's/^.*Manufacturer:\\s//p'")
self.cmd_strings["bios_processor_fam"] = "usr/sbin/dmidecode -s " \
"processor-family"
self.cmd_strings["bios_processor_fam"] = "sudo -n /usr/sbin/dmidecode"\
"-s processor-family"

def parse_data(self):
"""This method loops through all
Expand Down
2 changes: 1 addition & 1 deletion module_utils/subman_facts_command.py
Expand Up @@ -35,7 +35,7 @@ def __init__(self):
self.name = "subscription-manager"

self.cmd_strings["subman_facts_list"] \
= 'subscription-manager facts --list'
= 'sudo -n subscription-manager facts --list'
self.cmd_strings["subman_has_facts"] \
= 'ls /etc/rhsm/facts | grep .facts'

Expand Down
2 changes: 1 addition & 1 deletion module_utils/virt_command.py
Expand Up @@ -53,7 +53,7 @@ def __init__(self):
self.cmd_names["virt_running_list"] = ["virt.num_running_guests"]

self.cmd_strings["sys_manu"] = (
"/usr/sbin/dmidecode "
"sudo -n /usr/sbin/dmidecode "
"| grep -A4 'System Information' "
"| grep 'Manufacturer' "
"| sed -n -e 's/^.*Manufacturer:\\s//p'")
Expand Down
2 changes: 1 addition & 1 deletion module_utils/virt_what_command.py
Expand Up @@ -36,7 +36,7 @@ def __init__(self):

self.cmd_names["virt_what"] = ['virt-what.type']

cmd_string = "virt-what;echo $?"
cmd_string = "sudo -n virt-what;echo $?"
self.cmd_strings["virt_what"] = cmd_string

def parse_data(self):
Expand Down

0 comments on commit b32415a

Please sign in to comment.