Closed oupala closed 6 years ago
Ah, I see. Sorry, I hadn't even considered that. That can certainly be arranged!
The standalone script is now attached to all releases from 0.1.10 onward, along with a PGP signature. I hope you don't mind I also added the version number to the file name - let me know if that is a problem.
I understand that you added the version number in the filename so that each file can be signed individually.
But would it be possible to propose a standalone script without the version number in the filename? This makes my install process cleaner as my ansible playbook can now check if the file has changed before updating it:
If dest is a directory, the file will always be downloaded (regardless of the force option), but replaced only if the contents changed..
If yes and dest is not a directory, will download the file every time and replace the file if the contents change. If no, the file will only be downloaded if the destination does not exist.
Hm, I don't think I understand your use case. The whole point of downloading a new version is that the file has definitely changed, no?
Ok, I have to explain a bit more. Maybe you don't have experienced ansible, have you?
There is two way to download a file using the get_url module of ansible:
/usb/bin/gws
and another parameter force
tells ansible to download the file each time if force: true
or to download it only of the file does not exists if force: false
/usr/bin
and then ansible check if the file has changed or not before downloading it, but this way, the name of the file is the same as the name of the resource on the server (here: gws-0.2.0
)I really want to use the second solution, but I need the script to be name gws
without the version in its name, otherwise, it won't be easy to use.
Is it clearer with these explanations?
This second solution is the only way to achieve idempotency, which is a quite important feature of ansible.
Sorry, no, I have not used ansible. Ok, so if I try to enumerate the different combinations of options, as far as I can tell there are these possible scenarios. I will assume there is some way to substitue a version number into the url
option.
url: "https://github.com/StreakyCobra/gws/releases/download/$version/gws-$version", dest: "/usr/bin/"
/usr/bin/gws-$version
force
ignoredurl: "https://github.com/StreakyCobra/gws/releases/download/$version/gws-$version", dest: "/usr/bin/gws", force: "no"
/usr/bin/gws
url: "https://github.com/StreakyCobra/gws/releases/download/$version/gws-$version", dest: "/usr/bin/gws", force: "yes"
/usr/bin/gws
url: "https://github.com/StreakyCobra/gws/releases/download/$version/gws", dest: "/usr/bin/"
/usr/bin/gws
force
ignoredI'll assume you want the file to end up at /usr/bin/gws
, so option (1) is of course immediately disqualified, and option (2) is disqualified because it would not update the script to new releases. So far so good.
You are proposing option (4). However, I cannot tell a difference in effect between option (4) and option (3). Am I misreading the ansible docs?
Please know that I'm not trying to fight you - I'd be happy to be proven wrong and change my mind on this, but it currently seems to me like what you want to achieve is already possible.
I don't assume that you're trying to fight me. In fact, I do appreciate the way you try to analyze the situation, and possible solutions.
I'll try to explain the differences between (3) and (4).
For (3), replace only if contents changed is false, as force
is set to yes, the file will always be downloaded and the ansible task will always be reported as changed, or updated, whatever the file has really changed or not. From an ops view, it becomes hard to guess if the gws script has really changed or not. The task is always reported to be changed.
When an ansible task is idempotent, it is reported as changed the first time it is executed, but it should be reported as ok if the task is executed again. That's why (4) seems to be a better solution for ansible automation.
So are you saying that these two very similar statements in the docs mean different things?
dest
is a directory, the file will always be downloaded (regardless of the force
option), but replaced only if the contents changed.force
is] yes
and dest
is not a directory, will download the file every time and replace the file if the contents change.You make me doubt. I'll double check and come back here once tested...
I tested the two usecases and it appears that you were right.
I don't have anything to add except that your last statement was right, and that my task is idempotent.
Here is how I use ansible to install gws (just after installing git) on my servers:
- name: download gws script
get_url:
url: "{{ _git.gws_download_url }}"
dest: /home/{{ _git.user }}/bin/gws
force: yes
register: _gws_download_status
until: _gws_download_status | success
retries: 3
delay: 10
Thanks @emlun for finding the best solution with me!
Great! Glad I could help!
For version 0.1.8, it was possible to download the gws script only, with a well formed url.
Since version, 0.1.10, we can only download the whole source code, in a zip or in a tar.gz format. It is quite bad as we only need the gws script, not all the test and libs.
Do you think it could be possible to make the gws script available on its own for future versions?