Skip to content

Commit

Permalink
Merge pull request #64 from jlm3575/jlm3575/s3-support
Browse files Browse the repository at this point in the history
Adding S3 support.
  • Loading branch information
ernestas-poskus authored May 18, 2017
2 parents 1f27c7d + dc54ad7 commit 3ac38ed
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 3ac38ed

Please sign in to comment.