Skip to content

Commit

Permalink
add check for valid host
Browse files Browse the repository at this point in the history
Host validity is now verified before building the ansible-runner command,
thus any operation on 'host' property is done on a non-null object
  • Loading branch information
dangel101 authored and mwperina committed Aug 4, 2022
1 parent 6dc9bf8 commit f7561f9
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ public AnsibleReturnValue runCommand(AnsibleCommandConfig command,
}

public AnsibleReturnValue runCommand(AnsibleCommandConfig commandConfig, int timeout, BiConsumer<String, String> fn, boolean async) {
if (commandConfig.host() == null) {
throw new AnsibleRunnerCallException("Invalid host");
}
if (timeout <= 0) {
timeout = EngineLocalConfig.getInstance().getInteger("ANSIBLE_PLAYBOOK_EXEC_DEFAULT_TIMEOUT");
}
Expand Down Expand Up @@ -195,12 +198,6 @@ public AnsibleReturnValue runCommand(AnsibleCommandConfig commandConfig, int tim
}

private AuditLogable createAuditLogable(AnsibleCommandConfig command, String taskName) {
if (command.host() == null) {
return AuditLogableImpl.createEvent(
command.correlationId(),
Map.of("Message", taskName, "PlayAction", command.playAction())
);
}
return AuditLogableImpl.createHostEvent(
command.host(),
command.correlationId(),
Expand Down

0 comments on commit f7561f9

Please sign in to comment.