airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shame...@apache.org
Subject [17/29] airavata git commit: Start zookeeper as a systemd service
Date Sat, 24 Sep 2016 01:58:42 GMT
Start zookeeper as a systemd service


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/86a39199
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/86a39199
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/86a39199

Branch: refs/heads/develop
Commit: 86a3919970469f2ada367b8d12e0726716723693
Parents: c18b06c
Author: Shameera Rathnayaka <shameerainfo@gmail.com>
Authored: Thu Aug 18 00:11:38 2016 -0400
Committer: Shameera Rathnayaka <shameerainfo@gmail.com>
Committed: Thu Aug 18 00:11:38 2016 -0400

----------------------------------------------------------------------
 roles/common/handlers/main.yml                 | 45 ---------------------
 roles/common/tasks/main.yml                    | 38 ++++++++---------
 roles/common/vars/main.yml                     |  2 +-
 roles/zookeeper/handlers/main.yml              | 19 +++------
 roles/zookeeper/tasks/main.yml                 | 25 +++++++++++-
 roles/zookeeper/templates/zookeeper.service.j2 | 15 +++++++
 roles/zookeeper/vars/main.yml                  |  2 +-
 site.yml                                       |  1 +
 8 files changed, 67 insertions(+), 80 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/86a39199/roles/common/handlers/main.yml
----------------------------------------------------------------------
diff --git a/roles/common/handlers/main.yml b/roles/common/handlers/main.yml
deleted file mode 100644
index d5c99e94..0000000
--- a/roles/common/handlers/main.yml
+++ /dev/null
@@ -1,45 +0,0 @@
----
-# Handler file
-# Can have multiple handlers
-
-# Zookeeper related handlers
-- name: start zookeeper
-  command: ./bin/zkServer.sh start chdir={{zookeeper_dir}}/ creates={{zookeeper_data_dir}}/zookeeper_server.pid
-  become: true
-  become_user: "{{ user }}"
-
-- name: stop zookeeper
-  command: ./bin/zkServer.sh stop chdir={{zookeeper_dir}}/ removes={{zookeeper_data_dir}}/zookeeper_server.pid
-  become: true
-  become_user: "{{ user }}"
-
-- name: restart zookeeper
-  command: ./bin/zkServer.sh restart chdir={{zookeeper_dir}}/ removes={{zookeeper_data_dir}}/zookeeper_server.pid
-  become: true
-  become_user: "{{ user }}"
-
-# Rabbitmq related handlers
-- name: start rabbitmq
-  service: name=rabbitmq-server state=started
-
-- name: stop rabbitmq
-  service: name=rabbitmq-server state=stopped
-
-- name: restart rabbitmq
-  service: name=rabbitmq-server state=restarted
-
-# Gfac related handlers
-- name: start gfac
-  command: ./bin/airavata-server-start.sh gfac -d chdir="{{ gfac_dir }}/{{ airavata_dist
}}/" creates="{{ gfac_dir }}/{{ airavata_dist }}/bin/server_start_*"
-
-- name: stop gfac
-  command: ./bin/airavata-server-stop.sh -f chdir="{{ gfac_dir }}/{{ airavata_dist }}/" removes="{{
gfac_dir }}/{{ airavata_dist }}/bin/server_start_*"
-
-# Gfac related handlers
-- name: start api-orch
-  command: ./bin/airavata-server-start.sh api-orch -d chdir="{{ api_orch_dir }}/{{ airavata_dist
}}/" creates="{{ api_orch_dir }}/{{ airavata_dist }}/bin/server_start_*"
-
-- name: stop api-orch
-  command: ./bin/airavata-server-stop.sh -f chdir="{{ api_orch_dir }}/{{ airavata_dist }}/"
removes="{{ api_orch_dir }}/{{ airavata_dist }}/bin/server_start_*"
-
-...

http://git-wip-us.apache.org/repos/asf/airavata/blob/86a39199/roles/common/tasks/main.yml
----------------------------------------------------------------------
diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml
index 31bfaae..9c1884d 100644
--- a/roles/common/tasks/main.yml
+++ b/roles/common/tasks/main.yml
@@ -4,43 +4,45 @@
   with_items:
     - git
     - maven
