Skip to content

Commit

Permalink
Allow advanced commands after upload
Browse files Browse the repository at this point in the history
The command module does not support advanced Bash operations such as pipes (|), redirections, or if conditionals. That’s why the use of the shell module is necessary in this case.

My use case was: I need to restart a pacemaker resource after file upload and needed it to run only on node 1.
"if [[ $(hostname) == 'node1' ]] && crm_mon -1 | grep 'my_resource'; then crm_resource --resource my_resource --restart; fi"

Signed-off-by: Gabin LAURENT <[email protected]>
  • Loading branch information
Gabin-rte authored and insatomcat committed Oct 3, 2024
1 parent e4270d3 commit 4f2164e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion playbooks/seapath_setup_prerequisdebian.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@
- upload_files is defined
- item.extract is defined and item.extract is true
- name: run extra commands after upload
command: "{{ item }}"
shell: "{{ item }}"
tags:
- skip_ansible_lint
loop: "{{ commands_to_run_after_upload }}"
when: commands_to_run_after_upload is defined

Expand Down

0 comments on commit 4f2164e

Please sign in to comment.