From dc54ad7fb89ae58cfa41a536bdd70deabde863b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CJustin?= <“jmeacham@affinipay.com”> Date: Mon, 8 May 2017 16:56:44 -0500 Subject: [PATCH] Adding S3 support. --- README.md | 14 ++++++++++++++ tasks/tarball.yml | 22 ++++++++++++++++++++++ 2 files changed, 36 insertions(+) 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