Skip to content

Commit 0b6c7dd

Browse files
committed
reverted back to node exec and project config file
1 parent d6635a3 commit 0b6c7dd

4 files changed

Lines changed: 81 additions & 51 deletions

File tree

src/main/groovy/com/rundeck/plugins/ansible/ansible/AnsibleRunnerContextBuilder.java

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -612,16 +612,6 @@ public Boolean generateInventory() {
612612
generateInventory = Boolean.parseBoolean(sgenerateInventory);
613613
}
614614

615-
// Fallback to plugin group configuration if not set
616-
if (generateInventory == null || !generateInventory) {
617-
if (this.pluginGroup != null && this.pluginGroup.getGenerateInventory() != null && this.pluginGroup.getGenerateInventory()) {
618-
this.context.getExecutionLogger().log(
619-
4, "plugin group set getGenerateInventory: " + this.pluginGroup.getGenerateInventory()
620-
);
621-
generateInventory = this.pluginGroup.getGenerateInventory();
622-
}
623-
}
624-
625615
return generateInventory;
626616
}
627617

@@ -798,14 +788,14 @@ public void cleanupTempFiles() {
798788
System.err.println("DEBUG: Execution-specific directory exists: " + executionSpecificDir.getAbsolutePath());
799789
}
800790
if (!getDebug()) {
801-
System.err.println("DEBUG: Deleting execution-specific directory recursively");
802791
deleteDirectoryRecursively(executionSpecificDir);
803-
System.err.println("DEBUG: Execution-specific directory deleted");
804792
} else {
805793
System.err.println("DEBUG: Skipping cleanup due to debug mode");
806794
}
807795
} else {
808-
System.err.println("DEBUG: No execution-specific directory to cleanup");
796+
if (getDebug()) {
797+
System.err.println("DEBUG: No execution-specific directory to cleanup");
798+
}
809799
}
810800
}
811801

