From 16c0136744bc7fdd07fc130e710b3b34033e664c Mon Sep 17 00:00:00 2001 From: Someone Date: Mon, 29 Apr 2024 10:46:28 +0200 Subject: [PATCH] [roles/custom-command] Execute custom command on host(s) --- roles/custom-command/tasks/main.yml | 14 ++++++++++++++ roles/custom-command/tasks/run-command.yml | 16 ++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 roles/custom-command/tasks/main.yml create mode 100644 roles/custom-command/tasks/run-command.yml diff --git a/roles/custom-command/tasks/main.yml b/roles/custom-command/tasks/main.yml new file mode 100644 index 0000000..4634bdb --- /dev/null +++ b/roles/custom-command/tasks/main.yml @@ -0,0 +1,14 @@ +##################################### +### someone's ansible provisioner ### +##################################### +# Part of: https://git.somenet.org/root/pub/somesible.git +# 2017-2024 by someone +# +# usage: ./run_somesible.sh -D --tags cc -e '{"cc":["id","uname -a"]}' +# +--- +- include_tasks: run-command.yml + with_items: "{{cc}}" + loop_control: + loop_var: cmd + when: cc is defined diff --git a/roles/custom-command/tasks/run-command.yml b/roles/custom-command/tasks/run-command.yml new file mode 100644 index 0000000..3088cb4 --- /dev/null +++ b/roles/custom-command/tasks/run-command.yml @@ -0,0 +1,16 @@ +##################################### +### someone's ansible provisioner ### +##################################### +# Part of: https://git.somenet.org/root/pub/somesible.git +# 2017-2024 by someone +# +--- +- name: run custom shell command "{{cmd}}" + shell: "{{cmd}}" + register: cmd_output + ignore_errors: True + + +- name: result of "{{cmd}}" + debug: + msg: "{{cmd_output.stdout_lines}}" -- 2.43.0