I always wonder what is the good way to replace the following shell
tasks using the "ansible way" (with get_url
, etc.):
- name: Install oh-my-zsh
shell: wget -qO - https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | bash -
or
- name: Install nodesource repo
shell: curl -sL https://deb.nodesource.com/setup_5.x | bash -
@RaviTezu solution doesn't work because the file/script that you wish to execute must be on the machine where you execute your play/role.
As per the documentation here
So one way to do it is by downloading the file locally and using a task like below:
Or you can do this:
I would go for the first method if you are uploading your own script, the second method is more useful in your case because the script might gets updated in time so you are sure each time you execute it it uses the latest script.
May be this basic example can help you to start:
For example:
For me, the following statement worked:
Note the: "force=yes", which will always download the script, overriding the old one. Also note the "changed_when", which you can refine per your case.
This worked for me: