From bb0ad70697b4d65ef23f25cbaad3b075b79f1a82 Mon Sep 17 00:00:00 2001 From: Shim Shtein Date: Thu, 20 Jun 2024 19:08:22 +0300 Subject: [PATCH] Add a template that enables download and execution of a script The main idea is to execute scripts from the Foreman server, similar to theforeman/foreman#10208. --- .../download_and_execute_script.erb | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 app/views/foreman_ansible/job_templates/download_and_execute_script.erb diff --git a/app/views/foreman_ansible/job_templates/download_and_execute_script.erb b/app/views/foreman_ansible/job_templates/download_and_execute_script.erb new file mode 100644 index 00000000..9ed7a25d --- /dev/null +++ b/app/views/foreman_ansible/job_templates/download_and_execute_script.erb @@ -0,0 +1,28 @@ +<%# +name: Download and execute a script +job_category: Ansible Commands +description_format: Download script from %{url} and execute it +snippet: false +template_inputs: +- name: url + required: true + input_type: user + description: "URL of the script to download e.g: http://example.com/unattended/anonymous/my_script" + advanced: false +provider_type: Ansible +kind: job_template +model: JobTemplate +%> + +--- +- hosts: all + tasks: + - uri: + url: <%= input("url") %> + return_content: true + register: script_response + - shell: + cmd: | + {{script_response.content}} + register: out + - debug: var=out