Skip to content

Commit

Permalink
Support distro with systemd.
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoit Carriere committed Aug 2, 2015
1 parent 6c18f07 commit 5daea9d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@ Vagrant.configure("2") do |config|
c.vm.box = "centos65-x86_64-20140116"
c.vm.box_url = "https://github.com/2creatives/vagrant-centos/releases/download/v6.5.3/centos65-x86_64-20140116.box"
c.vm.provision "shell" do |s|
s.inline = "/bin/true"
s.inline = "yum install -y nc java-1.7.0-openjdk-devel ansible"
s.privileged = true
end
end

# centos 7
config.vm.define 'centos7' do |c|
c.vm.network "private_network", ip: "192.168.100.4"
c.vm.box = "centos/7"
c.vm.provision "shell" do |s|
s.inline = "yum install -y epel-release; yum install -y nc java-1.7.0-openjdk-devel ansible"
s.privileged = true
end
end
Expand Down
3 changes: 3 additions & 0 deletions ci/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
- hosts: localhost
connection: local
sudo: yes
gather_facts: false

tasks:
- wait_for: port=2181 state=started delay=1

- shell: echo stat | nc 127.0.0.1 2181
register: status
failed_when: status.rc != 0
16 changes: 16 additions & 0 deletions tasks/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,24 @@
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
Expand Down
15 changes: 15 additions & 0 deletions templates/zookeeper.service.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# {{ansible_managed}}

[Unit]
Description=ZooKeeper

[Service]
Type=simple
User=zookeeper
Group=zookeeper
ExecStart={{zookeeper_dir}}/bin/zkServer.sh start-foreground

TimeoutSec=300

[Install]
WantedBy=multi-user.target

0 comments on commit 5daea9d

Please sign in to comment.