From d6c81d26936a27f2010b9a69638d03903d600388 Mon Sep 17 00:00:00 2001 From: Marilen Corciovei Date: Sun, 31 Mar 2024 17:06:51 +0200 Subject: [PATCH 1/5] upgrade to 5.1.1 --- .../plugins/ansible/ansible/AnsibleRunner.java | 1 + .../ansible/ansible/AnsibleRunnerContextBuilder.java | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/main/groovy/com/rundeck/plugins/ansible/ansible/AnsibleRunner.java b/src/main/groovy/com/rundeck/plugins/ansible/ansible/AnsibleRunner.java index 3b8e7980..34b121b1 100644 --- a/src/main/groovy/com/rundeck/plugins/ansible/ansible/AnsibleRunner.java +++ b/src/main/groovy/com/rundeck/plugins/ansible/ansible/AnsibleRunner.java @@ -119,6 +119,7 @@ public static AnsibleRunner buildAnsibleRunner(AnsibleRunnerContextBuilder conte // set rundeck options as environment variables Map options = contextBuilder.getListOptions(); if (options != null) { + options.putAll(contextBuilder.getJobOptions()); ansibleRunnerBuilder.options(options); } diff --git a/src/main/groovy/com/rundeck/plugins/ansible/ansible/AnsibleRunnerContextBuilder.java b/src/main/groovy/com/rundeck/plugins/ansible/ansible/AnsibleRunnerContextBuilder.java index 77f3294f..80439ce9 100644 --- a/src/main/groovy/com/rundeck/plugins/ansible/ansible/AnsibleRunnerContextBuilder.java +++ b/src/main/groovy/com/rundeck/plugins/ansible/ansible/AnsibleRunnerContextBuilder.java @@ -833,4 +833,16 @@ public Map getListOptions(){ } return options; } + + public Map getJobOptions(){ + Map options = new HashMap<>(); + options.put("rundeckusername", context.getDataContext().get("job").get("username")); + + //also append all `job` env variables + Map jobOptions = context.getDataContext().get("job"); + for (Map.Entry entry : jobOptions.entrySet()) { + options.put("RD_JOB_" + entry.getKey().toUpperCase(), entry.getValue()); + } + return options; + } } From fc19aba82986e0c913a6a771dfdc94f5e7d00694 Mon Sep 17 00:00:00 2001 From: Marilen Corciovei Date: Sun, 31 Mar 2024 21:38:17 +0200 Subject: [PATCH 2/5] upgrade to 5.1.1 --- .../com/rundeck/plugins/ansible/ansible/AnsibleRunner.java | 1 + .../ansible/ansible/AnsibleRunnerContextBuilder.java | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/groovy/com/rundeck/plugins/ansible/ansible/AnsibleRunner.java b/src/main/groovy/com/rundeck/plugins/ansible/ansible/AnsibleRunner.java index 34b121b1..135fd438 100644 --- a/src/main/groovy/com/rundeck/plugins/ansible/ansible/AnsibleRunner.java +++ b/src/main/groovy/com/rundeck/plugins/ansible/ansible/AnsibleRunner.java @@ -119,6 +119,7 @@ public static AnsibleRunner buildAnsibleRunner(AnsibleRunnerContextBuilder conte // set rundeck options as environment variables Map options = contextBuilder.getListOptions(); if (options != null) { + //also add all the job options options.putAll(contextBuilder.getJobOptions()); ansibleRunnerBuilder.options(options); } diff --git a/src/main/groovy/com/rundeck/plugins/ansible/ansible/AnsibleRunnerContextBuilder.java b/src/main/groovy/com/rundeck/plugins/ansible/ansible/AnsibleRunnerContextBuilder.java index 80439ce9..93604dd6 100644 --- a/src/main/groovy/com/rundeck/plugins/ansible/ansible/AnsibleRunnerContextBuilder.java +++ b/src/main/groovy/com/rundeck/plugins/ansible/ansible/AnsibleRunnerContextBuilder.java @@ -836,12 +836,11 @@ public Map getListOptions(){ public Map getJobOptions(){ Map options = new HashMap<>(); - options.put("rundeckusername", context.getDataContext().get("job").get("username")); - - //also append all `job` env variables Map jobOptions = context.getDataContext().get("job"); for (Map.Entry entry : jobOptions.entrySet()) { - options.put("RD_JOB_" + entry.getKey().toUpperCase(), entry.getValue()); + if(entry.getValue() != null) { + options.put("RD_JOB_" + entry.getKey().toUpperCase(), entry.getValue()); + } } return options; } From 9ae2ae24c9f6d9c8132469f7be7cfcb19983365c Mon Sep 17 00:00:00 2001 From: Marilen Corciovei Date: Tue, 2 Jul 2024 12:32:19 +0200 Subject: [PATCH 3/5] update doc --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 1f9503f7..8d18aa74 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +> 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. +{.is-warning} + [![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! From d7ffe6cf025f8a585648860f68ec8c1b125278d0 Mon Sep 17 00:00:00 2001 From: Marilen Corciovei Date: Tue, 2 Jul 2024 12:33:27 +0200 Subject: [PATCH 4/5] update doc --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8d18aa74..9ba209e7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ +> [!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. -{.is-warning} [![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) From 0996c727ea734b34603d42c93a4c24683e9588b1 Mon Sep 17 00:00:00 2001 From: Marilen Corciovei Date: Tue, 2 Jul 2024 12:34:45 +0200 Subject: [PATCH 5/5] update doc --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 9ba209e7..00b87247 100644 --- a/README.md +++ b/README.md @@ -1,6 +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!