diff --git a/elasticsearch/tasks/plugin_head.yml b/elasticsearch/tasks/plugin_head.yml index 2c4fd264..4be19572 100644 --- a/elasticsearch/tasks/plugin_head.yml +++ b/elasticsearch/tasks/plugin_head.yml @@ -6,7 +6,7 @@ home: "{{ elasticsearch_plugin_head_home }}" createhome: yes system: yes - shell: /bin/false + shell: /bin/bash - block: - name: Head repository is checked-out @@ -53,3 +53,21 @@ - restart elasticsearch tags: - elasticsearch + +- name: Install systemd unit + template: + src: elasticsearch-head.service.j2 + dest: /etc/systemd/system/elasticsearch-head.service + tags: + - elasticsearch + - systemd + +- name: Enable systemd unit + systemd: + name: elasticsearch-head + daemon_reload: yes + enabled: yes + state: started + tags: + - elasticsearch + - systemd diff --git a/elasticsearch/templates/elasticsearch-head.service.j2 b/elasticsearch/templates/elasticsearch-head.service.j2 new file mode 100644 index 00000000..4e409ed0 --- /dev/null +++ b/elasticsearch/templates/elasticsearch-head.service.j2 @@ -0,0 +1,14 @@ +[Service] +Type=simple +ExecStart=/usr/bin/npm run start +User={{ elasticsearch_plugin_head_owner }} +Group={{ elasticsearch_plugin_head_group }} +StandardOutput=syslog +StandardError=syslog +SyslogIdentifier=elasticsearch-head +Restart=always +WorkingDirectory={{ elasticsearch_plugin_head_clone_dir }} +Environment=NODE_ENV=production + +[Install] +WantedBy=multi-user.target