Skip to content

Instantly share code, notes, and snippets.

@psykidellic
Created January 3, 2014 22:15
Show Gist options
  • Save psykidellic/8247707 to your computer and use it in GitHub Desktop.
Save psykidellic/8247707 to your computer and use it in GitHub Desktop.
---
- name: install elasticsearch prerequisties
apt: pkg=openjdk-7-jre-headless state=installed
- name: download deb file
get_url: url={{ elasticsearch.url }}/{{ elasticsearch.debian_package }} dest=/tmp
- name: install elasticsearch
shell: "dpkg -i /tmp/{{ elasticsearch.debian_package }}"
- name: remove the debian package
file: dest=/tmp/{{ elasticsearch.debian_package }}
@psykidellic
Copy link
Author

] Is there any canonical way to make this task idempotent? https://gist.github.com/psykidellic/8247707
[14:20:48] jergerber (textual@nat/rackspace/x-ljgohcvyzhhhbvyr) joined the channel.
[14:22:44] dragon3_ (~[email protected]) left IRC. (Ping timeout: 252 seconds)
[14:24:37] includex (~[email protected]) left IRC. (Ping timeout: 272 seconds)
[14:24:42] thaumos1 (~[email protected]) left IRC. (Quit: Leaving.)
[14:24:47] dcrouch (~[email protected]) left IRC. (Quit: This computer has gone to sleep)
[14:25:46] psykidellic: if you make the dest a file, rather than a dir, it will only download the file when it doesn't exist
[14:26:15] psykidellic: and you can then register a var there, and the the next set of tasks, you can do: when: registered_var|changed
[14:26:36] I see. This means though I have to keep the .deb file around in the location.
[14:26:37] ah, but I see you are removing the "tmp" file
[14:26:41] Yeah :)
[14:26:47] I mean its no big deal to leave it around…..
[14:26:54] guyver_ ([email protected]) left IRC. (Remote host closed the connection)
[14:26:55] but then i fear somebody deletes the file
[14:26:58] and runs the provision again.
[14:27:01] psykidellic: your other option, is to add other checks, such as a 'stat' module call, to check for a file provided by the package
[14:27:03] tonyflint (~[email protected]) left IRC. (Ping timeout: 272 seconds)
[14:27:05] or something like that
[14:27:12] and register a var then, and only act when you need to
[14:27:17] based on some logic you define
[14:27:19] Okay.
[14:27:25] I will look into the second option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment