diff --git a/parse_server/defaults/main.yml b/parse_server/defaults/main.yml index aee7d62f..f502ab50 100644 --- a/parse_server/defaults/main.yml +++ b/parse_server/defaults/main.yml @@ -7,5 +7,17 @@ parse_server_npm_modules: parse_server_http_port: 1337 parse_server_db: parse_db -parse_server_mongodb_url: 'mongodb://localhost:27017/{{ parse_server_db }}' +parse_server_mongodb_uri: 'mongodb://localhost:27017/{{ parse_server_db }}' +parse_server_app_id: 'foo' +#parse_server_master_key: 'use a vault file' +parse_server_app_name: '{{ parse_server_app_id }}' + +parse_server_dashboard_install: True +parse_server_dashboard_http_port: 4040 +parse_dashboard_user: parse +#parse_dashboard_passwd: 'use a vault file' +# Encrypt the password with something like https://www.bcrypt-generator.com/ +parse_dashboard_passwd_encrypted: 'true' +parse_server_dashboard_npm_modules: + - parse-dashboard diff --git a/parse_server/tasks/main.yml b/parse_server/tasks/main.yml index 1cb0562e..0accb629 100644 --- a/parse_server/tasks/main.yml +++ b/parse_server/tasks/main.yml @@ -10,4 +10,31 @@ npm: name={{ item }} global=yes state=present production=true with_items: '{{ parse_server_npm_modules }}' + - name: Install the parse server startup script + template: src=parse_server.upstart.j2 dest=/etc/init/parse_server.conf mode=0644 + + - name: Ensure that the parse service is started and enabled + service: name=parse_server state=started enabled=yes + tags: [ 'parse', 'parse_server' ] + +- block: + + - name: Install the parse server dashboard + npm: name={{ item }} global=yes state=present production=true + with_items: '{{ parse_server_dashboard_npm_modules }}' + + - name: Install the parse dashboard environment variables file + template: src=parse-server-dashboard dest=/etc/default/parse-server-dashboard + + - name: Install the parse dashboard configuration file + template: src=parse-dashboard-config.json dest={{ parse_server_user_home }}/parse-dashboard-config.json + + - name: Install the parse dashboard startup script + template: src=parse_server_dashboard.upstart.j2 dest=/etc/init/parse_server_dashboard.conf mode=0644 + + - name: Ensure that the parse dashboard service is started and enabled + service: name=parse_server_dashboard state=started enabled=yes + + when: parse_server_dashboard_install + tags: [ 'parse', 'parse_server', 'parse_server_dashboard' ] diff --git a/parse_server/templates/parse-server-dashboard b/parse_server/templates/parse-server-dashboard new file mode 100644 index 00000000..7949e70d --- /dev/null +++ b/parse_server/templates/parse-server-dashboard @@ -0,0 +1,2 @@ +export PARSE_DASHBOARD_TRUST_PROXY=1 +export MOUNT_PATH=/dashboard diff --git a/parse_server/templates/parse_server.upstart.j2 b/parse_server/templates/parse_server.upstart.j2 new file mode 100644 index 00000000..2bf04d2e --- /dev/null +++ b/parse_server/templates/parse_server.upstart.j2 @@ -0,0 +1,12 @@ +description "Parse server" +start on (local-filesystems and net-device-up IFACE!=lo) +stop on runlevel [016] + +respawn +respawn limit 10 5 +setuid {{ parse_server_user }} +setgid {{ parse_server_user }} + +script + exec /usr/bin/parse-server --appId "{{ parse_server_app_id }}" --masterKey "{{ parse_server_master_key }}" --databaseURI {{ parse_server_mongodb_uri }} +end script diff --git a/parse_server/templates/parse_server_dashboard.upstart.j2 b/parse_server/templates/parse_server_dashboard.upstart.j2 new file mode 100644 index 00000000..ee79fafe --- /dev/null +++ b/parse_server/templates/parse_server_dashboard.upstart.j2 @@ -0,0 +1,15 @@ +description "Parse server dashboard" +start on (local-filesystems and net-device-up IFACE!=lo) +stop on runlevel [016] + +respawn +respawn limit 10 5 +setuid {{ parse_server_user }} +setgid {{ parse_server_user }} + +script + . /etc/default/parse-server-dashboard + export PARSE_DASHBOARD_TRUST_PROXY + export MOUNT_PATH + exec /usr/bin/parse-dashboard --config parse-dashboard-config.json +end script