refactor: use module.run_command instead of subprocess

Ansible modules should use module.run_command instead of subprocess.
This is flagged by the latest ansible-test

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
This commit is contained in:
Rich Megginson 2026-04-02 09:04:13 -06:00 committed by Richard Megginson
parent 2044cbf239
commit d56563dc16

View file

@ -67,7 +67,6 @@ import os
import re
import shlex
import socket
import subprocess
import time
import traceback
import logging
@ -2684,7 +2683,8 @@ class Cmd_initscripts(Cmd):
present and did not save any state about the corresponding interface.
"""
try:
subprocess.call(
# run_command returns rc, stdout, and stderr but we don't need them
_rc, _stdout, _stderr = self.run_env.run_command(
[
"busctl",
"--system",
@ -2696,7 +2696,8 @@ class Cmd_initscripts(Cmd):
"as",
"1",
path,
]
],
handle_exceptions=False,
)
except Exception:
pass