Skip to content

Commit

Permalink
Adding S3 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
“Justin committed May 17, 2017
1 parent 0c9923d commit dc54ad7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ Example Playbook
- role: AnsibleShipyard.ansible-zookeeper
```
Example Retrieving Tarball From S3
----------------------------------
```yaml
- name: Installing ZooKeeper
hosts: all
sudo: yes
vars:
zookeeper_archive_s3_bucket: my-s3-bucket
zookeeper_archive_s3_object: my/s3/directory/zookeeper-{{zookeeper_version}}.tar.gz
roles:
- role: AnsibleShipyard.ansible-zookeeper
```
Cluster Example
----------------
Expand Down
22 changes: 22 additions & 0 deletions tasks/tarball.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,31 @@
- name: "Ensure the zookeeper dir exists at {{zookeeper_dir}}"
file: path={{zookeeper_dir}} state=directory

# If the file exists already, the S3 call can experience errors
- name: check whether the tarball is downloaded already
stat: path={{zookeeper_tarball_dir}}/zookeeper-{{zookeeper_version}}.tar.gz
register: zookeeper_tarball_script

- name: Download zookeeper from S3
s3:
mode: get
bucket: "{{zookeeper_archive_s3_bucket}}"
object: "{{zookeeper_archive_s3_object}}"
dest: "{{zookeeper_tarball_dir}}/zookeeper-{{zookeeper_version}}.tar.gz"
register: zookeeper_s3_tarball_downloaded
tags: bootstrap
when: >
zookeeper_archive_s3_bucket is defined and
zookeeper_archive_s3_object is defined and
not zookeeper_tarball_script.stat.exists
- name: Download zookeeper version.
get_url: url={{zookeeper_url}} dest={{zookeeper_tarball_dir}}/zookeeper-{{zookeeper_version}}.tar.gz
tags: bootstrap
register: zookeeper_tarball_downloaded
when: >
zookeeper_archive_s3_bucket is not defined or
zookeeper_archive_s3_object is not defined
- name: Unpack tarball.
command: tar zxf {{zookeeper_tarball_dir}}/zookeeper-{{zookeeper_version}}.tar.gz --strip-components=1 chdir={{zookeeper_dir}} creates={{zookeeper_dir}}/bin
Expand Down

0 comments on commit dc54ad7

Please sign in to comment.