Skip to content

Commit

Permalink
handle jobs without credentials (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
ansibleguy committed Oct 6, 2024
1 parent 1334197 commit fb74490
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
25 changes: 13 additions & 12 deletions src/ansibleguy-webui/aw/execute/play_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _exec_log(execution: JobExecution, msg: str, level: int = 3):
)


def _commandline_arguments(job: Job, execution: JobExecution, creds: BaseJobCredentials) -> str:
def _commandline_arguments(job: Job, execution: JobExecution, creds: (BaseJobCredentials, None)) -> str:
cmd_arguments = []
if is_set(job.cmd_args):
cmd_arguments.append(job.cmd_args)
Expand All @@ -57,20 +57,21 @@ def _commandline_arguments(job: Job, execution: JobExecution, creds: BaseJobCred
else:
_exec_log(execution=execution, msg='Ignoring known_hosts file because it does not exist', level=5)

if is_set(creds.become_pass):
cmd_arguments.append('--ask-become-pass')
if is_set(creds):
if is_set(creds.become_pass):
cmd_arguments.append('--ask-become-pass')

if is_set(creds.become_user):
cmd_arguments.append(f'--become-user {creds.become_user}')
if is_set(creds.become_user):
cmd_arguments.append(f'--become-user {creds.become_user}')

if is_set(creds.connect_pass):
cmd_arguments.append('--ask-pass')
if is_set(creds.connect_pass):
cmd_arguments.append('--ask-pass')

if is_set(creds.connect_user):
cmd_arguments.append(f'--user {creds.connect_user}')
if is_set(creds.connect_user):
cmd_arguments.append(f'--user {creds.connect_user}')

if is_set(creds.vault_pass):
cmd_arguments.append('--ask-vault-pass')
if is_set(creds.vault_pass):
cmd_arguments.append('--ask-vault-pass')

return ' '.join(cmd_arguments)

Expand Down Expand Up @@ -129,7 +130,7 @@ def _execution_or_job(job: Job, execution: JobExecution, attr: str):


def _runner_options(
job: Job, execution: JobExecution, path_run: Path, project_dir: str, creds: BaseJobCredentials,
job: Job, execution: JobExecution, path_run: Path, project_dir: str, creds: (BaseJobCredentials, None),
) -> dict:
verbosity = None
if execution.verbosity != 0:
Expand Down
2 changes: 1 addition & 1 deletion src/ansibleguy-webui/aw/utils/util_no_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ def is_null(data) -> bool:
return str(data).strip() == ''


def is_set(data: str) -> bool:
def is_set(data) -> bool:
return not is_null(data)

0 comments on commit fb74490

Please sign in to comment.