Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/pyinfra_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import sys
import warnings
from fnmatch import fnmatch
from getpass import getpass
from os import chdir as os_chdir, getcwd, path
from typing import Iterable, List, Tuple, Union

Expand Down Expand Up @@ -82,6 +83,12 @@ def _print_support(ctx, param, value):
envvar="PYINFRA_YES",
show_envvar=True,
)
@click.option(
"--same-sudo-password",
is_flag=True,
default=False,
help="All hosts have the same sudo password, so ask only once.",
)
@click.option(
"--limit",
help="Restrict the target hosts by name and group name.",
Expand Down Expand Up @@ -274,6 +281,7 @@ def _main(
ssh_key,
ssh_key_password: str,
ssh_password: str,
same_sudo_password: bool,
shell_executable,
sudo: bool,
sudo_user: str,
Expand Down Expand Up @@ -344,6 +352,9 @@ def _main(
ssh_password,
)

if same_sudo_password:
config.SUDO_PASSWORD = getpass("sudo password: ")

if yes is False:
_set_fail_prompts(state, config)

Expand Down
1 change: 1 addition & 0 deletions tests/test_cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def test_deploy_operation_direct(self):
ssh_key=None,
ssh_key_password=None,
ssh_password=None,
same_sudo_password=False,
sudo=False,
sudo_user=None,
use_sudo_password=False,
Expand Down