You are welcome, however, keep in mind, that you might be better of migrating your script to an actual ansible module instead.
Anyway, make sure to mark my answer as a solution, if it is, so other forum users, can find it as well ;-)
Hey jonawang,
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/script_module.html
Regarding best practices, see the Notes section: "[...]It is usually preferable to write Ansible modules rather than pushing scripts. Convert your script to an Ansible module for bonus points![...]"
See also:
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/shell_module.html
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/command_module.html
Thanks, Alexander.
Before I asked this question, I were thinkg how to use command or shell module to achieve this purpose. As you mentioned, it sounds script module is more approriate for setting up executing shell scripts at remote servers.
Regards,
Jonathan
You are welcome, however, keep in mind, that you might be better of migrating your script to an actual ansible module instead.
Anyway, make sure to mark my answer as a solution, if it is, so other forum users, can find it as well ;-)
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.