mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-05 09:45:13 +00:00
[PR #11879/77509be2 backport][stable-12] Replace .format() calls with f-strings across multiple plugins (#11881)
Replace .format() calls with f-strings across multiple plugins (#11879)
* Replace .format() calls with f-strings across multiple plugins
* Add changelog fragment for PR 11879
---------
(cherry picked from commit 77509be2aa)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6458abb9c1
commit
748882dfa8
15 changed files with 88 additions and 114 deletions
|
|
@ -63,17 +63,10 @@ def test_dzdo(mocker, parser, reset_cli_args):
|
|||
task["become_pass"] = "testpass"
|
||||
cmd = call_become_plugin(task, var_options, cmd=default_cmd, executable=default_exe)
|
||||
print(cmd)
|
||||
password_pattern = r"\"\[dzdo via ansible, key=.+?\] password:\""
|
||||
assert (
|
||||
re.match(
|
||||
"""{} {} -p {} -u {} {} -c 'echo {}; {}'""".format(
|
||||
dzdo_exe,
|
||||
dzdo_flags,
|
||||
r"\"\[dzdo via ansible, key=.+?\] password:\"",
|
||||
task["become_user"],
|
||||
default_exe,
|
||||
success,
|
||||
default_cmd,
|
||||
),
|
||||
f"""{dzdo_exe} {dzdo_flags} -p {password_pattern} -u {task["become_user"]} {default_exe} -c 'echo {success}; {default_cmd}'""",
|
||||
cmd,
|
||||
)
|
||||
is not None
|
||||
|
|
@ -112,17 +105,10 @@ def test_dzdo_varoptions(mocker, parser, reset_cli_args):
|
|||
var_options["ansible_become_pass"] = "testpass"
|
||||
cmd = call_become_plugin(task, var_options, cmd=default_cmd, executable=default_exe)
|
||||
print(cmd)
|
||||
password_pattern = r"\"\[dzdo via ansible, key=.+?\] password:\""
|
||||
assert (
|
||||
re.match(
|
||||
"""{} {} -p {} -u {} {} -c 'echo {}; {}'""".format(
|
||||
dzdo_exe,
|
||||
dzdo_flags,
|
||||
r"\"\[dzdo via ansible, key=.+?\] password:\"",
|
||||
var_options["ansible_become_user"],
|
||||
default_exe,
|
||||
success,
|
||||
default_cmd,
|
||||
),
|
||||
f"""{dzdo_exe} {dzdo_flags} -p {password_pattern} -u {var_options["ansible_become_user"]} {default_exe} -c 'echo {success}; {default_cmd}'""",
|
||||
cmd,
|
||||
)
|
||||
is not None
|
||||
|
|
|
|||
|
|
@ -50,17 +50,11 @@ def test_sudosu(mocker, parser, reset_cli_args):
|
|||
var_options = {}
|
||||
cmd = call_become_plugin(task, var_options, cmd=default_cmd, executable=default_exe)
|
||||
print(cmd)
|
||||
password_pattern = r"\[sudo via ansible, key=.+?\] password:"
|
||||
assert (
|
||||
re.match(
|
||||
"""{} {} -p "{}" su -l {} {} -c 'echo {}; {}'""".format(
|
||||
sudo_exe,
|
||||
sudo_flags.replace("-n", ""),
|
||||
r"\[sudo via ansible, key=.+?\] password:",
|
||||
task["become_user"],
|
||||
default_exe,
|
||||
success,
|
||||
default_cmd,
|
||||
),
|
||||
f"""{sudo_exe} {sudo_flags.replace("-n", "")} -p "{password_pattern}" """
|
||||
f"""su -l {task["become_user"]} {default_exe} -c 'echo {success}; {default_cmd}'""",
|
||||
cmd,
|
||||
)
|
||||
is not None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue