Skip to content

Instantly share code, notes, and snippets.

@thomaslorentsen
Last active April 7, 2017 12:16
Show Gist options
  • Save thomaslorentsen/d0d689f7877df3a89a098641654145c0 to your computer and use it in GitHub Desktop.
Save thomaslorentsen/d0d689f7877df3a89a098641654145c0 to your computer and use it in GitHub Desktop.
Only install unzip if directories do not exist
---
- block:
- name: test files exist
stat:
path: "{{ item }}"
register: directory_exists
changed_when: directory_exists.stat.exists == false
with_items: "{{ target_directories }}"
- name: install unzip
package:
name: unzip
state: present
when: directory_exists.changed
- debug: msg="unzip will be removed at the end of play"
notify: remove unzip
changed_when: directory_exists.changed
...
---
dependencies:
- unzip:
role: common/unzip
target_directories:
- "/usr/java/{{ java.server_dir }}"
- "/usr/java/{{ java.server_dir }}/jre/lib/security"
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment