diff --git a/README.md b/README.md index bd5b933..6297729 100644 --- a/README.md +++ b/README.md @@ -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 ---------------- diff --git a/tasks/tarball.yml b/tasks/tarball.yml index 2607f0b..eaf54ea 100644 --- a/tasks/tarball.yml +++ b/tasks/tarball.yml @@ -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