Coder Social home page Coder Social logo

ansible-pimatic's Introduction

ansible-pimatic Build Status

An Ansible role to install and configure pimatic - a smart home automation software for the Raspberry Pi.

Requirements

  • Raspberry Pi with Raspbian OS
  • network access to the Raspberry Pi and sshd enabled
  • a user with sudo permissions

Install the role via Ansible Galaxy

Typical run:

$ ansible-galaxy install layereight.pimatic

If you want to install a specific version in a collection with other roles using a role file:

$ ansible-galaxy install -r roles.yml

roles.yml

- name: layereight.pimatic
  src: layereight.pimatic
  version: "2.0.1"

Role Variables

mandatory

  • pimatic_nodejs_arch: Has to be set. Choose node.js hardware architecture, typically armv6l (Pi Model A, B, B+ or Zero) or armv7l (Pi 2 Model B or Pi 3 Model B).

optional

  • pimatic_nodejs_version

    • default: "v10.18.1"
    • description: "Version of nodejs to install"
  • pimatic_app_dir

    • default: "pimatic-app"
    • description: Name of the directory in the user's home directory where pimatic should be installed to. E.g. with user pi the final installation directory will become /home/pi/pimatic-app.
  • pimatic_port

    • default: 8080
    • description: Port pimatic's web frontend will listen on. We will also wait_for pimatic to start up on that port. You may want to set it to 443 when you enable pimatic_ssl.
  • pimatic_config_template

    • default: "config.json.j2"
    • description: The role comes with pimatic's standard configuration. Pimatic's httpServer will be started on pimatic_port. Usually you want to provide your own pimatic configuration template. E.g. set pimatic_config_template to pimatic_config.json.j2 and create a file of that name in the templates directory relative to your ansible playbook.
  • pimatic_waitfor_startup

    • default: true
    • description: Configure whether the role wait for pimatic to start up. Depending on the hardware we are running on and depending on the configured plugins this may take up to 1h.
  • pimatic_ssl

    • default: false
    • description: Configure whether we should generate self signed ssl certificates. If set to true the role will provide the variables pimatic_ssl_privkey and pimatic_ssl_cert with the paths to the generated ssl private key and certificate.
  • pimatic_ssl_cn

    • default: "{{ ansible_fqdn }}"
    • description: Common Name in certificate (CN in subject).
  • pimatic_ssl_c

    • default: "DE"
    • description: Country in certificate (C in subject).
  • pimatic_ssl_st

    • default: "Berlin"
    • description: State in certificate (ST in subject).
  • pimatic_ssl_l

    • default: "Berlin"
    • description: Location in certificate (L in subject).
  • pimatic_ssl_o

    • default: "pimatic"
    • description: Organization in certificate (O in subject).
  • pimatic_ssl_ou

    • default: "pimatic"
    • description: Organizational Unit in certificate (OU in subject).

provided

  • pimatic_ssl_privkey: Provided if pimatic_ssl is set to true. You may want to use this variable in your pimatic_config_template to setup a httpsServer.

  • pimatic_ssl_cert: Provided if pimatic_ssl is set to true. You may want to use this variable in your pimatic_config_template to setup a httpsServer.

Example Playbook

Typical playbook run:

$ ansible-playbook -i inventory pimatic.yml

inventory

[raspberrypi]
pizero ansible_host=192.168.0.101 ansible_user=pi ansible_ssh_pass=raspberry 

pimatic.yml

- hosts: raspberrypi
  
  roles:
    - pimatic
  
  vars:
    pimatic_nodejs_arch: "armv6l"
    pimatic_port: 443
    pimatic_config_template: "pimatic_config.json.j2"
    pimatic_ssl: true
    pimatic_admin_password: "verysecret"

templates/pimatic_config.json.j2

{
  "settings": {
    "httpServer": {
      "enabled": false
    },
    "httpsServer": {
      "enabled": true,
      "port": {{ pimatic_port }},
      "hostname": "",
      "keyFile": "{{ pimatic_ssl_privkey }}",
      "certFile": "{{ pimatic_ssl_cert }}"
    },
    "database": {
    }
  },
  "plugins": [
    {
      "plugin": "cron"
    },
    {
      "plugin": "mobile-frontend"
    }
  ],
  "devices": [

  ],
  "rules": [

  ],
  "pages": [
    {
      "id": "favourite",
      "name": "Favourites",
      "devices": []
    }
  ],
  "groups": [

  ],
  "users": [
    {
      "username": "admin",
      "password": "{{ pimatic_admin_password }}",
      "role": "admin"
    }
  ],
  "roles": [
    {
      "name": "admin",
      "permissions": {
        "pages": "write",
        "rules": "write",
        "variables": "write",
        "messages": "write",
        "events": "write",
        "devices": "write",
        "groups": "write",
        "plugins": "write",
        "updates": "write",
        "database": "write",
        "config": "write",
        "controlDevices": true,
        "restart": true
      }
    }
  ]
}

ansible-pimatic's People

Contributors

layereight avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mwittig

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.