cancel
Showing results for 
Search instead for 
Did you mean: 
jonawang
Flight Engineer
Flight Engineer
  • 3,872 Views

In Ansible, how to execute shell scripts on a remote http server ?

Jump to solution

How to execute shell scripts on a remote server ? What is the best practice if there are mutiple ways ?

Thanks.

Labels (2)
0 Kudos
1 Solution

Accepted Solutions
tat
Flight Engineer Flight Engineer
Flight Engineer
  • 3,798 Views

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 ;-)

 

best regards,
Alexander

View solution in original post

0 Kudos
3 Replies
tat
Flight Engineer Flight Engineer
Flight Engineer
  • 3,846 Views

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

 

best regards,
Alexander
jonawang
Flight Engineer
Flight Engineer
  • 3,810 Views

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

tat
Flight Engineer Flight Engineer
Flight Engineer
  • 3,799 Views

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 ;-)

 

best regards,
Alexander
0 Kudos
Join the discussion
You must log in to join this conversation.