Skip to content

Commit 427ec9b

Browse files
authored
Merge pull request #60 from UnsignedLong/feature/tag-per-resource
Feature/tag per resource
2 parents cf6865d + 2b8bdc3 commit 427ec9b

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/main/java/com/batix/rundeck/AnsibleResourceModelSource.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ public class AnsibleResourceModelSource implements ResourceModelSource {
2222
final String limit;
2323
final String extraArgs;
2424
final String ignoreTagPrefix;
25+
final String envTag;
2526

2627
public AnsibleResourceModelSource(Properties configuration) {
2728
gatherFacts = "true".equals(configuration.get("gatherFacts"));
2829
limit = (String) configuration.get("limit");
2930
extraArgs = (String) configuration.get("extraArgs");
3031
ignoreTagPrefix = (String) configuration.get("ignoreTagPrefix");
32+
envTag = (String) configuration.get("envTag");
3133
}
3234

3335
@Override
@@ -110,6 +112,9 @@ public INodeSet getNodes() throws ResourceModelSourceException {
110112
if (ignoreTagPrefix != null && ignoreTagPrefix.length() > 0 && ele.getAsString().startsWith(ignoreTagPrefix)) continue;
111113
tags.add(ele.getAsString());
112114
}
115+
if (envTag != null && envTag.length() > 0) {
116+
tags.add(envTag);
117+
}
113118
node.setTags(tags);
114119

115120
if (root.has("ansible_lsb")) {

src/main/java/com/batix/rundeck/AnsibleResourceModelSourceFactory.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ public Description getDescription() {
5454
"Leave blank to import all groups as tags or specify a prefix string, groups starting with this string won't be added as tags.",
5555
false,
5656
""
57+
)).property(PropertyUtil.string(
58+
"envTag",
59+
"Additional host tag",
60+
"This tag will be added to all hosts discovered by this source",
61+
false,
62+
""
5763
))
5864
.build();
5965
}

0 commit comments

Comments
 (0)