Skip to content
Open
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
> [!TIP]
> This fork main purpose is to forward the RUNDECK variables (such as RD_JOB_USERNAME, etc.) to the Ansible playbook. One reason is to give the ansible playbook the ability to proper identify who is running the playbook.

---

[![Gitter](https://img.shields.io/gitter/room/rundeck-ansible-plugin/Lobby.svg)](https://gitter.im/rundeck-ansible-plugin/Lobby) [Read more about Rundeck + Ansible](https://www.rundeck.com/ansible)

Please [report](https://github.com/rundeck-plugins/ansible-plugin/issues) any errors or suggestions!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ public static AnsibleRunner buildAnsibleRunner(AnsibleRunnerContextBuilder conte
// set rundeck options as environment variables
Map<String,String> options = contextBuilder.getListOptions();
if (options != null) {
//also add all the job options
options.putAll(contextBuilder.getJobOptions());
ansibleRunnerBuilder.options(options);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -833,4 +833,15 @@ public Map<String,String> getListOptions(){
}
return options;
}

public Map<String,String> getJobOptions(){
Map<String, String> options = new HashMap<>();
Map<String, String> jobOptions = context.getDataContext().get("job");
for (Map.Entry<String, String> entry : jobOptions.entrySet()) {
if(entry.getValue() != null) {
options.put("RD_JOB_" + entry.getKey().toUpperCase(), entry.getValue());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#424 (comment)

looks like you need to look for a NullPointer here (it will fail in the GH actions tests as well)

}
}
return options;
}
}