You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@metron.apache.org by ni...@apache.org on 2016/05/03 20:10:03 UTC
incubator-metron git commit: METRON-125 Install Metron UI as SysV
service (nickwallen) closes apache/incubator-metron#102
Repository: incubator-metron
Updated Branches:
refs/heads/master dc8a14e22 -> 90d1438d6
METRON-125 Install Metron UI as SysV service (nickwallen) closes apache/incubator-metron#102
Project: http://git-wip-us.apache.org/repos/asf/incubator-metron/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-metron/commit/90d1438d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-metron/tree/90d1438d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-metron/diff/90d1438d
Branch: refs/heads/master
Commit: 90d1438d686af30fe9cf78a13551819ebe3e357c
Parents: dc8a14e
Author: nickwallen <ni...@nickallen.org>
Authored: Tue May 3 14:09:12 2016 -0400
Committer: Nick Allen <ni...@nickallen.org>
Committed: Tue May 3 14:09:12 2016 -0400
----------------------------------------------------------------------
metron-deployment/roles/metron_ui/README.md | 14 +++++
.../roles/metron_ui/tasks/dependencies.yml | 33 ++++++++++++
.../roles/metron_ui/tasks/main.yml | 40 +-------------
.../roles/metron_ui/tasks/metron-ui.yml | 56 ++++++++++++++++++++
4 files changed, 105 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/90d1438d/metron-deployment/roles/metron_ui/README.md
----------------------------------------------------------------------
diff --git a/metron-deployment/roles/metron_ui/README.md b/metron-deployment/roles/metron_ui/README.md
new file mode 100644
index 0000000..54eb6e4
--- /dev/null
+++ b/metron-deployment/roles/metron_ui/README.md
@@ -0,0 +1,14 @@
+Metron Deployment - Metron UI
+=============================
+
+This project deploys all of the necessary components to run the Metron UI. This is installed as a SysV service for management purposes.
+
+Getting Started
+---------------
+
+```
+service pm2-init.sh start
+service pm2-init.sh stop
+service pm2-init.sh restart
+service pm2-init.sh status
+```
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/90d1438d/metron-deployment/roles/metron_ui/tasks/dependencies.yml
----------------------------------------------------------------------
diff --git a/metron-deployment/roles/metron_ui/tasks/dependencies.yml b/metron-deployment/roles/metron_ui/tasks/dependencies.yml
new file mode 100644
index 0000000..fd849f7
--- /dev/null
+++ b/metron-deployment/roles/metron_ui/tasks/dependencies.yml
@@ -0,0 +1,33 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+---
+- name: Install yum repositories
+ yum: name=epel-release update_cache=yes
+
+- name: Install Metron UI dependencies
+ yum:
+ pkg: "{{ item }}"
+ state: installed
+ with_items:
+ - libpcap-devel
+ - wireshark
+ - nodejs
+ - npm
+ register: result
+ until: result.rc == 0
+ retries: 5
+ delay: 10
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/90d1438d/metron-deployment/roles/metron_ui/tasks/main.yml
----------------------------------------------------------------------
diff --git a/metron-deployment/roles/metron_ui/tasks/main.yml b/metron-deployment/roles/metron_ui/tasks/main.yml
index 30f12a4..f7bb733 100644
--- a/metron-deployment/roles/metron_ui/tasks/main.yml
+++ b/metron-deployment/roles/metron_ui/tasks/main.yml
@@ -15,42 +15,6 @@
# limitations under the License.
#
---
-- name: Install Metron UI dependencies
- yum:
- pkg: "{{ item }}"
- state: installed
- with_items:
- - libpcap-devel
- - wireshark
- - nodejs
- - npm
- register: result
- until: result.rc == 0
- retries: 5
- delay: 10
-
+- include: dependencies.yml
- include: copy-source.yml
-
-- name: Configure Metron UI
- lineinfile:
- dest="{{ metron_ui_directory }}/config.json"
- regexp="{{ item.regexp }}"
- line="{{ item.line }}"
- state=present
- with_items:
- - { regexp: '"elasticsearch":', line: '"elasticsearch": { "url": "http://{{ groups.search[0] }}:{{ elasticsearch_web_port }}" },' }
- - { regexp: '"pcap":', line: ' "pcap": { "url": "http://{{ groups.pcap_server[0] }}:{{ pcapservice_port }}/pcapGetter","mock": false }' }
-
-- name: Install Node dependencies
- npm:
- name: pm2
- path: "{{ metron_ui_directory }}"
- global: true
-
-- name: Install Metron UI
- npm:
- path: "{{ metron_ui_directory }}"
- production: no
-
-- name: Start Metron UI
- shell: "pm2 start {{ metron_ui_directory }}/lib/metron-ui.js --name metron"
+- include: metron-ui.yml
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/90d1438d/metron-deployment/roles/metron_ui/tasks/metron-ui.yml
----------------------------------------------------------------------
diff --git a/metron-deployment/roles/metron_ui/tasks/metron-ui.yml b/metron-deployment/roles/metron_ui/tasks/metron-ui.yml
new file mode 100644
index 0000000..548c1b0
--- /dev/null
+++ b/metron-deployment/roles/metron_ui/tasks/metron-ui.yml
@@ -0,0 +1,56 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+---
+- name: Configure Metron UI
+ lineinfile:
+ dest="{{ metron_ui_directory }}/config.json"
+ regexp="{{ item.regexp }}"
+ line="{{ item.line }}"
+ state=present
+ with_items:
+ - { regexp: '"elasticsearch":', line: '"elasticsearch": { "url": "http://{{ groups.search[0] }}:{{ elasticsearch_web_port }}" },' }
+ - { regexp: '"pcap":', line: ' "pcap": { "url": "http://{{ groups.pcap_server[0] }}:{{ pcapservice_port }}/pcapGetter","mock": false }' }
+
+- name: Install Node dependencies
+ npm:
+ name: pm2
+ path: "{{ metron_ui_directory }}"
+ global: true
+
+- name: Install Metron UI
+ npm:
+ path: "{{ metron_ui_directory }}"
+ production: no
+
+- name: Ensure Metron UI is stopped before installing service
+ shell: pm2 stop all
+ args:
+ creates: /etc/init.d/pm2-init.sh
+ ignore_errors: True
+
+- name: Configure Metron UI as a service
+ shell: "{{ item }}"
+ args:
+ creates: /etc/init.d/pm2-init.sh
+ with_items:
+ - "pm2 start {{ metron_ui_directory }}/lib/metron-ui.js --name metron"
+ - pm2 save
+ - pm2 startup centos
+ - su -c 'chmod +x /etc/init.d/pm2-init.sh; chkconfig --add pm2-init.sh'
+
+- name: Start Metron UI
+ service: name=pm2-init.sh state=restarted