I need to run a few lines of shell on a remote system, and I find YAML more than awkward to use for this and would prefer to put this into a foo.sh.j2 file instead.
Now I could do the dance:
- stat to test if a remote directory exists
- create a remote temporary path if said directory does not exist
- run the template module with
foo.sh.j2into the remote temporary path if said directory does not exist - run
sh path/foo.shwith thecommandmodule if said directory does not exist, creating said directory - remove the remote temporary path if said directory did not exist
This is quite the overhead for something that ideally does get executed only once.
What I am really looking for is something like:
ansible.builtin.shell:
cmd_from_template: foo.sh.j2
creates: /path/to/said/directory
The foo.sh.j2 file needs to be evaluated locally, as is normal for templates; this is not a request to do that remotely.