diff --git a/Vagrantfile b/Vagrantfile index 6f13ea1..79ce3ce 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -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 diff --git a/ci/tests.yml b/ci/tests.yml index 724f86e..1554d04 100644 --- a/ci/tests.yml +++ b/ci/tests.yml @@ -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 diff --git a/tasks/RedHat.yml b/tasks/RedHat.yml index 379b03e..ca7d635 100644 --- a/tasks/RedHat.yml +++ b/tasks/RedHat.yml @@ -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 diff --git a/templates/zookeeper.service.j2 b/templates/zookeeper.service.j2 new file mode 100644 index 0000000..685be93 --- /dev/null +++ b/templates/zookeeper.service.j2 @@ -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