From 9c57bb4f60e48925ef5ac5b466fd25808f295e6c Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Mon, 24 Nov 2025 21:21:29 +0100 Subject: [PATCH] [PR #11192/64dc009e backport][stable-12] solaris_zone: replace os.system() with run_command() (#11207) solaris_zone: replace os.system() with run_command() (#11192) * solaris_zone: replace os.system() with run_command() * add changelog frag (cherry picked from commit 64dc009ea754f4a41ac3dcc1d7291664dd31586e) Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --- changelogs/fragments/11192-solaris-zone-os-system.yml | 2 ++ plugins/modules/solaris_zone.py | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/11192-solaris-zone-os-system.yml diff --git a/changelogs/fragments/11192-solaris-zone-os-system.yml b/changelogs/fragments/11192-solaris-zone-os-system.yml new file mode 100644 index 0000000000..e4a131757f --- /dev/null +++ b/changelogs/fragments/11192-solaris-zone-os-system.yml @@ -0,0 +1,2 @@ +minor_changes: + - solaris_zone - execute external commands using Ansible construct (https://github.com/ansible-collections/community.general/pull/11192). diff --git a/plugins/modules/solaris_zone.py b/plugins/modules/solaris_zone.py index 78e1661e3e..09ccc6e508 100644 --- a/plugins/modules/solaris_zone.py +++ b/plugins/modules/solaris_zone.py @@ -309,12 +309,15 @@ class Zone: Wait until the zone's console login is running; once that's running, consider the zone booted. """ + zone_booted_re = re.compile(r"ttymon.*-d /dev/console") + cmd_ps = ["ps", "-z", self.name, "-o", "args"] + elapsed = 0 while True: if elapsed > self.timeout: self.module.fail_json(msg="timed out waiting for zone to boot") - rc = os.system(f'ps -z {self.name} -o args|grep "ttymon.*-d /dev/console" > /dev/null 2>/dev/null') - if rc == 0: + rc, out, err = self.module.run_command(cmd_ps, check_rc=False) + if any(zone_booted_re.match(x) for x in out.splitlines()): break time.sleep(10) elapsed += 10