Giter VIP home page Giter VIP logo

marinepi-provisioning's Introduction

MarinePi

Ansible scripts to setup a Raspberry Pi for boat use, providing access to various data sources on board both via wired and wireless connections. Features include:

  • Signal K node server with NMEA 0183 and NMEA 2000 support
  • wifi hotspot
  • (marina) wifi access with routing
  • 3/4G Internet connectivity with Huawei e3372
  • VPN access
  • various dynamic dns providers (inadyn, Route 53)
  • read-only root partition

Usage

  1. Install Ansible on your computer and verify that it works

    • ansible --version
    • note: on MacOS Ansible might not be added to your PATH in bash_profile, see 2nd answer in this thread on how to fixed that.
  2. Install Raspberry OS Lite on an SD-card with your local computer.

    • Download the Raspberry Pi Imager and install the OS (the tool will download the latest image). It is also possible to configure and enable remote access already at this stage in Imager and skip the step (3) below.
    • Alternatively you can download the image yourself and write this to the SD-card with a tool like Belena Etcher or directly from the command line with the following commands:
      diskutil list
      diskutil unmountDisk /dev/<disk#>
      sudo dd bs=1m if=<your image file>.img of=/dev/<disk#>
      
  3. Enable remote access while the SD-Card is still in the computer.

    • ssh
      • Windows: create an empty file ssh on the SD-card (which now has the volume label 'boot)
      • Linux/MacOS: create the empty file with this command: touch /Volumes/bootfs/ssh
    • create default user (since Bullseye)
    • Alternatively, both ssh and the default user can be enabled and created in the Raspberry Pi Imager in the previous step (2)
    • Optionally, configure the Raspberry Pi to connect to your Wifi network (otherwise you have to connect through Ethernet)
      • Create a file wpa_supplicants.conf on the SD-card with the following content:
      ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
      update_config=1
      country=<Insert 2 letter ISO 3166-1 country code here>
      
      network={
      ssid="<Name of your wireless LAN>"
      psk="<Password for your wireless LAN>"
      }
      
  4. Insert SD-card in the Raspberry Pi and test the network connection.

  5. Clone this git repository on your computer

  6. Run ./firstrun.sh from your computer, for the initial setup of your Raspberry Pi.

    • This script will:
      • copy over your ssh key for secure passwordles access from your computer.
      • change the default password for user pi (which is raspberry)
        You will be asked for a new password, be aware that characters like '@' seem to crash the process
      • expand the filesystem
    • The script assumes that your Raspberry Pi is configured with the standard hostname raspberrypi.local. If you want to use its IP address, or another hostname use: ./firstrun.sh <ip-of-your-raspi> (find out the IP address).
    • Known problems:
      • MacOS users might see an error because 'sshpass' is not installed by default. See answer in this thread on how to install sshpass (first install XCode and than the XCode command line utilities)
  7. Create a copy of playbooks/example-boat.yml and edit the settings to match your environment such as the hostname, wifi and hotspot settings, etc.

  8. Run ./provision.sh <ip-of-your-raspi> playbooks/example-boat.yml to provision the software & configurations for the roles in example-boat.yml.

    • Known problems:
      • After a automated reboot the script might not continue or it presents an 'unreachable' error. After giving it some time and verifying that the connection to the Raspberry Pi, just restart the provisioning process. The process will continue where it has stopped.
      • An error on installing pysk, see issues on github repo for a solution
    • When the process is finished your Raspberry Pi is ready.
      Configure signalk through the browser: http://raspberrypi:3000/ or http://raspberrypi/ (log in at the top right and change default userid pi and password password). When you are done with the configuration save .signalk/defaults.json, security.json and settings.json. You can use these in a next provisioning process.

Roles

You define what features you want to provision by adding roles to your playbook.

signalk-npm

Installs the Signal K Node server. Uses node and node-app roles to install Node.js and run under systemd.

hotspot

Installs and configures the software needed for the Pi to act as a wifi hotspot. Override variables:

hotspot_ssid: MarinePi
hotspot_channel: 11
hotspot_passphrase: NavigareNecesseEst
hotspot_interface: wlan0

canboat

Installs canboat utilities to interface with the NMEA 2000 network.

route53-ddns

Installs a cron script that periodically checks your external IP address and updates Amazon's Route 53 name server information to act as dynamic DNS setup. Installs Amazon's command line tools as a dependency.

For minimal priviledges you should create a limited AWS identity for use with this profile and attach the policy AmazonRoute53FullAccess. In your own playbook define variables

aws_access_key_id: 'YOUR_ACCESS_KEY_ID'
aws_secret_access_key: 'YOUR_SECRET_ACCESS_KEY'

with the information for this limited identity.

wificlient

Installs and configures the software the Pi needs to act as a wifi client. Override variables:

wificlient_interface: wlan1
wificlient_networks:
  - ssid: defaultssid
    psk: defaultpassphrase
    priority: 1
    scan_ssid: 0

You can add multiple networks by repeating the last four lines, if needed.

pysk

Installs the pysk console client on the Pi. See: https://github.com/ph1l/pysk

grafana

Installs grafana. Override variables:

grafana_admin_password: admin
grafana_secret: SW2YcwTIb9zpOOhoPsMm
grafana_port: 3000

Credits

Fork of original project with the intention of continuing work in this repo.

marinepi-provisioning's People

Contributors

bergie avatar bhavers avatar cannonerd avatar chacal avatar hkapanen avatar joux3 avatar lfrancois avatar mairas avatar miago avatar ph1l avatar tkurki avatar webmasterkai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

marinepi-provisioning's Issues

provision-single-role doesn't work

elektron@x61s:~/code/marinepi-provisioning$ ./provision-single-role.sh grafana marinepi
#!/bin/bash -evx
# set role path in ansible.cfg or ANSIBLE_ROLES_PATH environment variable

role=$1
+ role=grafana

shift 1
+ shift 1

cat > /tmp/play.yml <<PLAYBOOK
---
- hosts: all
  roles:
  - $role
PLAYBOOK
+ cat

ansible-playbook /tmp/play.yml -i $1, -u pi
+ ansible-playbook /tmp/play.yml -i marinepi, -u pi
ERROR! the role 'grafana' was not found in /tmp/roles:/etc/ansible/roles:/tmp

The error appears to have been in '/tmp/play.yml': line 4, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  roles:
  - grafana
    ^ here

grafana role improvements?

TASK [grafana : Change admin password] *****************************************
fatal: [marinepi]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'grafana_admin_password' is undefined\n\nThe error appears to have been in '/home/elektron/code/marinepi-provisioning/roles/grafana/tasks/main.yml': line 38, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Change admin password\n  ^ here\n"}

100% unattended installation

Starting from this image: https://github.com/debian-pi/raspbian-ua-netinst, it would be pretty easy to provide some configuration files for that image to also install Ansible and git, and install from this repo. That would give a 100% unattended installation: just dump a few files on your SD card, plug it into the Pi, power on and a few minutes later you're up & running!

Thoughts?

admin-ui install failure on raspberry pi: Node Sass does not yet support your current environment: Linux Unsupported architecture (arm) with Node.js 8.x

pi@marinepi:/opt/signalk-server/admin-ui $ (npm run clean && npm run build) 2>&1 | tee /tmp/failure.log

ERROR in ./node_modules/css-loader?{"alias":{"../img":"../public_src/img"}}!./node_modules/sass-loader/lib/loader.js!./scss/style.scss
Module build failed: Error: Node Sass does not yet support your current environment: Linux Unsupported architecture (arm) with Node.js 8.x
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.7.1
    at module.exports (/opt/signalk-server/admin-ui/node_modules/node-sass/lib/binding.js:13:13)
    at Object.<anonymous> (/opt/signalk-server/admin-ui/node_modules/node-sass/lib/index.js:14:35)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/opt/signalk-server/admin-ui/node_modules/sass-loader/lib/loader.js:3:14)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at loadLoader (/opt/signalk-server/admin-ui/node_modules/loader-runner/lib/loadLoader.js:13:17)
    at iteratePitchingLoaders (/opt/signalk-server/admin-ui/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/opt/signalk-server/admin-ui/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /opt/signalk-server/admin-ui/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/opt/signalk-server/admin-ui/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/opt/signalk-server/admin-ui/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at runLoaders (/opt/signalk-server/admin-ui/node_modules/loader-runner/lib/LoaderRunner.js:362:2)
    at NormalModule.doBuild (/opt/signalk-server/admin-ui/node_modules/webpack/lib/NormalModule.js:182:3)
    at NormalModule.build (/opt/signalk-server/admin-ui/node_modules/webpack/lib/NormalModule.js:275:15)
    at Compilation.buildModule (/opt/signalk-server/admin-ui/node_modules/webpack/lib/Compilation.js:151:10)
    at factoryCallback (/opt/signalk-server/admin-ui/node_modules/webpack/lib/Compilation.js:344:12)
    at factory (/opt/signalk-server/admin-ui/node_modules/webpack/lib/NormalModuleFactory.js:241:5)
    at applyPluginsAsyncWaterfall (/opt/signalk-server/admin-ui/node_modules/webpack/lib/NormalModuleFactory.js:94:13)
 @ ./scss/style.scss 4:14-127 18:2-22:4 19:20-133
 @ ./src/index.js
 @ multi ./src/index.js

full log: failure.log

Reboots not working in Ansible 2

setup.yml playbook successfully calls raspi-config to change the root partition size. However, for the change to work the device must be rebooted. The firstrun.sh should probably also take care of that? Or do some mounting magic. Your thoughts?

easy_install deprecated

easy_install is deprecated, and therefor installing pysk will not work.
I think roles/pysk/task/main.yml should be changed. Something like this?

- pip:
    name: pysk
    version: latest
  become: true
#- name: 'Install pysk'
#  easy_install:
#    name: pysk
#    state: latest
#  become: true

also opened an issue in the pysk project: ph1l/pysk#5

Signal K from git now needs a build step

We need to add a npm run build in the git checkout for the signalk role. Otherwise it'll fail to start with:

$ /usr/bin/node /opt/signalk-server/bin/signalk-server
internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module '../lib'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)

systemd port mapping breaks signalk discovery protocol

connecting to port 80, the signalk daemon still thinks it's running on port 3000

elektron@x61s:~/code/marinepi-provisioning$ curl http://marinepi:80/signalk/ | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   185  100   185    0     0   7333      0 --:--:-- --:--:-- --:--:--  7708
{
  "endpoints": {
    "v1": {
      "version": "1.alpha1",
      "signalk-http": "http://marinepi:3000/signalk/v1/api/",
      "signalk-ws": "ws://marinepi:3000/signalk/v1/stream",
      "signalk-tcp": "tcp://marinepi:3858"
    }
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.