+  become: yes
 
 # Setup airavata source
 - name: Create deployment directory {{ deployment_dir }}
   file: path={{ deployment_dir }} state=directory mode=0755
-  become: true
-  become_user: "{{ user }}"
-  tags: deploy
 
 - name: Create source directory
-  file: path={{airavata_source_dir}} state=directory mode=0755 owner={{ user }} group={{
group }}
-  tags: deploy
+  file: path={{airavata_source_dir}}
+        state=directory
+        mode=0755
+        owner={{ user }}
+        group={{ group }}
 
 - name: git checkout from airavata github
-  git: repo=https://git-wip-us.apache.org/repos/asf/airavata.git  dest="{{ airavata_source_dir
}}" version=master
+  git: repo=https://git-wip-us.apache.org/repos/asf/airavata.git
+       dest="{{ airavata_source_dir }}"
+       version="{{ git_branch }}"
   register: checkout
-  become: true
-  become_user: "{{ user }}"
-  tags: deploy, update_gfac, update_api_orch, update
+  tags: update
 
 - name: Run maven build
   command: mvn clean install -Dmaven.test.skip=true chdir="{{ airavata_source_dir }}/"
   when: (checkout|success) or (checkout|skipped)
   register: build
-  become: true
-  become_user: "{{ user }}"
-  tags: deploy, update_gfac, update_api_orch, update
+  tags: update
 
 ################################################################################
 # copy key store and trust store files
 - name: Create KeyStores directory
-  file: path="{{ key_stores_location }}" state=directory owner="{{ user }}" group="{{ group
}}"
-  tags: deploy
+  file: path="{{ key_stores_location }}"
+        state=directory
+        owner="{{ user }}" group="{{ group }}"
 
 - name: Transfer airavata.jks KeyStore file
-  copy: src="{{ key_store }}" dest="{{ key_stores_location }}/{{ key_store }}" owner="{{
user }}" group="{{ group }}"
-  tags: deploy
+  copy: src="{{ key_store }}"
+        dest="{{ key_stores_location }}/{{ key_store }}"
+        owner="{{ user }}" group="{{ group }}"
 
 - name: Transfer client trust store KeyStore file
-  copy: src="{{ cred_key_store }}" dest="{{ key_stores_location }}/{{ cred_key_store }}"
owner="{{ user }}" group="{{ group }}"
-  tags: deploy
+  copy: src="{{ cred_key_store }}"
+        dest="{{ key_stores_location }}/{{ cred_key_store }}"
+        owner="{{ user }}" group="{{ group }}"

http://git-wip-us.apache.org/repos/asf/airavata/blob/86a39199/roles/common/vars/main.yml
----------------------------------------------------------------------
diff --git a/roles/common/vars/main.yml b/roles/common/vars/main.yml
index 0071b42..0df33c5 100644
--- a/roles/common/vars/main.yml
+++ b/roles/common/vars/main.yml
@@ -1,5 +1,5 @@
 ---
 # Common variables
 airavata_source_dir: "{{ user_home }}/source"
-
+git_branch: master
 ...

http://git-wip-us.apache.org/repos/asf/airavata/blob/86a39199/roles/zookeeper/handlers/main.yml
----------------------------------------------------------------------
diff --git a/roles/zookeeper/handlers/main.yml b/roles/zookeeper/handlers/main.yml
index c6d7c34..5f30254 100644
--- a/roles/zookeeper/handlers/main.yml
+++ b/roles/zookeeper/handlers/main.yml
@@ -1,19 +1,12 @@
 ---
-
-# Zookeeper related handlers
 - name: start zookeeper
-  command: ./bin/zkServer.sh start chdir={{zookeeper_dir}}/ creates={{zookeeper_data_dir}}/zookeeper_server.pid
-  become: true
-  become_user: "{{ user }}"
+  service: name=zookeeper state=started
+  become: yes
 
 - name: stop zookeeper
