11
11
import java .io .IOException ;
12
12
import java .io .InputStream ;
13
13
import java .io .InputStreamReader ;
14
+ import java .nio .file .Path ;
15
+ import java .nio .file .Paths ;
14
16
import java .util .ArrayList ;
15
17
import java .util .HashMap ;
16
18
import java .util .List ;
21
23
public class AnsibleInventoryList {
22
24
23
25
private String inventory ;
26
+ private Path ansibleBinariesDirectory ;
24
27
private String configFile ;
25
28
private boolean debug ;
26
29
@@ -33,7 +36,7 @@ public class AnsibleInventoryList {
33
36
private File vaultPromptFile ;
34
37
private File tempLimitFile ;
35
38
36
- public static final String ANSIBLE_INVENTORY = "ansible-inventory" ;
39
+ public static final String ANSIBLE_INVENTORY_COMMAND = "ansible-inventory" ;
37
40
38
41
/**
39
42
* Executes Ansible command to bring all nodes from inventory
@@ -42,7 +45,11 @@ public class AnsibleInventoryList {
42
45
public String getNodeList () throws IOException , AnsibleException {
43
46
44
47
List <String > procArgs = new ArrayList <>();
45
- procArgs .add (ANSIBLE_INVENTORY );
48
+ String ansibleCommand = ANSIBLE_INVENTORY_COMMAND ;
49
+ if (ansibleBinariesDirectory !=null ) {
50
+ ansibleCommand = Paths .get (ansibleBinariesDirectory .toFile ().getAbsolutePath (), ansibleCommand ).toFile ().getAbsolutePath ();
51
+ }
52
+ procArgs .add (ansibleCommand );
46
53
//inventory can be defined in ansible.cfg
47
54
if (inventory !=null && !inventory .isEmpty ()){
48
55
procArgs .add ("--inventory-file" + "=" + inventory );
0 commit comments