Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ansible: fix cluster upgrade #588

Merged
merged 1 commit into from
Aug 16, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,11 @@ private void createHostFile(File inventory) {
File hostFile = new File(String.format("%1$s/hosts", inventory));
try {
hostFile.createNewFile();
Files.write(hostFile.toPath(),
String.format(this.host.getHostName() + " ansible_port=%1$s", this.host.getSshPort()).getBytes());
if (host != null) {
// if VDS is null then playbook is running on engine and ansible uses localhost inventory automatically
Files.write(hostFile.toPath(),
String.format(this.host.getHostName() + " ansible_port=%1$s", this.host.getSshPort()).getBytes());
}
} catch (IOException ex) {
throw new AnsibleRunnerCallException(
String.format("Failed to create inventory file '%s':", hostFile.toString()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,6 @@ 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 @@ -198,6 +195,12 @@ 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