-  command: ./bin/zkServer.sh stop chdir={{zookeeper_dir}}/ removes={{zookeeper_data_dir}}/zookeeper_server.pid
-  become: true
-  become_user: "{{ user }}"
+  service: name=zookeeper state=stopped
+  become: yes
 
 - name: restart zookeeper
-  command: ./bin/zkServer.sh restart chdir={{zookeeper_dir}}/ removes={{zookeeper_data_dir}}/zookeeper_server.pid
-  become: true
-  become_user: "{{ user }}"
-
-...
+  service: name=zookeeper state=restarted
+  become: yes

http://git-wip-us.apache.org/repos/asf/airavata/blob/86a39199/roles/zookeeper/tasks/main.yml
----------------------------------------------------------------------
diff --git a/roles/zookeeper/tasks/main.yml b/roles/zookeeper/tasks/main.yml
index 90a2d30..78bcec2 100644
--- a/roles/zookeeper/tasks/main.yml
+++ b/roles/zookeeper/tasks/main.yml
@@ -2,12 +2,33 @@
 ################################################################################
 # Setup and run Zookeeper
 - name: Download and unarchive zookeeper
-  unarchive: src="{{ zookeeper_url }}" dest="{{ user_home }}" copy=no owner="{{ user }}"
group="{{ group }}"
+  unarchive: src="{{ zookeeper_url }}"
+      dest="{{ user_home }}"
+      copy=no
+      owner="{{ user }}"
+      group="{{ group }}"
+
+- name: open zookeeper port
+  firewalld: port=2181/tcp zone=public permanent=true state=enabled immediate=yes
+  become: yes
 
 - name: Copy zoo.cfg file
   template: src=zoo.cfg.j2 dest="{{ zookeeper_dir }}/conf/zoo.cfg" owner="{{ user }}" group="{{
group }}" mode="u=rw,g=r,o=r"
   notify:
-    - start zookeeper
     - 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
+  notify:
+    - restart zookeeper
+  become: yes
+
+- name: reload systemd daemons
+  command: systemctl daemon-reload
+  become: yes
 ...

http://git-wip-us.apache.org/repos/asf/airavata/blob/86a39199/roles/zookeeper/templates/zookeeper.service.j2
----------------------------------------------------------------------
diff --git a/roles/zookeeper/templates/zookeeper.service.j2 b/roles/zookeeper/templates/zookeeper.service.j2
new file mode 100644
index 0000000..19c3718
--- /dev/null
+++ b/roles/zookeeper/templates/zookeeper.service.j2
@@ -0,0 +1,15 @@
+# {{ansible_managed}}
+
+[Unit]
+Description=ZooKeeper
+
+
+[Service]
+Type=forking
+ExecStart={{zookeeper_dir}}/bin/zkServer.sh start
+ExecStop={{ zookeeper_dir }}/bin/zkServer.sh stop
+Restart=always
+TimeoutSec=300
+
+[Install]
+WantedBy=multi-user.target

http://git-wip-us.apache.org/repos/asf/airavata/blob/86a39199/roles/zookeeper/vars/main.yml
----------------------------------------------------------------------
diff --git a/roles/zookeeper/vars/main.yml b/roles/zookeeper/vars/main.yml
index dd40e56..825f26f 100644
--- a/roles/zookeeper/vars/main.yml
+++ b/roles/zookeeper/vars/main.yml
@@ -5,7 +5,7 @@ zookeeper_version: 3.4.8
 zookeeper_url: http://www.us.apache.org/dist/zookeeper/zookeeper-{{zookeeper_version}}/zookeeper-{{zookeeper_version}}.tar.gz
 
 apt_cache_timeout: 3600
-client_port: 2183
+client_port: 2181
 init_limit: 5
 sync_limit: 2
 tick_time: 2000

http://git-wip-us.apache.org/repos/asf/airavata/blob/86a39199/site.yml
----------------------------------------------------------------------
diff --git a/site.yml b/site.yml
index bae8573..6a7a634 100644
--- a/site.yml
+++ b/site.yml
@@ -4,6 +4,7 @@
   tags: zookeeper, airavata
   roles:
     - env_setup
+    - java
     - zookeeper
 
 - hosts: rabbitmq


Mime
View raw message