From 1beb4963dce5b0d9fb87fda7dda5dced62b451df Mon Sep 17 00:00:00 2001 From: jmanuelosunamoreno Date: Thu, 7 Nov 2024 14:18:24 -0300 Subject: [PATCH] remove duplicate code --- .../plugin/AnsibleResourceModelSource.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/main/groovy/com/rundeck/plugins/ansible/plugin/AnsibleResourceModelSource.java b/src/main/groovy/com/rundeck/plugins/ansible/plugin/AnsibleResourceModelSource.java index 4979d67..e1622c3 100644 --- a/src/main/groovy/com/rundeck/plugins/ansible/plugin/AnsibleResourceModelSource.java +++ b/src/main/groovy/com/rundeck/plugins/ansible/plugin/AnsibleResourceModelSource.java @@ -761,21 +761,18 @@ public String getNodesFromInventory(AnsibleRunner.AnsibleRunnerBuilder runnerBui AnsibleRunner runner = runnerBuilder.build(); if (this.ansibleInventoryListBuilder == null) { - if(ansibleBinariesDirectoryPath!=null && !ansibleBinariesDirectoryPath.isEmpty()){ - this.ansibleInventoryListBuilder = AnsibleInventoryList.builder() - .inventory(inventory) - .ansibleBinariesDirectory(java.nio.file.Path.of(ansibleBinariesDirectoryPath)) - .configFile(configFile) - .debug(debug); - } - else{ - this.ansibleInventoryListBuilder = AnsibleInventoryList.builder() - .inventory(inventory) - .configFile(configFile) - .debug(debug); - } + Path ansibleBinPath = null; + if (ansibleBinariesDirectoryPath != null && !ansibleBinariesDirectoryPath.isEmpty()) { + ansibleBinPath = (java.nio.file.Path.of(ansibleBinariesDirectoryPath)); } + this.ansibleInventoryListBuilder = AnsibleInventoryList.builder() + .inventory(inventory) + .ansibleBinariesDirectory(ansibleBinPath) + .configFile(configFile) + .debug(debug); + } + if(runner.getVaultPass() != null){ VaultPrompt vaultPrompt = VaultPrompt.builder() .vaultId("None")