Skip to content

Commit

Permalink
Refactor into reusable includes (#33)
Browse files Browse the repository at this point in the history
* refactor to re-use redhat tasks for new debian install

* refactor tasks into reusable includes

* removed extra lines
  • Loading branch information
lhoss authored and ernestas-poskus committed Aug 8, 2016
1 parent e52041e commit 1359081
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 55 deletions.
58 changes: 3 additions & 55 deletions tasks/RedHat.yml
Original file line number Diff line number Diff line change
@@ -1,68 +1,16 @@
---
- file: path=/opt/src state=directory
- file: path={{zookeeper_dir}} state=directory

- name: Download zookeeper version.
get_url: url={{zookeeper_url}} dest=/opt/src/zookeeper-{{zookeeper_version}}.tar.gz
tags: bootstrap

- name: Install OS Packages
yum: name={{ item }} state=present
with_items:
- libselinux-python

- name: Unpack tarball.
command: tar zxf /opt/src/zookeeper-{{zookeeper_version}}.tar.gz --strip-components=1 chdir={{zookeeper_dir}} creates={{zookeeper_dir}}/bin
tags: bootstrap

- group: name=zookeeper system=yes
- user: name=zookeeper group=zookeeper system=yes

- name: Change ownership on zookeeper directory.
file: path={{zookeeper_dir}} state=directory owner=zookeeper group=zookeeper recurse=yes
tags: bootstrap

- name: Create zookeeper data folder.
file: path={{data_dir}} state=directory recurse=yes owner=zookeeper group=zookeeper
tags: bootstrap

- name: Create zookeeper logs folder.
file: path={{log_dir}} state=directory recurse=yes owner=zookeeper group=zookeeper
tags: bootstrap

- name: Check if /etc/init exists
stat: path=/etc/init/
register: etc_init

- name: Upstart script.
template: src=zookeeper.conf.j2 dest=/etc/init/zookeeper.conf
when: etc_init.stat.exists == true
tags: deploy
notify:
- Restart zookeeper

- name: Check if systemd exists
stat: path=/usr/lib/systemd/system/
register: systemd_check

- name: Systemd script.
template: src=zookeeper.service.j2 dest=/usr/lib/systemd/system/zookeeper.service
when: systemd_check.stat.exists == true
tags: deploy
notify:
- Restart zookeeper
- include: tarball.yml

- name: Write myid file.
template: src=myid.j2 dest={{data_dir}}/myid owner=zookeeper group=zookeeper
- include: upstart.yml
tags: deploy
notify:
- Restart zookeeper

- name: Configure zookeeper
template: src=zoo.cfg.j2 dest={{ zookeeper_dir }}/conf/zoo.cfg owner=zookeeper group=zookeeper
- include: systemd.yml
tags: deploy
notify:
- Restart zookeeper

- name: Start zookeeper
service: name=zookeeper state=started enabled=yes
Expand Down
10 changes: 10 additions & 0 deletions tasks/systemd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Check if systemd exists
stat: path=/usr/lib/systemd/system/
register: systemd_check

- name: Systemd script.
template: src=zookeeper.service.j2 dest=/usr/lib/systemd/system/zookeeper.service
when: systemd_check.stat.exists == true
notify:
- Restart zookeeper
38 changes: 38 additions & 0 deletions tasks/tarball.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
- file: path=/opt/src state=directory
- file: path={{zookeeper_dir}} state=directory

- name: Download zookeeper version.
get_url: url={{zookeeper_url}} dest=/opt/src/zookeeper-{{zookeeper_version}}.tar.gz
tags: bootstrap

- name: Unpack tarball.
command: tar zxf /opt/src/zookeeper-{{zookeeper_version}}.tar.gz --strip-components=1 chdir={{zookeeper_dir}} creates={{zookeeper_dir}}/bin
tags: bootstrap

- group: name=zookeeper system=yes
- user: name=zookeeper group=zookeeper system=yes

- name: Change ownership on zookeeper directory.
file: path={{zookeeper_dir}} state=directory owner=zookeeper group=zookeeper recurse=yes
tags: bootstrap

- name: Create zookeeper data folder.
file: path={{data_dir}} state=directory recurse=yes owner=zookeeper group=zookeeper
tags: bootstrap

- name: Create zookeeper logs folder.
file: path={{log_dir}} state=directory recurse=yes owner=zookeeper group=zookeeper
tags: bootstrap

- name: Write myid file.
template: src=myid.j2 dest={{data_dir}}/myid owner=zookeeper group=zookeeper
tags: deploy
notify:
- Restart zookeeper

- name: Configure zookeeper
template: src=zoo.cfg.j2 dest={{ zookeeper_dir }}/conf/zoo.cfg owner=zookeeper group=zookeeper
tags: deploy
notify:
- Restart zookeeper
10 changes: 10 additions & 0 deletions tasks/upstart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Check if /etc/init exists
stat: path=/etc/init/
register: etc_init

- name: Upstart script.
template: src=zookeeper.conf.j2 dest=/etc/init/zookeeper.conf
when: etc_init.stat.exists == true
notify:
- Restart zookeeper

0 comments on commit 1359081

Please sign in to comment.