# Copyright 2016 Teppo Kurki <teppo.kurki@iki.fi>
#
# Licensed 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 mdns dependency"
    apt: pkg=libavahi-compat-libdnssd-dev state=latest

  - name: "Install mdns for Signal K server"
    command: "npm install mdns"
    args:
      chdir: /opt/signalk-server

# Copyright 2016 Teppo Kurki <teppo.kurki@iki.fi>
#
# Licensed 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 mdns dependency"
    apt: pkg=libavahi-compat-libdnssd-dev state=latest

  - name: "Install mdns for Signal K server"
    command: "npm install mdns"
    args:
      chdir: /opt/signalk-server

  - name: Copy SignalK server settings
    copy: src={{ signalk_settings_file }} dest=/etc/signalk-settings.json mode=0644
    when: signalk_settings_file is defined
    register: signalk_settings

  - name: Restart SignalK server
    service: name=signalk-server state=restarted
    when: signalk_settings.changed

Copy SignalK settings from local file if “signalk_settings_file” is defined
Copy SignalK settings from local file if “signalk_settings_file” is defined

NOTE! By default the copied file is not used! Use SIGNALK_NODE_SETTINGS
environment variable to take it into use. For example:

  - role: signalk
    signalk_settings_file: signalk-settings-freya.json
    node_app_env:
      - "NODE_ENV=production"
      - "SIGNALK_NODE_SETTINGS=/etc/signalk-settings.json"