Skip to content

semodule not found in path when run from cron #271

@atvseth

Description

@atvseth

command: semodule -R

Running ansible via cron does not detect where semodule is located:

RUNNING HANDLER [fedora.linux_system_roles.selinux : Reload SELinux policy] ****
--
fatal: [localhost]: FAILED! => \{"changed": true, "cmd": "semodule -R", "msg": "[Errno 2] No such file or directory: b'semodule'", "rc": 2, "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
 
PLAY RECAP *********************************************************************
localhost                  : ok=232  changed=144  unreachable=0    failed=1    skipped=174  rescued=0    ignored=7

But if the code is changed to the following, there's no issue:

-  command: semodule -R
+  command: /usr/sbin/semodule -R

Result:

RUNNING HANDLER [fedora.linux_system_roles.selinux : Reload SELinux policy] ****
changed: [localhost]
... more lines ...
PLAY RECAP *********************************************************************
localhost                  : ok=247  changed=147  unreachable=0    failed=0    skipped=174  rescued=0    ignored=7   

A more future proof way might be to which semodule and use that output to run the command?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions