diff --git a/tasks/RedHat.yml b/tasks/RedHat.yml index 06691a5..ffa145f 100644 --- a/tasks/RedHat.yml +++ b/tasks/RedHat.yml @@ -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 diff --git a/tasks/systemd.yml b/tasks/systemd.yml new file mode 100644 index 0000000..4adef10 --- /dev/null +++ b/tasks/systemd.yml @@ -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 diff --git a/tasks/tarball.yml b/tasks/tarball.yml new file mode 100644 index 0000000..e90b1f1 --- /dev/null +++ b/tasks/tarball.yml @@ -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 diff --git a/tasks/upstart.yml b/tasks/upstart.yml new file mode 100644 index 0000000..f20f982 --- /dev/null +++ b/tasks/upstart.yml @@ -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