@@ -1018,17 +1008,39 @@ public List<String> getListNodesKeyPath(){
10181008

10191009

10201010
public Boolean generateInventoryNodesAuth() {
1021-
// Only use plugin group configuration
1022-
if (this.pluginGroup != null && this.pluginGroup.getGenerateInventoryNodesAuth() != null) {
1023-
Boolean generateInventoryNodesAuth = this.pluginGroup.getGenerateInventoryNodesAuth();
1024-
this.context.getExecutionLogger().log(
1025-
4, "Using plugin group configuration for generateInventoryNodesAuth: " + generateInventoryNodesAuth
1026-
);
1027-
return generateInventoryNodesAuth;
1011+
Boolean generateInventoryNodesAuth = null;
1012+
1013+
if(getDebug()) {
1014+
System.err.println("DEBUG: Resolving property ANSIBLE_GENERATE_INVENTORY_NODES_AUTH");
1015+
System.err.println("DEBUG: Property key: " + AnsibleDescribable.ANSIBLE_GENERATE_INVENTORY_NODES_AUTH);
1016+
System.err.println("DEBUG: Framework project: " + getFrameworkProject());
10281017
}
10291018

1030-
// Default to false if not configured
1031-
return false;
1019+
String sgenerateInventoryNodesAuth = PropertyResolver.resolveProperty(
1020+
AnsibleDescribable.ANSIBLE_GENERATE_INVENTORY_NODES_AUTH,
1021+
null,
1022+
getFrameworkProject(),
1023+
getFramework(),
1024+
getNode(),
1025+
getJobConf()
1026+
);
1027+
1028+
if(getDebug()) {
1029+
System.err.println("DEBUG: PropertyResolver returned: " + sgenerateInventoryNodesAuth);
1030+
}
1031+
1032+
if (null != sgenerateInventoryNodesAuth) {
1033+
generateInventoryNodesAuth = Boolean.parseBoolean(sgenerateInventoryNodesAuth);
1034+
if(getDebug()) {
1035+
System.err.println("DEBUG: Parsed to boolean: " + generateInventoryNodesAuth);
1036+
}
1037+
} else {
1038+
if(getDebug()) {
1039+
System.err.println("DEBUG: Property not found, returning null");
1040+
}
1041+
}
1042+
1043+
return generateInventoryNodesAuth;
10321044
}
10331045

10341046
/**
@@ -1068,7 +1080,9 @@ private String getExecutionSpecificTmpDir() {
10681080
}
10691081
executionSpecificDir.mkdirs();
10701082
} else {
1071-
System.err.println("DEBUG: Execution-specific directory already exists: " + executionSpecificDir.getAbsolutePath());
1083+
if (getDebug()) {
1084+
System.err.println("DEBUG: Execution-specific directory already exists: " + executionSpecificDir.getAbsolutePath());
1085+
}
10721086
}
10731087
return executionSpecificDir.getAbsolutePath();
10741088
}

src/main/groovy/com/rundeck/plugins/ansible/plugin/AnsiblePlaybookInlineWorkflowStep.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public class AnsiblePlaybookInlineWorkflowStep implements StepPlugin, AnsibleDes
7070
// Project and framework level mappings for inventory generation
7171
builder.mapping(ANSIBLE_GENERATE_INVENTORY, PROJ_PROP_PREFIX + ANSIBLE_GENERATE_INVENTORY);
7272
builder.frameworkMapping(ANSIBLE_GENERATE_INVENTORY, FWK_PROP_PREFIX + ANSIBLE_GENERATE_INVENTORY);
73+
builder.mapping(ANSIBLE_GENERATE_INVENTORY_NODES_AUTH, PROJ_PROP_PREFIX + ANSIBLE_GENERATE_INVENTORY_NODES_AUTH);
74+
builder.frameworkMapping(ANSIBLE_GENERATE_INVENTORY_NODES_AUTH, FWK_PROP_PREFIX + ANSIBLE_GENERATE_INVENTORY_NODES_AUTH);
7375

7476
DESC = builder.build();
7577
}
@@ -107,11 +109,31 @@ public void executeStep(PluginStepContext context, Map<String, Object> configura
107109
runner = AnsibleRunner.buildAnsibleRunner(contextBuilder);
108110

109111
Boolean generateInventoryNodeAuth = contextBuilder.generateInventoryNodesAuth();
112+
113+
boolean isDebug = context.getDataContext().get("job").get("loglevel").equals("DEBUG");
114+
115+
if(isDebug) {
116+
System.err.println("DEBUG: generateInventoryNodesAuth returned: " + generateInventoryNodeAuth);
117+
}
118+
110119
if(generateInventoryNodeAuth != null && generateInventoryNodeAuth){
120+
if(isDebug) {
121+
System.err.println("DEBUG: Node auth is enabled, getting authentication map");
122+
}
111123
Map<String, Map<String, String>> nodesAuth = contextBuilder.getNodesAuthenticationMap();
124+
if(isDebug) {
125+
System.err.println("DEBUG: Retrieved " + (nodesAuth != null ? nodesAuth.size() : 0) + " node authentications");
126+
}
112127
if (nodesAuth != null && !nodesAuth.isEmpty()) {
113128
runner.setAddNodeAuthToInventory(true);
114129
runner.setNodesAuthentication(nodesAuth);
130+
if(isDebug) {
131+
System.err.println("DEBUG: Set node authentication on runner");
132+
}
133+
}
134+
} else {
135+
if(isDebug) {
136+
System.err.println("DEBUG: Node auth is NOT enabled");
115137
}
116138
}
117139

src/main/groovy/com/rundeck/plugins/ansible/plugin/AnsiblePlaybookWorkflowStep.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public class AnsiblePlaybookWorkflowStep implements StepPlugin, AnsibleDescribab
6868
// Project and framework level mappings for inventory generation
6969
builder.mapping(ANSIBLE_GENERATE_INVENTORY, PROJ_PROP_PREFIX + ANSIBLE_GENERATE_INVENTORY);
7070
builder.frameworkMapping(ANSIBLE_GENERATE_INVENTORY, FWK_PROP_PREFIX + ANSIBLE_GENERATE_INVENTORY);
71+
builder.mapping(ANSIBLE_GENERATE_INVENTORY_NODES_AUTH, PROJ_PROP_PREFIX + ANSIBLE_GENERATE_INVENTORY_NODES_AUTH);
72+
builder.frameworkMapping(ANSIBLE_GENERATE_INVENTORY_NODES_AUTH, FWK_PROP_PREFIX + ANSIBLE_GENERATE_INVENTORY_NODES_AUTH);
7173

7274
DESC = builder.build();
7375
}
@@ -104,11 +106,31 @@ public void executeStep(PluginStepContext context, Map<String, Object> configura
104106
runner = AnsibleRunner.buildAnsibleRunner(contextBuilder);
105107

106108
Boolean generateInventoryNodeAuth = contextBuilder.generateInventoryNodesAuth();
109+
110+
boolean isDebug = context.getDataContext().get("job").get("loglevel").equals("DEBUG");
111+
112+
if(isDebug) {
113+
System.err.println("DEBUG: generateInventoryNodesAuth returned: " + generateInventoryNodeAuth);
114+
}
115+
107116
if(generateInventoryNodeAuth != null && generateInventoryNodeAuth){
117+
if(isDebug) {
118+
System.err.println("DEBUG: Node auth is enabled, getting authentication map");
119+
}
108120
Map<String, Map<String, String>> nodesAuth = contextBuilder.getNodesAuthenticationMap();
121+
if(isDebug) {
122+
System.err.println("DEBUG: Retrieved " + (nodesAuth != null ? nodesAuth.size() : 0) + " node authentications");
123+
}
109124
if (nodesAuth != null && !nodesAuth.isEmpty()) {
110125
runner.setAddNodeAuthToInventory(true);
111126
runner.setNodesAuthentication(nodesAuth);
127+
if(isDebug) {
128+
System.err.println("DEBUG: Set node authentication on runner");
129+
}
130+
}
131+
} else {
132+
if(isDebug) {
133+
System.err.println("DEBUG: Node auth is NOT enabled");
112134
}
113135
}
114136

src/main/groovy/com/rundeck/plugins/ansible/plugin/AnsiblePluginGroup.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,6 @@ public void setEncryptExtraVars(Boolean encryptExtraVars) {
3939
this.encryptExtraVars = encryptExtraVars;
4040
}
4141

42-
public Boolean getGenerateInventory() {
43-
return generateInventory;
44-
}
45-
46-
public void setGenerateInventory(Boolean generateInventory) {
47-
this.generateInventory = generateInventory;
48-
}
49-
50-
public Boolean getGenerateInventoryNodesAuth() {
51-
return generateInventoryNodesAuth;
52-
}
53-
54-
public void setGenerateInventoryNodesAuth(Boolean generateInventoryNodesAuth) {
55-
this.generateInventoryNodesAuth = generateInventoryNodesAuth;
56-
}
57-
5842
@PluginProperty(
5943
title = "Ansible config file path",
6044
description = "Set ansible config file path."
@@ -73,18 +57,6 @@ public void setGenerateInventoryNodesAuth(Boolean generateInventoryNodesAuth) {
7357
)
7458
Boolean encryptExtraVars;
7559

76-
@PluginProperty(
77-
title = "Generate inventory",
78-
description = "Generate an Ansible inventory from the targeted nodes."
79-
)
80-
Boolean generateInventory;
81-
82-
@PluginProperty(
83-
title = "Generate inventory with node authentication",
84-
description = "Add node-specific authentication credentials to the generated inventory via group_vars."
85-
)
86-
Boolean generateInventoryNodesAuth;
87-
8860
@Override
8961
public Description getDescription() {
9062
DescriptionBuilder builder = DescriptionBuilder.builder();

0 commit comments

Comments
 (0)