From c76cdf1f20ba2d75a78339d9d3e756d297979a73 Mon Sep 17 00:00:00 2001 From: Anish Mangal Date: Wed, 27 Jun 2018 08:52:11 +0000 Subject: [PATCH 01/52] Add Mosquitto pub-sub broker to IIAB --- roles/6-generic-apps/tasks/main.yml | 6 +++ roles/mosquitto/README.rst | 3 ++ roles/mosquitto/defaults/main.yml | 4 ++ roles/mosquitto/tasks/main.yml | 50 ++++++++++++++++++++ roles/mosquitto/templates/websockets.conf.j2 | 3 ++ 5 files changed, 66 insertions(+) create mode 100644 roles/mosquitto/README.rst create mode 100644 roles/mosquitto/defaults/main.yml create mode 100644 roles/mosquitto/tasks/main.yml create mode 100644 roles/mosquitto/templates/websockets.conf.j2 diff --git a/roles/6-generic-apps/tasks/main.yml b/roles/6-generic-apps/tasks/main.yml index b7fe93cc2..77946a371 100644 --- a/roles/6-generic-apps/tasks/main.yml +++ b/roles/6-generic-apps/tasks/main.yml @@ -51,6 +51,12 @@ when: wordpress_install tags: wordpress +- name: MOSQUITTO + include_role: + name: mosquitto + when: mosquitto_install + tags: mosquitto + - name: Recording STAGE 6 HAS COMPLETED ==================== lineinfile: dest: "{{ iiab_env_file }}" diff --git a/roles/mosquitto/README.rst b/roles/mosquitto/README.rst new file mode 100644 index 000000000..ae9d5ca9f --- /dev/null +++ b/roles/mosquitto/README.rst @@ -0,0 +1,3 @@ +Adds the mosquitto pub-sub broker to the iiab. + +Roughly follows this guide: https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-the-mosquitto-mqtt-messaging-broker-on-ubuntu-16-04 diff --git a/roles/mosquitto/defaults/main.yml b/roles/mosquitto/defaults/main.yml new file mode 100644 index 000000000..bc4baf2a2 --- /dev/null +++ b/roles/mosquitto/defaults/main.yml @@ -0,0 +1,4 @@ +mosquitto_install: True +mosquitto_enabled: False +mosquitto_user: admin +mosquitto_password: g0adm1n diff --git a/roles/mosquitto/tasks/main.yml b/roles/mosquitto/tasks/main.yml new file mode 100644 index 000000000..79599b8c6 --- /dev/null +++ b/roles/mosquitto/tasks/main.yml @@ -0,0 +1,50 @@ +- name: Install Mosquitto + package: name={{ item }} + state=present + with_items: + - mosquitto + - mosquitto-clients + when: mosquitto_install + tags: download + +- name: Disable mosquitto + service: + name: mosquitto + enabled: no + +- name: Stop mosquitto + service: + name: mosquitto + state: stopped + +- name: Create mosquitto passwd file + file: + path: /etc/mosquitto/passwd + state: touch + mode: "u=rw,g=r,o=r" + +- name: Create mosquitto username/password + shell: mosquitto_passwd -b /etc/mosquitto/passwd "{{ mosquitto_user }}" "{{ mosquitto_password }}" + +- name: Create mosquitto config file + template: + backup: yes + src: "{{ item.src }}" + dest: "{{ item.dest }}" + owner: root + group: root + mode: "{{ item.mode }}" + with_items: + - { src: 'websockets.conf.j2' , dest: '/etc/mosquitto/conf.d/websockets.conf', mode: '0755' } + +- name: Enable mosquitto + service: + name: mosquitto + enabled: yes + when: mosquitto_enabled + +- name: Start mosquitto + service: + name: mosquitto + state: started + when: mosquitto_enabled diff --git a/roles/mosquitto/templates/websockets.conf.j2 b/roles/mosquitto/templates/websockets.conf.j2 new file mode 100644 index 000000000..16e3f7654 --- /dev/null +++ b/roles/mosquitto/templates/websockets.conf.j2 @@ -0,0 +1,3 @@ +listener 1883 +allow_anonymous false +password_file /etc/mosquitto/passwd From 7254822a1675737fb691153c4136a94066c28add Mon Sep 17 00:00:00 2001 From: Anish Mangal Date: Wed, 27 Jun 2018 11:17:44 +0000 Subject: [PATCH 02/52] Add Mosquitto pub-sub broker to IIAB --- roles/6-generic-apps/tasks/main.yml | 6 + roles/nodered/README.rst | 1 + roles/nodered/defaults/main.yml | 4 + roles/nodered/tasks/main.yml | 62 +++++ roles/nodered/templates/node-red.service.j2 | 21 ++ roles/nodered/templates/settings.js.j2 | 245 ++++++++++++++++++++ 6 files changed, 339 insertions(+) create mode 100644 roles/nodered/README.rst create mode 100644 roles/nodered/defaults/main.yml create mode 100644 roles/nodered/tasks/main.yml create mode 100644 roles/nodered/templates/node-red.service.j2 create mode 100644 roles/nodered/templates/settings.js.j2 diff --git a/roles/6-generic-apps/tasks/main.yml b/roles/6-generic-apps/tasks/main.yml index 77946a371..a33bddbc2 100644 --- a/roles/6-generic-apps/tasks/main.yml +++ b/roles/6-generic-apps/tasks/main.yml @@ -57,6 +57,12 @@ when: mosquitto_install tags: mosquitto +- name: NODE-RED + include_role: + name: nodered + when: nodered_install + tags: nodered + - name: Recording STAGE 6 HAS COMPLETED ==================== lineinfile: dest: "{{ iiab_env_file }}" diff --git a/roles/nodered/README.rst b/roles/nodered/README.rst new file mode 100644 index 000000000..01f9a08e4 --- /dev/null +++ b/roles/nodered/README.rst @@ -0,0 +1 @@ +Adds node-red and node-red dashboard to the schoolserver diff --git a/roles/nodered/defaults/main.yml b/roles/nodered/defaults/main.yml new file mode 100644 index 000000000..b13ce2e6c --- /dev/null +++ b/roles/nodered/defaults/main.yml @@ -0,0 +1,4 @@ +nodered_install: True +nodered_enabled: False +nodered_user: admin +nodered_password: g0adm1n diff --git a/roles/nodered/tasks/main.yml b/roles/nodered/tasks/main.yml new file mode 100644 index 000000000..7f739bcf0 --- /dev/null +++ b/roles/nodered/tasks/main.yml @@ -0,0 +1,62 @@ +- name: Install nodejs-legacy + package: name={{ item }} + state=present + with_items: + - nodejs-legacy + when: nodered_install + tags: download + +- name: Install npm + package: name={{ item }} + state=present + with_items: + - npm + when: nodered_install + tags: download + +- name: Install node-red packages globally. + shell: npm install -g --unsafe-perm node-red node-red-admin node-red-dashboard + +- name: Create nodered usergroup + group: + name: nodered + state: present + +- name: Add the user nodered and add to nodered group + user: + name: nodered + group: nodered + +- name: Copy settings.js file with authentication + template: + backup: yes + src: "{{ item.src }}" + dest: "{{ item.dest }}" + owner: nodered + group: nodered + mode: "{{ item.mode }}" + with_items: + - { src: 'settings.js.j2' , dest: '/home/nodered/.node-red/settings.js', mode: '0755' } + +- name: Create node-red systemd file + template: + backup: yes + src: "{{ item.src }}" + dest: "{{ item.dest }}" + owner: root + group: root + mode: "{{ item.mode }}" + with_items: + - { src: 'node-red.service.j2' , dest: '/etc/systemd/system/node-red.service', mode: '0755' } + +- name: Enable node-red + service: + name: node-red + enabled: yes + when: nodered_enabled + +- name: Start node-red + service: + name: node-red + state: started + when: nodered_enabled diff --git a/roles/nodered/templates/node-red.service.j2 b/roles/nodered/templates/node-red.service.j2 new file mode 100644 index 000000000..00527689d --- /dev/null +++ b/roles/nodered/templates/node-red.service.j2 @@ -0,0 +1,21 @@ +[Unit] +Description=Node-RED +After=syslog.target network.target + +[Service] +ExecStart=/usr/local/bin/node-red-pi --max-old-space-size=128 -v +Restart=on-failure +KillSignal=SIGINT + +# log output to syslog as 'node-red' +SyslogIdentifier=node-red +StandardOutput=syslog + +# non-root user to run as +WorkingDirectory=/home/nodered/ +User=nodered +Group=nodered + +[Install] +WantedBy=multi-user.target + diff --git a/roles/nodered/templates/settings.js.j2 b/roles/nodered/templates/settings.js.j2 new file mode 100644 index 000000000..867022dd9 --- /dev/null +++ b/roles/nodered/templates/settings.js.j2 @@ -0,0 +1,245 @@ +/** + * Copyright JS Foundation and other contributors, http://js.foundation + * + * 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. + **/ + +// The `https` setting requires the `fs` module. Uncomment the following +// to make it available: +//var fs = require("fs"); + +module.exports = { + // the tcp port that the Node-RED web server is listening on + uiPort: process.env.PORT || 1880, + + // By default, the Node-RED UI accepts connections on all IPv4 interfaces. + // To listen on all IPv6 addresses, set uiHost to "::", + // The following property can be used to listen on a specific interface. For + // example, the following would only allow connections from the local machine. + //uiHost: "127.0.0.1", + + // Retry time in milliseconds for MQTT connections + mqttReconnectTime: 15000, + + // Retry time in milliseconds for Serial port connections + serialReconnectTime: 15000, + + // Retry time in milliseconds for TCP socket connections + //socketReconnectTime: 10000, + + // Timeout in milliseconds for TCP server socket connections + // defaults to no timeout + //socketTimeout: 120000, + + // Timeout in milliseconds for HTTP request connections + // defaults to 120 seconds + //httpRequestTimeout: 120000, + + // The maximum length, in characters, of any message sent to the debug sidebar tab + debugMaxLength: 1000, + + // The maximum number of messages nodes will buffer internally as part of their + // operation. This applies across a range of nodes that operate on message sequences. + // defaults to no limit. A value of 0 also means no limit is applied. + //nodeMaxMessageBufferLength: 0, + + // To disable the option for using local files for storing keys and certificates in the TLS configuration + // node, set this to true + //tlsConfigDisableLocalFiles: true, + + // Colourise the console output of the debug node + //debugUseColors: true, + + // The file containing the flows. If not set, it defaults to flows_.json + //flowFile: 'flows.json', + + // To enabled pretty-printing of the flow within the flow file, set the following + // property to true: + //flowFilePretty: true, + + // By default, credentials are encrypted in storage using a generated key. To + // specify your own secret, set the following property. + // If you want to disable encryption of credentials, set this property to false. + // Note: once you set this property, do not change it - doing so will prevent + // node-red from being able to decrypt your existing credentials and they will be + // lost. + //credentialSecret: "a-secret-key", + + // By default, all user data is stored in the Node-RED install directory. To + // use a different location, the following property can be used + //userDir: '/home/nol/.node-red/', + + // Node-RED scans the `nodes` directory in the install directory to find nodes. + // The following property can be used to specify an additional directory to scan. + //nodesDir: '/home/nol/.node-red/nodes', + + // By default, the Node-RED UI is available at http://localhost:1880/ + // The following property can be used to specify a different root path. + // If set to false, this is disabled. + //httpAdminRoot: '/admin', + + // Some nodes, such as HTTP In, can be used to listen for incoming http requests. + // By default, these are served relative to '/'. The following property + // can be used to specifiy a different root path. If set to false, this is + // disabled. + //httpNodeRoot: '/red-nodes', + + // The following property can be used in place of 'httpAdminRoot' and 'httpNodeRoot', + // to apply the same root to both parts. + //httpRoot: '/red', + + // When httpAdminRoot is used to move the UI to a different root path, the + // following property can be used to identify a directory of static content + // that should be served at http://localhost:1880/. + //httpStatic: '/home/nol/node-red-static/', + + // The maximum size of HTTP request that will be accepted by the runtime api. + // Default: 5mb + //apiMaxLength: '5mb', + + // If you installed the optional node-red-dashboard you can set it's path + // relative to httpRoot + ui: { path: "ui" }, + + // Securing Node-RED + // ----------------- + // To password protect the Node-RED editor and admin API, the following + // property can be used. See http://nodered.org/docs/security.html for details. + adminAuth: { + type: "credentials", + users: [{ + username: "{{ nodered_user }}", + password: "{{ nodered_password }}", + permissions: "*" + }] + }, + + // To password protect the node-defined HTTP endpoints (httpNodeRoot), or + // the static content (httpStatic), the following properties can be used. + // The pass field is a bcrypt hash of the password. + // See http://nodered.org/docs/security.html#generating-the-password-hash + //httpNodeAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."}, + //httpStaticAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."}, + + // The following property can be used to enable HTTPS + // See http://nodejs.org/api/https.html#https_https_createserver_options_requestlistener + // for details on its contents. + // See the comment at the top of this file on how to load the `fs` module used by + // this setting. + // + //https: { + // key: fs.readFileSync('privatekey.pem'), + // cert: fs.readFileSync('certificate.pem') + //}, + + // The following property can be used to cause insecure HTTP connections to + // be redirected to HTTPS. + //requireHttps: true + + // The following property can be used to disable the editor. The admin API + // is not affected by this option. To disable both the editor and the admin + // API, use either the httpRoot or httpAdminRoot properties + //disableEditor: false, + + // The following property can be used to configure cross-origin resource sharing + // in the HTTP nodes. + // See https://github.com/troygoode/node-cors#configuration-options for + // details on its contents. The following is a basic permissive set of options: + //httpNodeCors: { + // origin: "*", + // methods: "GET,PUT,POST,DELETE" + //}, + + // If you need to set an http proxy please set an environment variable + // called http_proxy (or HTTP_PROXY) outside of Node-RED in the operating system. + // For example - http_proxy=http://myproxy.com:8080 + // (Setting it here will have no effect) + // You may also specify no_proxy (or NO_PROXY) to supply a comma separated + // list of domains to not proxy, eg - no_proxy=.acme.co,.acme.co.uk + + // The following property can be used to add a custom middleware function + // in front of all http in nodes. This allows custom authentication to be + // applied to all http in nodes, or any other sort of common request processing. + //httpNodeMiddleware: function(req,res,next) { + // // Handle/reject the request, or pass it on to the http in node by calling next(); + // // Optionally skip our rawBodyParser by setting this to true; + // //req.skipRawBodyParser = true; + // next(); + //}, + + // The following property can be used to verify websocket connection attempts. + // This allows, for example, the HTTP request headers to be checked to ensure + // they include valid authentication information. + //webSocketNodeVerifyClient: function(info) { + // // 'info' has three properties: + // // - origin : the value in the Origin header + // // - req : the HTTP request + // // - secure : true if req.connection.authorized or req.connection.encrypted is set + // // + // // The function should return true if the connection should be accepted, false otherwise. + // // + // // Alternatively, if this function is defined to accept a second argument, callback, + // // it can be used to verify the client asynchronously. + // // The callback takes three arguments: + // // - result : boolean, whether to accept the connection or not + // // - code : if result is false, the HTTP error status to return + // // - reason: if result is false, the HTTP reason string to return + //}, + + // Anything in this hash is globally available to all functions. + // It is accessed as context.global. + // eg: + // functionGlobalContext: { os:require('os') } + // can be accessed in a function block as: + // context.global.os + + functionGlobalContext: { + // os:require('os'), + // jfive:require("johnny-five"), + // j5board:require("johnny-five").Board({repl:false}) + }, + + // The following property can be used to order the categories in the editor + // palette. If a node's category is not in the list, the category will get + // added to the end of the palette. + // If not set, the following default order is used: + //paletteCategories: ['subflows', 'input', 'output', 'function', 'social', 'mobile', 'storage', 'analysis', 'advanced'], + + // Configure the logging output + logging: { + // Only console logging is currently supported + console: { + // Level of logging to be recorded. Options are: + // fatal - only those errors which make the application unusable should be recorded + // error - record errors which are deemed fatal for a particular request + fatal errors + // warn - record problems which are non fatal + errors + fatal errors + // info - record information about the general running of the application + warn + error + fatal errors + // debug - record information which is more verbose than info + info + warn + error + fatal errors + // trace - record very detailed logging + debug + info + warn + error + fatal errors + // off - turn off all logging (doesn't affect metrics or audit) + level: "info", + // Whether or not to include metric events in the log output + metrics: false, + // Whether or not to include audit events in the log output + audit: false + } + }, + + // Customising the editor + editorTheme: { + projects: { + // To enable the Projects feature, set this value to true + enabled: false + } + } +} From bacac4ac193d5e85c0aa91dccb1ba027711e4055 Mon Sep 17 00:00:00 2001 From: Anish Mangal Date: Wed, 27 Jun 2018 21:38:53 +0530 Subject: [PATCH 03/52] Update default password from admin to Admin --- roles/mosquitto/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/mosquitto/defaults/main.yml b/roles/mosquitto/defaults/main.yml index bc4baf2a2..4f225127e 100644 --- a/roles/mosquitto/defaults/main.yml +++ b/roles/mosquitto/defaults/main.yml @@ -1,4 +1,4 @@ mosquitto_install: True mosquitto_enabled: False -mosquitto_user: admin +mosquitto_user: Admin mosquitto_password: g0adm1n From b3c52f69767f0f4bffbce8bef9f25e9bad05e097 Mon Sep 17 00:00:00 2001 From: Anish Mangal Date: Wed, 27 Jun 2018 21:39:33 +0530 Subject: [PATCH 04/52] node-red | Update default password from admin to Admin --- roles/nodered/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/nodered/defaults/main.yml b/roles/nodered/defaults/main.yml index b13ce2e6c..c3315263f 100644 --- a/roles/nodered/defaults/main.yml +++ b/roles/nodered/defaults/main.yml @@ -1,4 +1,4 @@ nodered_install: True nodered_enabled: False -nodered_user: admin +nodered_user: Admin nodered_password: g0adm1n From d57a3924752ca126b3ebc693bf55c7585ef767a4 Mon Sep 17 00:00:00 2001 From: Anish Mangal Date: Wed, 27 Jun 2018 22:01:10 +0530 Subject: [PATCH 05/52] Add node-red and mqtt flags to local_vars_min --- vars/local_vars_min.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vars/local_vars_min.yml b/vars/local_vars_min.yml index 8fc3772f4..0fae7addb 100644 --- a/vars/local_vars_min.yml +++ b/vars/local_vars_min.yml @@ -191,6 +191,11 @@ nextcloud_enabled: False wordpress_install: False wordpress_enabled: False +mosquitto_install: False +mosquitto_enabled: False + +nodered_install: False +nodered_enabled: False # 7-EDU-APPS From a34bda2a3485a060efe53fa97f69c0e1ace3624d Mon Sep 17 00:00:00 2001 From: Anish Mangal Date: Wed, 27 Jun 2018 22:02:35 +0530 Subject: [PATCH 06/52] Add node-red and mqtt flags to local_vars_medium --- vars/local_vars_medium.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vars/local_vars_medium.yml b/vars/local_vars_medium.yml index 2c0a04a68..c03ea2221 100644 --- a/vars/local_vars_medium.yml +++ b/vars/local_vars_medium.yml @@ -191,6 +191,11 @@ nextcloud_enabled: True wordpress_install: True wordpress_enabled: True +mosquitto_install: True +mosquitto_enabled: False + +nodered_install: True +nodered_enabled: False # 7-EDU-APPS From 4823104ab1b9ab5ceff16b6c6c5527ec29b2fde8 Mon Sep 17 00:00:00 2001 From: Anish Mangal Date: Wed, 27 Jun 2018 22:03:09 +0530 Subject: [PATCH 07/52] Add node-red and mqtt flags to local_vars_big --- vars/local_vars_big.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vars/local_vars_big.yml b/vars/local_vars_big.yml index f4ead774b..94df4f425 100644 --- a/vars/local_vars_big.yml +++ b/vars/local_vars_big.yml @@ -191,6 +191,11 @@ nextcloud_enabled: True wordpress_install: True wordpress_enabled: True +mosquitto_install: True +mosquitto_enabled: True + +nodered_install: True +nodered_enabled: True # 7-EDU-APPS From d5b38d7525d80606a0e91a6319002f8cef56c418 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 27 Jun 2018 15:43:33 -0400 Subject: [PATCH 08/52] modern/recommended Ansible syntax --- roles/mosquitto/tasks/main.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/roles/mosquitto/tasks/main.yml b/roles/mosquitto/tasks/main.yml index 79599b8c6..37896435c 100644 --- a/roles/mosquitto/tasks/main.yml +++ b/roles/mosquitto/tasks/main.yml @@ -1,6 +1,7 @@ - name: Install Mosquitto - package: name={{ item }} - state=present + package: + name: "{{ item }}" + state: present with_items: - mosquitto - mosquitto-clients From e35013a1796382682f5c4f71f4a3e34773ce1a14 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 27 Jun 2018 15:44:57 -0400 Subject: [PATCH 09/52] modern/recommended Ansible syntax --- roles/nodered/tasks/main.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/roles/nodered/tasks/main.yml b/roles/nodered/tasks/main.yml index 7f739bcf0..ce11ccf2b 100644 --- a/roles/nodered/tasks/main.yml +++ b/roles/nodered/tasks/main.yml @@ -1,14 +1,16 @@ - name: Install nodejs-legacy - package: name={{ item }} - state=present + package: + name: "{{ item }}" + state: present with_items: - nodejs-legacy when: nodered_install tags: download - name: Install npm - package: name={{ item }} - state=present + package: + name: "{{ item }}" + state: present with_items: - npm when: nodered_install From 8cef26738a90fe8011eb2d66b3a13353c90ab726 Mon Sep 17 00:00:00 2001 From: Anish Mangal Date: Tue, 15 Jan 2019 13:43:02 +0000 Subject: [PATCH 10/52] Add nodered, mqtt port variables; nodered hash-password --- roles/mosquitto/defaults/main.yml | 1 + roles/nodered/tasks/main.yml | 62 +++++++++++++++++++++++-------- 2 files changed, 48 insertions(+), 15 deletions(-) diff --git a/roles/mosquitto/defaults/main.yml b/roles/mosquitto/defaults/main.yml index 4f225127e..5acf9ab3f 100644 --- a/roles/mosquitto/defaults/main.yml +++ b/roles/mosquitto/defaults/main.yml @@ -2,3 +2,4 @@ mosquitto_install: True mosquitto_enabled: False mosquitto_user: Admin mosquitto_password: g0adm1n +mosquitto_port: 1883 diff --git a/roles/nodered/tasks/main.yml b/roles/nodered/tasks/main.yml index ce11ccf2b..c2647387e 100644 --- a/roles/nodered/tasks/main.yml +++ b/roles/nodered/tasks/main.yml @@ -1,20 +1,44 @@ -- name: Install nodejs-legacy - package: - name: "{{ item }}" - state: present - with_items: - - nodejs-legacy - when: nodered_install - tags: download +- name: Set up Node.js 8.x apt sources (debuntu, but avoid ubuntu-18) + shell: curl -sL https://deb.nodesource.com/setup_8.x | bash - + args: + warn: no + when: internet_available and is_debuntu and not is_ubuntu_18 -- name: Install npm +- name: Install latest Node.js which includes /usr/bin/npm (debuntu, but avoid ubuntu-18) package: - name: "{{ item }}" - state: present - with_items: - - npm - when: nodered_install - tags: download + name: nodejs + # name: nodejs=8.x + state: latest + # state: present + when: internet_available and is_debuntu and not is_ubuntu_18 + +# 2018-07-14: BOTH STEPS ABOVE TAKE TIME, but Raspbian (apt offers npm +# 1.4.21) & Debian 9 (apt offers no npm!) STILL NEED the above +# nodesource.com approach to get a version of npm that works with Sugarizer: +# https://github.com/iiab/iiab/issues/798#issuecomment-404324530 +# +# MORE POSITIVELY: this nodesource.com approach (brings in npm 5.6.0 with +# nodejs 8.11.3 for now, to any OS) would also work on Ubuntu 18.04, and +# might even bring about a sane consistency across mainline OS's? +# +# BUT FOR NOW: Ubuntu 18.04's apt (approach below) brings in npm 3.5.2, +# which appears suffic "SO FAR"? 18.04's nodejs 8.10.0 is more reassuring! + +# CRAZY IDEA: most versions of npm can upgrade themselves to the latest +# (6.2.0 for now) using command "npm install -g npm", if that helps us in +# future, e.g. TK's memory issue etc? If so, be CAREFUL this puts npm +# in /usr/local/bin on Ubuntu 18.04 -- unlike Ubuntu 16.04 and Raspbian +# where it upgrades /usr/bin/npm in place: +# https://askubuntu.com/questions/1036278/npm-is-incorrect-version-on-latest-ubuntu-18-04-installation + +- name: Install latest packages nodejs and npm (ubuntu-18 or not debuntu) + package: + name: + - nodejs + - npm + state: latest + when: internet_available and (is_ubuntu_18 or not is_debuntu) + - name: Install node-red packages globally. shell: npm install -g --unsafe-perm node-red node-red-admin node-red-dashboard @@ -29,6 +53,14 @@ name: nodered group: nodered +- name: Create /home/nodered/.node-red/ directory + file: + path: "/home/nodered/.node-red" + state: directory + owner: nodered + group: nodered + mode: 0775 + - name: Copy settings.js file with authentication template: backup: yes From b78db708d38ce7d4b853150a4c7feb3285d58def Mon Sep 17 00:00:00 2001 From: Anish Mangal Date: Tue, 15 Jan 2019 13:43:39 +0000 Subject: [PATCH 11/52] Add nodered, mqtt ports to iptables-generator script --- roles/network/templates/gateway/iiab-gen-iptables | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/roles/network/templates/gateway/iiab-gen-iptables b/roles/network/templates/gateway/iiab-gen-iptables index 94f2f49cc..8ced09eb7 100755 --- a/roles/network/templates/gateway/iiab-gen-iptables +++ b/roles/network/templates/gateway/iiab-gen-iptables @@ -62,6 +62,8 @@ cups_port={{ cups_port }} transmission_http_port={{ transmission_http_port }} transmission_peer_port={{ transmission_peer_port }} sugarizer_port={{ sugarizer_port }} +nodered_port={{ nodered_port }} +mosquitto_port={{ mosquitto_port }} block_DNS={{ block_DNS }} echo "LAN is $lan and WAN is $wan" @@ -96,6 +98,8 @@ if [ "$services_externally_visible" == "True" ]; then $IPTABLES -A INPUT -p tcp --dport $calibre_port -m state --state NEW -i $wan -j ACCEPT $IPTABLES -A INPUT -p tcp --dport $cups_port -m state --state NEW -i $wan -j ACCEPT $IPTABLES -A INPUT -p tcp --dport $sugarizer_port -m state --state NEW -i $wan -j ACCEPT + $IPTABLES -A INPUT -p tcp --dport $nodered_port -m state --state NEW -i $wan -j ACCEPT + $IPTABLES -A INPUT -p tcp --dport $mosquitto_port -m state --state NEW -i $wan -j ACCEPT $IPTABLES -A INPUT -p tcp --dport $transmission_http_port -m state --state NEW -i $wan -j ACCEPT $IPTABLES -A INPUT -p tcp --dport $transmission_peer_port -m state --state NEW -i $wan -j ACCEPT fi From e6cd4ad965d16b3d0df181927077ac78301660e4 Mon Sep 17 00:00:00 2001 From: Anish Mangal Date: Tue, 15 Jan 2019 13:44:19 +0000 Subject: [PATCH 12/52] nodered auth: replace password with its hash in settings.js --- roles/nodered/templates/settings.js.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/nodered/templates/settings.js.j2 b/roles/nodered/templates/settings.js.j2 index 867022dd9..eb709304e 100644 --- a/roles/nodered/templates/settings.js.j2 +++ b/roles/nodered/templates/settings.js.j2 @@ -119,7 +119,7 @@ module.exports = { type: "credentials", users: [{ username: "{{ nodered_user }}", - password: "{{ nodered_password }}", + password: "{{ nodered_password_hash }}", permissions: "*" }] }, From 40db7dc72f23ef1300631480e36b7e0d3d638a0f Mon Sep 17 00:00:00 2001 From: Anish Mangal Date: Tue, 15 Jan 2019 13:46:39 +0000 Subject: [PATCH 13/52] nodered: fix default.yml new hash-pw and port --- roles/nodered/defaults/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/roles/nodered/defaults/main.yml b/roles/nodered/defaults/main.yml index c3315263f..dddc8e0c4 100644 --- a/roles/nodered/defaults/main.yml +++ b/roles/nodered/defaults/main.yml @@ -2,3 +2,5 @@ nodered_install: True nodered_enabled: False nodered_user: Admin nodered_password: g0adm1n +nodered_password_hash: $2b$08$yJaHCz1zl3GUYA7YhZ7HMO8cEOrWDxHLVgd8hyFn9aSH7VoAzEUty +nodered_port: 1880 From 6688b7e990d910b001db1c987af39f550d73632e Mon Sep 17 00:00:00 2001 From: Anish Mangal Date: Tue, 15 Jan 2019 14:10:36 +0000 Subject: [PATCH 14/52] Add nodered and mqtt ports to default_vars --- vars/default_vars.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vars/default_vars.yml b/vars/default_vars.yml index 7d10880bc..4d57bffad 100644 --- a/vars/default_vars.yml +++ b/vars/default_vars.yml @@ -289,6 +289,13 @@ nextcloud_enabled: False wordpress_install: False wordpress_enabled: False +mosquitto_install: True +mosquitto_enabled: True +mosquitto_port: 1883 + +nodered_install: True +nodered_enabled: True +nodered_port: 1880 # 7-EDU-APPS From 35d6730d2e9c5c4b3e6e7c29a2181b6f2bcd646d Mon Sep 17 00:00:00 2001 From: Anish Mangal Date: Tue, 15 Jan 2019 14:12:35 +0000 Subject: [PATCH 15/52] Remove nodered and mqtt ports from respective default/main.yml files --- roles/mosquitto/defaults/main.yml | 1 - roles/nodered/defaults/main.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/roles/mosquitto/defaults/main.yml b/roles/mosquitto/defaults/main.yml index 5acf9ab3f..4f225127e 100644 --- a/roles/mosquitto/defaults/main.yml +++ b/roles/mosquitto/defaults/main.yml @@ -2,4 +2,3 @@ mosquitto_install: True mosquitto_enabled: False mosquitto_user: Admin mosquitto_password: g0adm1n -mosquitto_port: 1883 diff --git a/roles/nodered/defaults/main.yml b/roles/nodered/defaults/main.yml index dddc8e0c4..e28f60766 100644 --- a/roles/nodered/defaults/main.yml +++ b/roles/nodered/defaults/main.yml @@ -3,4 +3,3 @@ nodered_enabled: False nodered_user: Admin nodered_password: g0adm1n nodered_password_hash: $2b$08$yJaHCz1zl3GUYA7YhZ7HMO8cEOrWDxHLVgd8hyFn9aSH7VoAzEUty -nodered_port: 1880 From 6632a39740a00eeee80934468d1d519c0e3dc1e2 Mon Sep 17 00:00:00 2001 From: Anish Mangal Date: Tue, 15 Jan 2019 15:07:32 +0000 Subject: [PATCH 16/52] Update nodered and mqtt flags as pwe #1352 --- vars/default_vars.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vars/default_vars.yml b/vars/default_vars.yml index 4d57bffad..b904c77fc 100644 --- a/vars/default_vars.yml +++ b/vars/default_vars.yml @@ -289,12 +289,12 @@ nextcloud_enabled: False wordpress_install: False wordpress_enabled: False -mosquitto_install: True -mosquitto_enabled: True +mosquitto_install: False +mosquitto_enabled: False mosquitto_port: 1883 -nodered_install: True -nodered_enabled: True +nodered_install: False +nodered_enabled: False nodered_port: 1880 # 7-EDU-APPS From 4665768a798f42933fdc25e14beff0060b543998 Mon Sep 17 00:00:00 2001 From: Anish Mangal Date: Tue, 15 Jan 2019 15:23:19 +0000 Subject: [PATCH 17/52] Update nodered and mqtt flags in respective default/main.yml as per #1352 --- roles/mosquitto/defaults/main.yml | 2 +- roles/nodered/defaults/main.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/mosquitto/defaults/main.yml b/roles/mosquitto/defaults/main.yml index 4f225127e..48974bde0 100644 --- a/roles/mosquitto/defaults/main.yml +++ b/roles/mosquitto/defaults/main.yml @@ -1,4 +1,4 @@ -mosquitto_install: True +mosquitto_install: False mosquitto_enabled: False mosquitto_user: Admin mosquitto_password: g0adm1n diff --git a/roles/nodered/defaults/main.yml b/roles/nodered/defaults/main.yml index e28f60766..aadce2b63 100644 --- a/roles/nodered/defaults/main.yml +++ b/roles/nodered/defaults/main.yml @@ -1,4 +1,4 @@ -nodered_install: True +nodered_install: False nodered_enabled: False nodered_user: Admin nodered_password: g0adm1n From c6181b5deb0291a38ce0da9c7a34988700207600 Mon Sep 17 00:00:00 2001 From: Anish Mangal Date: Tue, 15 Jan 2019 16:32:59 +0000 Subject: [PATCH 18/52] nodered, mqtt: fix bug when install flags are disabled --- roles/mosquitto/tasks/main.yml | 5 +++++ roles/nodered/tasks/main.yml | 12 +++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/roles/mosquitto/tasks/main.yml b/roles/mosquitto/tasks/main.yml index 37896435c..2b029dec4 100644 --- a/roles/mosquitto/tasks/main.yml +++ b/roles/mosquitto/tasks/main.yml @@ -12,20 +12,24 @@ service: name: mosquitto enabled: no + when: mosquitto_install - name: Stop mosquitto service: name: mosquitto state: stopped + when: mosquitto_install - name: Create mosquitto passwd file file: path: /etc/mosquitto/passwd state: touch mode: "u=rw,g=r,o=r" + when: mosquitto_install - name: Create mosquitto username/password shell: mosquitto_passwd -b /etc/mosquitto/passwd "{{ mosquitto_user }}" "{{ mosquitto_password }}" + when: mosquitto_install - name: Create mosquitto config file template: @@ -37,6 +41,7 @@ mode: "{{ item.mode }}" with_items: - { src: 'websockets.conf.j2' , dest: '/etc/mosquitto/conf.d/websockets.conf', mode: '0755' } + when: mosquitto_install - name: Enable mosquitto service: diff --git a/roles/nodered/tasks/main.yml b/roles/nodered/tasks/main.yml index c2647387e..1ab73fc6b 100644 --- a/roles/nodered/tasks/main.yml +++ b/roles/nodered/tasks/main.yml @@ -2,7 +2,7 @@ shell: curl -sL https://deb.nodesource.com/setup_8.x | bash - args: warn: no - when: internet_available and is_debuntu and not is_ubuntu_18 + when: internet_available and is_debuntu and not is_ubuntu_18 and nodered_install - name: Install latest Node.js which includes /usr/bin/npm (debuntu, but avoid ubuntu-18) package: @@ -10,7 +10,7 @@ # name: nodejs=8.x state: latest # state: present - when: internet_available and is_debuntu and not is_ubuntu_18 + when: internet_available and is_debuntu and not is_ubuntu_18 and nodered_install # 2018-07-14: BOTH STEPS ABOVE TAKE TIME, but Raspbian (apt offers npm # 1.4.21) & Debian 9 (apt offers no npm!) STILL NEED the above @@ -37,21 +37,24 @@ - nodejs - npm state: latest - when: internet_available and (is_ubuntu_18 or not is_debuntu) + when: internet_available and (is_ubuntu_18 or not is_debuntu) and nodered_install - name: Install node-red packages globally. shell: npm install -g --unsafe-perm node-red node-red-admin node-red-dashboard + when: nodered_install - name: Create nodered usergroup group: name: nodered state: present + when: nodered_install - name: Add the user nodered and add to nodered group user: name: nodered group: nodered + when: nodered_install - name: Create /home/nodered/.node-red/ directory file: @@ -60,6 +63,7 @@ owner: nodered group: nodered mode: 0775 + when: nodered_install - name: Copy settings.js file with authentication template: @@ -71,6 +75,7 @@ mode: "{{ item.mode }}" with_items: - { src: 'settings.js.j2' , dest: '/home/nodered/.node-red/settings.js', mode: '0755' } + when: nodered_install - name: Create node-red systemd file template: @@ -82,6 +87,7 @@ mode: "{{ item.mode }}" with_items: - { src: 'node-red.service.j2' , dest: '/etc/systemd/system/node-red.service', mode: '0755' } + when: nodered_install - name: Enable node-red service: From 291b39e3679633b1d3dd04646c0e472f11602ffb Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 15 Jan 2019 12:51:41 -0500 Subject: [PATCH 19/52] Update README.rst --- roles/mosquitto/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/mosquitto/README.rst b/roles/mosquitto/README.rst index ae9d5ca9f..5ac69147b 100644 --- a/roles/mosquitto/README.rst +++ b/roles/mosquitto/README.rst @@ -1,3 +1,3 @@ -Adds the mosquitto pub-sub broker to the iiab. +Adds the `Mosquitto `_ (`MQTT `_) `pub-sub `_ broker to Internet-in-a-Box (IIAB) for educational experiments with `IoT `_. Roughly follows this guide: https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-the-mosquitto-mqtt-messaging-broker-on-ubuntu-16-04 From f6f3461445d9f20a3fb20e01f76f9b82fe2e6ab2 Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 15 Jan 2019 12:58:23 -0500 Subject: [PATCH 20/52] Update README.rst --- roles/nodered/README.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/roles/nodered/README.rst b/roles/nodered/README.rst index 01f9a08e4..f1e97232b 100644 --- a/roles/nodered/README.rst +++ b/roles/nodered/README.rst @@ -1 +1,3 @@ -Adds node-red and node-red dashboard to the schoolserver +Adds `Node-RED `_ and `Node-RED Dashboard `_ to Internet-in-a-Box (IIAB) for educational experiments with `IoT `_. + +SEE ALSO: `roles/mosquitto/README.rst <../mosquitto/README.rst>`_ From 344b2c5444a8192d2c6bf28ca7024ac8dbc8b834 Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 15 Jan 2019 13:00:17 -0500 Subject: [PATCH 21/52] Update README.rst --- roles/mosquitto/README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/roles/mosquitto/README.rst b/roles/mosquitto/README.rst index 5ac69147b..1ac3e4b41 100644 --- a/roles/mosquitto/README.rst +++ b/roles/mosquitto/README.rst @@ -1,3 +1,5 @@ Adds the `Mosquitto `_ (`MQTT `_) `pub-sub `_ broker to Internet-in-a-Box (IIAB) for educational experiments with `IoT `_. Roughly follows this guide: https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-the-mosquitto-mqtt-messaging-broker-on-ubuntu-16-04 + +SEE ALSO: `Node-RED <../nodered/README.rst>`_ From 0d47ee779d6cbc8661c8dae151c9b65148236a22 Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 15 Jan 2019 13:01:01 -0500 Subject: [PATCH 22/52] Update README.rst --- roles/nodered/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/nodered/README.rst b/roles/nodered/README.rst index f1e97232b..0b228d752 100644 --- a/roles/nodered/README.rst +++ b/roles/nodered/README.rst @@ -1,3 +1,3 @@ Adds `Node-RED `_ and `Node-RED Dashboard `_ to Internet-in-a-Box (IIAB) for educational experiments with `IoT `_. -SEE ALSO: `roles/mosquitto/README.rst <../mosquitto/README.rst>`_ +SEE ALSO: `Mosquitto (MQTT) <../mosquitto/README.rst>`_ From 0dd7c981b15eb39f6a319993d04d5c8105dec669 Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 15 Jan 2019 13:05:53 -0500 Subject: [PATCH 23/52] Don't install Mosquitto & Node-RED on MEDIUM-sized --- vars/local_vars_medium.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vars/local_vars_medium.yml b/vars/local_vars_medium.yml index c03ea2221..58ec618a8 100644 --- a/vars/local_vars_medium.yml +++ b/vars/local_vars_medium.yml @@ -191,10 +191,10 @@ nextcloud_enabled: True wordpress_install: True wordpress_enabled: True -mosquitto_install: True +mosquitto_install: False mosquitto_enabled: False -nodered_install: True +nodered_install: False nodered_enabled: False # 7-EDU-APPS From 85bef4802aa5469a94b9e144a8e4cc50f1844c7d Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 15 Jan 2019 13:18:09 -0500 Subject: [PATCH 24/52] tighter code, more complete explanations --- roles/mosquitto/tasks/main.yml | 36 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/roles/mosquitto/tasks/main.yml b/roles/mosquitto/tasks/main.yml index 2b029dec4..45a4d7efd 100644 --- a/roles/mosquitto/tasks/main.yml +++ b/roles/mosquitto/tasks/main.yml @@ -1,4 +1,4 @@ -- name: Install Mosquitto +- name: Install mosquitto & mosquitto-clients package: name: "{{ item }}" state: present @@ -8,49 +8,37 @@ when: mosquitto_install tags: download -- name: Disable mosquitto - service: +- name: Disable & Stop mosquitto service + systemd: name: mosquitto enabled: no - when: mosquitto_install - -- name: Stop mosquitto - service: - name: mosquitto state: stopped when: mosquitto_install -- name: Create mosquitto passwd file +- name: Create (touch) file /etc/mosquitto/passwd file: path: /etc/mosquitto/passwd state: touch - mode: "u=rw,g=r,o=r" + mode: "u=rw,g=r,o=r" # 0644 when: mosquitto_install -- name: Create mosquitto username/password +- name: Populate /etc/mosquitto/passwd with actual username/password shell: mosquitto_passwd -b /etc/mosquitto/passwd "{{ mosquitto_user }}" "{{ mosquitto_password }}" when: mosquitto_install -- name: Create mosquitto config file +- name: Install /etc/mosquitto/conf.d/websockets.conf from template template: backup: yes - src: "{{ item.src }}" - dest: "{{ item.dest }}" + src: websockets.conf.j2 + dest: /etc/mosquitto/conf.d/websockets.conf owner: root group: root - mode: "{{ item.mode }}" - with_items: - - { src: 'websockets.conf.j2' , dest: '/etc/mosquitto/conf.d/websockets.conf', mode: '0755' } + mode: 0755 when: mosquitto_install -- name: Enable mosquitto - service: +- name: Enable & Start mosquitto service + systemd: name: mosquitto enabled: yes - when: mosquitto_enabled - -- name: Start mosquitto - service: - name: mosquitto state: started when: mosquitto_enabled From 7c731746bc34c4e0190cc8e241c1a327a0bc1ce3 Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 15 Jan 2019 13:46:45 -0500 Subject: [PATCH 25/52] Update main.yml --- roles/nodered/tasks/main.yml | 73 ++++++++++++------------------------ 1 file changed, 25 insertions(+), 48 deletions(-) diff --git a/roles/nodered/tasks/main.yml b/roles/nodered/tasks/main.yml index 1ab73fc6b..68dd84809 100644 --- a/roles/nodered/tasks/main.yml +++ b/roles/nodered/tasks/main.yml @@ -1,56 +1,42 @@ -- name: Set up Node.js 8.x apt sources (debuntu, but avoid ubuntu-18) +- name: Set up Node.js 8.x apt sources (debuntu distros up to 2017) shell: curl -sL https://deb.nodesource.com/setup_8.x | bash - args: warn: no - when: internet_available and is_debuntu and not is_ubuntu_18 and nodered_install - -- name: Install latest Node.js which includes /usr/bin/npm (debuntu, but avoid ubuntu-18) + when: internet_available and (is_debian_8 or is_debian_9) and nodered_install + # NOT NEC TO TEST FOR is_raspbian_8 OR is_raspbian_9 AS /opt/iiab/iiab/vars/.yml + # DEFINES THESE AS SUBSETS OF is_debian_8 OR is_debian_9 (FOR NOW!) + +- name: Install latest Node.js which includes /usr/bin/npm (debuntu distros up to 2017) package: name: nodejs # name: nodejs=8.x state: latest # state: present - when: internet_available and is_debuntu and not is_ubuntu_18 and nodered_install + when: internet_available and (is_debian_8 or is_debian_9) and nodered_install -# 2018-07-14: BOTH STEPS ABOVE TAKE TIME, but Raspbian (apt offers npm -# 1.4.21) & Debian 9 (apt offers no npm!) STILL NEED the above -# nodesource.com approach to get a version of npm that works with Sugarizer: -# https://github.com/iiab/iiab/issues/798#issuecomment-404324530 -# -# MORE POSITIVELY: this nodesource.com approach (brings in npm 5.6.0 with -# nodejs 8.11.3 for now, to any OS) would also work on Ubuntu 18.04, and -# might even bring about a sane consistency across mainline OS's? -# -# BUT FOR NOW: Ubuntu 18.04's apt (approach below) brings in npm 3.5.2, -# which appears suffic "SO FAR"? 18.04's nodejs 8.10.0 is more reassuring! +# 2019-01-15: WE'RE BORROWING npm INSTALLATION TRICKS FROM MID-2018 SUGARIZER: +# https://github.com/iiab/iiab/blob/master/roles/sugarizer/tasks/main.yml#L77-L94 -# CRAZY IDEA: most versions of npm can upgrade themselves to the latest -# (6.2.0 for now) using command "npm install -g npm", if that helps us in -# future, e.g. TK's memory issue etc? If so, be CAREFUL this puts npm -# in /usr/local/bin on Ubuntu 18.04 -- unlike Ubuntu 16.04 and Raspbian -# where it upgrades /usr/bin/npm in place: -# https://askubuntu.com/questions/1036278/npm-is-incorrect-version-on-latest-ubuntu-18-04-installation - -- name: Install latest packages nodejs and npm (ubuntu-18 or not debuntu) +- name: Install latest packages nodejs and npm (debuntu distros after 2017, or other distros) package: name: - nodejs - npm state: latest - when: internet_available and (is_ubuntu_18 or not is_debuntu) and nodered_install + when: internet_available and not (is_debian_8 or is_debian_9) and nodered_install -- name: Install node-red packages globally. +- name: 'npm install node-red packages globally: node-red, node-red-admin, node-red-dashboard' shell: npm install -g --unsafe-perm node-red node-red-admin node-red-dashboard when: nodered_install -- name: Create nodered usergroup +- name: Ensure Linux group "nodered" exists group: name: nodered state: present when: nodered_install -- name: Add the user nodered and add to nodered group +- name: Ensure Linux user "nodered" exists and is added to group "nodered" user: name: nodered group: nodered @@ -58,45 +44,36 @@ - name: Create /home/nodered/.node-red/ directory file: - path: "/home/nodered/.node-red" + path: /home/nodered/.node-red state: directory owner: nodered group: nodered mode: 0775 when: nodered_install -- name: Copy settings.js file with authentication +- name: Install /home/nodered/.node-red/settings.js from template, with authentication template: backup: yes - src: "{{ item.src }}" - dest: "{{ item.dest }}" + src: settings.js.j2 + dest: /home/nodered/.node-red/settings.js owner: nodered group: nodered - mode: "{{ item.mode }}" - with_items: - - { src: 'settings.js.j2' , dest: '/home/nodered/.node-red/settings.js', mode: '0755' } + mode: 0755 when: nodered_install -- name: Create node-red systemd file +- name: Install /etc/systemd/system/node-red.service systemd unit file from template template: backup: yes - src: "{{ item.src }}" - dest: "{{ item.dest }}" + src: node-red.service.j2 + dest: /etc/systemd/system/node-red.service owner: root group: root - mode: "{{ item.mode }}" - with_items: - - { src: 'node-red.service.j2' , dest: '/etc/systemd/system/node-red.service', mode: '0755' } + mode: 0755 when: nodered_install -- name: Enable node-red - service: +- name: Enable & Start node-red service + systemd: name: node-red enabled: yes - when: nodered_enabled - -- name: Start node-red - service: - name: node-red state: started when: nodered_enabled From 2db67740f6a2707804b0b57a4c378b239900bcff Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 15 Jan 2019 13:48:52 -0500 Subject: [PATCH 26/52] Update main.yml --- roles/nextcloud/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/nextcloud/tasks/main.yml b/roles/nextcloud/tasks/main.yml index e09f43644..b7eb5f2f7 100644 --- a/roles/nextcloud/tasks/main.yml +++ b/roles/nextcloud/tasks/main.yml @@ -63,7 +63,7 @@ package: name: "php{{ php_version }}-mcrypt" state: present - when: is_debuntu and (is_debian_8 or is_debian_9 or is_ubuntu_16 or is_ubuntu_17) + when: is_debian_8 or is_debian_9 or is_ubuntu_16 or is_ubuntu_17 # NOT NEC TO TEST FOR is_raspbian_8 OR is_raspbian_9 AS /opt/iiab/iiab/vars/.yml # DEFINES THESE AS SUBSETS OF is_debian_8 OR is_debian_9 (FOR NOW!) From 5acd823020a1a42b21d09d52f1f4e00a49f1dfc7 Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 15 Jan 2019 13:50:37 -0500 Subject: [PATCH 27/52] Update main.yml --- roles/nodered/tasks/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/nodered/tasks/main.yml b/roles/nodered/tasks/main.yml index 68dd84809..bd4057b41 100644 --- a/roles/nodered/tasks/main.yml +++ b/roles/nodered/tasks/main.yml @@ -2,7 +2,7 @@ shell: curl -sL https://deb.nodesource.com/setup_8.x | bash - args: warn: no - when: internet_available and (is_debian_8 or is_debian_9) and nodered_install + when: internet_available and (is_debian_8 or is_debian_9 or is_ubuntu_16 or is_ubuntu_17) and nodered_install # NOT NEC TO TEST FOR is_raspbian_8 OR is_raspbian_9 AS /opt/iiab/iiab/vars/.yml # DEFINES THESE AS SUBSETS OF is_debian_8 OR is_debian_9 (FOR NOW!) @@ -12,7 +12,7 @@ # name: nodejs=8.x state: latest # state: present - when: internet_available and (is_debian_8 or is_debian_9) and nodered_install + when: internet_available and (is_debian_8 or is_debian_9 or is_ubuntu_16 or is_ubuntu_17) and nodered_install # 2019-01-15: WE'RE BORROWING npm INSTALLATION TRICKS FROM MID-2018 SUGARIZER: # https://github.com/iiab/iiab/blob/master/roles/sugarizer/tasks/main.yml#L77-L94 @@ -23,7 +23,7 @@ - nodejs - npm state: latest - when: internet_available and not (is_debian_8 or is_debian_9) and nodered_install + when: internet_available and not (is_debian_8 or is_debian_9 or is_ubuntu_16 or is_ubuntu_17) and nodered_install - name: 'npm install node-red packages globally: node-red, node-red-admin, node-red-dashboard' From ad6cef52bae5e18273df039f8eb68adea5f3713b Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 15 Jan 2019 14:05:43 -0500 Subject: [PATCH 28/52] attempt to future-proof Sugarizer for new distros --- roles/sugarizer/tasks/main.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/roles/sugarizer/tasks/main.yml b/roles/sugarizer/tasks/main.yml index ef494b463..7052d19c3 100644 --- a/roles/sugarizer/tasks/main.yml +++ b/roles/sugarizer/tasks/main.yml @@ -60,19 +60,23 @@ # 3. INSTALL A GOOD VERSION OF Node.js AND npm -- name: Set up Node.js 8.x apt sources (debuntu, but avoid ubuntu-18) +- name: Set up Node.js 8.x apt sources (debuntu distros up to 2017) shell: curl -sL https://deb.nodesource.com/setup_8.x | bash - args: warn: no - when: internet_available and is_debuntu and not is_ubuntu_18 + when: internet_available and (is_debian_8 or is_debian_9 or is_ubuntu_16 or is_ubuntu_17) + # NOT NEC TO TEST FOR is_raspbian_8 OR is_raspbian_9 AS /opt/iiab/iiab/vars/.yml + # DEFINES THESE AS SUBSETS OF is_debian_8 OR is_debian_9 (FOR NOW!) -- name: Install latest Node.js which includes /usr/bin/npm (debuntu, but avoid ubuntu-18) +- name: Install latest Node.js which includes /usr/bin/npm (debuntu distros up to 2017) package: name: nodejs # name: nodejs=8.x state: latest # state: present - when: internet_available and is_debuntu and not is_ubuntu_18 + when: internet_available and (is_debian_8 or is_debian_9 or is_ubuntu_16 or is_ubuntu_17) + +# 2019-01-15: BORROWED BY https://github.com/iiab/iiab/blob/master/roles/nodered/tasks/main.yml#L1-L26 # 2018-07-14: BOTH STEPS ABOVE TAKE TIME, but Raspbian (apt offers npm # 1.4.21) & Debian 9 (apt offers no npm!) STILL NEED the above @@ -93,13 +97,13 @@ # where it upgrades /usr/bin/npm in place: # https://askubuntu.com/questions/1036278/npm-is-incorrect-version-on-latest-ubuntu-18-04-installation -- name: Install latest packages nodejs and npm (ubuntu-18 or not debuntu) +- name: Install latest packages nodejs and npm (debuntu distros after 2017, or other distros) package: name: - nodejs - npm state: latest - when: internet_available and (is_ubuntu_18 or not is_debuntu) + when: internet_available and not (is_debian_8 or is_debian_9 or is_ubuntu_16 or is_ubuntu_17) # 4. RUN "npm install" TO POPULATE ~35MB /opt/iiab/sugarizer-server/node_modules From 1ef626fe583a6758325ab61cc8005e39a1d78b08 Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 15 Jan 2019 14:24:24 -0500 Subject: [PATCH 29/52] Update main.yml --- roles/6-generic-apps/tasks/main.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/roles/6-generic-apps/tasks/main.yml b/roles/6-generic-apps/tasks/main.yml index a33bddbc2..27cebdf08 100644 --- a/roles/6-generic-apps/tasks/main.yml +++ b/roles/6-generic-apps/tasks/main.yml @@ -33,6 +33,18 @@ when: lokole_install tags: lokole +- name: MOSQUITTO + include_role: + name: mosquitto + when: mosquitto_install + tags: mosquitto + +- name: NODE-RED + include_role: + name: nodered + when: nodered_install + tags: nodered + - name: NEXTCLOUD include_role: name: nextcloud @@ -51,18 +63,6 @@ when: wordpress_install tags: wordpress -- name: MOSQUITTO - include_role: - name: mosquitto - when: mosquitto_install - tags: mosquitto - -- name: NODE-RED - include_role: - name: nodered - when: nodered_install - tags: nodered - - name: Recording STAGE 6 HAS COMPLETED ==================== lineinfile: dest: "{{ iiab_env_file }}" From 39839b6af4711f5d8c096abb7e4f50f160300efc Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 15 Jan 2019 16:13:26 -0500 Subject: [PATCH 30/52] Update local_vars_min.yml --- vars/local_vars_min.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vars/local_vars_min.yml b/vars/local_vars_min.yml index 0fae7addb..4a9d33602 100644 --- a/vars/local_vars_min.yml +++ b/vars/local_vars_min.yml @@ -184,6 +184,12 @@ ejabberd_enabled: False lokole_install: False lokole_enabled: False +mosquitto_install: False +mosquitto_enabled: False + +nodered_install: False +nodered_enabled: False + nextcloud_install: False nextcloud_enabled: False @@ -191,12 +197,6 @@ nextcloud_enabled: False wordpress_install: False wordpress_enabled: False -mosquitto_install: False -mosquitto_enabled: False - -nodered_install: False -nodered_enabled: False - # 7-EDU-APPS # KA Lite - SEE THE "Transmission" BITTORRENT DOWNLOADER FURTHER BELOW, TO INSTALL THOUSANDS OF VIDEOS From 93108c0069f5da77c6a22b188852e4a6284018b0 Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 15 Jan 2019 16:13:55 -0500 Subject: [PATCH 31/52] Update local_vars_medium.yml --- vars/local_vars_medium.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vars/local_vars_medium.yml b/vars/local_vars_medium.yml index 58ec618a8..36e36e8e3 100644 --- a/vars/local_vars_medium.yml +++ b/vars/local_vars_medium.yml @@ -184,6 +184,12 @@ ejabberd_enabled: False lokole_install: False lokole_enabled: False +mosquitto_install: False +mosquitto_enabled: False + +nodered_install: False +nodered_enabled: False + nextcloud_install: True nextcloud_enabled: True @@ -191,12 +197,6 @@ nextcloud_enabled: True wordpress_install: True wordpress_enabled: True -mosquitto_install: False -mosquitto_enabled: False - -nodered_install: False -nodered_enabled: False - # 7-EDU-APPS # KA Lite - SEE THE "Transmission" BITTORRENT DOWNLOADER FURTHER BELOW, TO INSTALL THOUSANDS OF VIDEOS From 3999feae34372d8488c78fab0cefaca89309ff42 Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 15 Jan 2019 16:14:27 -0500 Subject: [PATCH 32/52] Update local_vars_big.yml --- vars/local_vars_big.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vars/local_vars_big.yml b/vars/local_vars_big.yml index 94df4f425..c3119361c 100644 --- a/vars/local_vars_big.yml +++ b/vars/local_vars_big.yml @@ -184,6 +184,12 @@ ejabberd_enabled: False lokole_install: True lokole_enabled: True +mosquitto_install: True +mosquitto_enabled: True + +nodered_install: True +nodered_enabled: True + nextcloud_install: True nextcloud_enabled: True @@ -191,12 +197,6 @@ nextcloud_enabled: True wordpress_install: True wordpress_enabled: True -mosquitto_install: True -mosquitto_enabled: True - -nodered_install: True -nodered_enabled: True - # 7-EDU-APPS # KA Lite - SEE THE "Transmission" BITTORRENT DOWNLOADER FURTHER BELOW, TO INSTALL THOUSANDS OF VIDEOS From fd65fccf58b9ae716ace86718ca9e7aa3b34cd6a Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 15 Jan 2019 16:20:30 -0500 Subject: [PATCH 33/52] Update default_vars.yml --- vars/default_vars.yml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/vars/default_vars.yml b/vars/default_vars.yml index b904c77fc..424838f2f 100644 --- a/vars/default_vars.yml +++ b/vars/default_vars.yml @@ -282,6 +282,16 @@ ejabberd_enabled: False lokole_install: False lokole_enabled: False +# MQTT pub-sub broker for IoT on Raspberry Pi etc +mosquitto_install: False +mosquitto_enabled: False +mosquitto_port: 1883 + +# Flow-based visual programming for wiring together IoT hardware devices etc +nodered_install: False +nodered_enabled: False +nodered_port: 1880 + nextcloud_install: False nextcloud_enabled: False @@ -289,14 +299,6 @@ nextcloud_enabled: False wordpress_install: False wordpress_enabled: False -mosquitto_install: False -mosquitto_enabled: False -mosquitto_port: 1883 - -nodered_install: False -nodered_enabled: False -nodered_port: 1880 - # 7-EDU-APPS # KA Lite - SEE THE "Transmission" BITTORRENT DOWNLOADER FURTHER BELOW, TO INSTALL THOUSANDS OF VIDEOS From ec07c530b3ed447d7c48a6d5c7a4f32455d6101c Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 15 Jan 2019 16:21:36 -0500 Subject: [PATCH 34/52] Update local_vars_big.yml --- vars/local_vars_big.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vars/local_vars_big.yml b/vars/local_vars_big.yml index c3119361c..faefa910d 100644 --- a/vars/local_vars_big.yml +++ b/vars/local_vars_big.yml @@ -184,9 +184,11 @@ ejabberd_enabled: False lokole_install: True lokole_enabled: True +# MQTT pub-sub broker for IoT on Raspberry Pi etc mosquitto_install: True mosquitto_enabled: True +# Flow-based visual programming for wiring together IoT hardware devices etc nodered_install: True nodered_enabled: True From d5d9f9e177f3a37ee451b5f062cf826c8a4a7a85 Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 15 Jan 2019 16:22:40 -0500 Subject: [PATCH 35/52] Update local_vars_medium.yml --- vars/local_vars_medium.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vars/local_vars_medium.yml b/vars/local_vars_medium.yml index 36e36e8e3..cfa6ac0e8 100644 --- a/vars/local_vars_medium.yml +++ b/vars/local_vars_medium.yml @@ -184,9 +184,11 @@ ejabberd_enabled: False lokole_install: False lokole_enabled: False +# MQTT pub-sub broker for IoT on Raspberry Pi etc mosquitto_install: False mosquitto_enabled: False +# Flow-based visual programming for wiring together IoT hardware devices etc nodered_install: False nodered_enabled: False From a71b42e5dc6040f6a29e706e8f637d50064b3267 Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 15 Jan 2019 16:23:21 -0500 Subject: [PATCH 36/52] Update local_vars_min.yml --- vars/local_vars_min.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vars/local_vars_min.yml b/vars/local_vars_min.yml index 4a9d33602..88446893f 100644 --- a/vars/local_vars_min.yml +++ b/vars/local_vars_min.yml @@ -184,9 +184,11 @@ ejabberd_enabled: False lokole_install: False lokole_enabled: False +# MQTT pub-sub broker for IoT on Raspberry Pi etc mosquitto_install: False mosquitto_enabled: False +# Flow-based visual programming for wiring together IoT hardware devices etc nodered_install: False nodered_enabled: False From cdbbfecf631034ef606a6aedb8e1ebc1ce798c2a Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 15 Jan 2019 16:24:46 -0500 Subject: [PATCH 37/52] Update README.rst --- roles/nodered/README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/roles/nodered/README.rst b/roles/nodered/README.rst index 0b228d752..32f3ca0cc 100644 --- a/roles/nodered/README.rst +++ b/roles/nodered/README.rst @@ -1,3 +1,5 @@ Adds `Node-RED `_ and `Node-RED Dashboard `_ to Internet-in-a-Box (IIAB) for educational experiments with `IoT `_. +Node-RED is a flow-based development tool for visual programming developed originally by IBM for wiring together hardware devices, APIs and online services as part of the Internet of Things. Node-RED provides a web browser-based flow editor, which can be used to create JavaScript functions. + SEE ALSO: `Mosquitto (MQTT) <../mosquitto/README.rst>`_ From b534ecdf560e621f47f8504f4c09d24938146a18 Mon Sep 17 00:00:00 2001 From: Anish Mangal Date: Wed, 16 Jan 2019 03:43:41 +0000 Subject: [PATCH 38/52] Fix node red executable path in service file per host OS --- roles/nodered/templates/node-red.service.j2 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/roles/nodered/templates/node-red.service.j2 b/roles/nodered/templates/node-red.service.j2 index 00527689d..aace44507 100644 --- a/roles/nodered/templates/node-red.service.j2 +++ b/roles/nodered/templates/node-red.service.j2 @@ -3,7 +3,11 @@ Description=Node-RED After=syslog.target network.target [Service] +{% if is_debian_8 or is_debian_9 or is_ubuntu_16 or is_ubuntu_17 %} +ExecStart=/usr/bin/node-red-pi --max-old-space-size=128 -v +{% else %} ExecStart=/usr/local/bin/node-red-pi --max-old-space-size=128 -v +{% endif %} Restart=on-failure KillSignal=SIGINT From 3d5058f74a3aae88294542b1ffe8eb33bee23287 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 16 Jan 2019 01:18:19 -0500 Subject: [PATCH 39/52] "systemctl daemon_reload" before node-red service enabled/started --- roles/nodered/tasks/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/nodered/tasks/main.yml b/roles/nodered/tasks/main.yml index bd4057b41..57f4da42f 100644 --- a/roles/nodered/tasks/main.yml +++ b/roles/nodered/tasks/main.yml @@ -73,6 +73,7 @@ - name: Enable & Start node-red service systemd: + daemon_reload: yes name: node-red enabled: yes state: started From f3e144eb6be7c25dd9600c4657e2626f62f29c28 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 16 Jan 2019 01:22:35 -0500 Subject: [PATCH 40/52] "systemctl daemon_reload" before mosquitto service enabled/started --- roles/mosquitto/tasks/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/mosquitto/tasks/main.yml b/roles/mosquitto/tasks/main.yml index 45a4d7efd..d966e01ec 100644 --- a/roles/mosquitto/tasks/main.yml +++ b/roles/mosquitto/tasks/main.yml @@ -38,6 +38,7 @@ - name: Enable & Start mosquitto service systemd: + daemon_reload: yes name: mosquitto enabled: yes state: started From d9118bdbeb5cb386ae6d571d342e081009cc60b1 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 16 Jan 2019 01:28:42 -0500 Subject: [PATCH 41/52] Update main.yml --- roles/mosquitto/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/mosquitto/defaults/main.yml b/roles/mosquitto/defaults/main.yml index 48974bde0..2d7190be4 100644 --- a/roles/mosquitto/defaults/main.yml +++ b/roles/mosquitto/defaults/main.yml @@ -1,4 +1,4 @@ mosquitto_install: False mosquitto_enabled: False mosquitto_user: Admin -mosquitto_password: g0adm1n +mosquitto_password: changeme From 0ca70009c9ea2934373b48dd504c1b57201cf912 Mon Sep 17 00:00:00 2001 From: Anish Mangal Date: Wed, 16 Jan 2019 12:00:35 +0530 Subject: [PATCH 42/52] node-red: Update default password to changeme --- roles/nodered/defaults/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/nodered/defaults/main.yml b/roles/nodered/defaults/main.yml index aadce2b63..e1cc6d548 100644 --- a/roles/nodered/defaults/main.yml +++ b/roles/nodered/defaults/main.yml @@ -1,5 +1,5 @@ nodered_install: False nodered_enabled: False nodered_user: Admin -nodered_password: g0adm1n -nodered_password_hash: $2b$08$yJaHCz1zl3GUYA7YhZ7HMO8cEOrWDxHLVgd8hyFn9aSH7VoAzEUty +nodered_password: changeme +nodered_password_hash: $2b$08$oxgvoU9et3deSbXY8UNVTOWHSTQAyEASIal86RHVMqYQJhpPMNz7q From f690ed5676ff9a15482a2bda7c57c073be805187 Mon Sep 17 00:00:00 2001 From: Anish Mangal Date: Wed, 16 Jan 2019 12:02:00 +0530 Subject: [PATCH 43/52] Update main.yml --- roles/nodered/defaults/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/roles/nodered/defaults/main.yml b/roles/nodered/defaults/main.yml index e1cc6d548..a02540ec6 100644 --- a/roles/nodered/defaults/main.yml +++ b/roles/nodered/defaults/main.yml @@ -1,5 +1,7 @@ nodered_install: False nodered_enabled: False nodered_user: Admin +# To generate a new password, run 'node-red-admin hash-pw' and enter the new password. +# Copy the resulting hash to /home/nodered/.node-red/settings.js nodered_password: changeme nodered_password_hash: $2b$08$oxgvoU9et3deSbXY8UNVTOWHSTQAyEASIal86RHVMqYQJhpPMNz7q From b9e3ee32dcdc0ad64bd129e7b99a23d02cc6b35d Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 16 Jan 2019 01:41:29 -0500 Subject: [PATCH 44/52] Update README.rst --- roles/nodered/README.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/roles/nodered/README.rst b/roles/nodered/README.rst index 32f3ca0cc..cbe772aa2 100644 --- a/roles/nodered/README.rst +++ b/roles/nodered/README.rst @@ -2,4 +2,14 @@ Adds `Node-RED `_ and `Node-RED Dashboard `_ contains: + + nodered_install: True + nodered_enabled: True + +After installing Node-RED as part IIAB, please log in to http://box:1880 with: + + Username: Admin + Password: changeme + SEE ALSO: `Mosquitto (MQTT) <../mosquitto/README.rst>`_ From d36c09bf9c6557b98b433c6795d10033de594309 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 16 Jan 2019 01:53:11 -0500 Subject: [PATCH 45/52] Update README.rst --- roles/nodered/README.rst | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/roles/nodered/README.rst b/roles/nodered/README.rst index cbe772aa2..fbd264110 100644 --- a/roles/nodered/README.rst +++ b/roles/nodered/README.rst @@ -1,15 +1,26 @@ +=============== +Node-RED README +=============== + Adds `Node-RED `_ and `Node-RED Dashboard `_ to Internet-in-a-Box (IIAB) for educational experiments with `IoT `_. Node-RED is a flow-based development tool for visual programming developed originally by IBM for wiring together hardware devices, APIs and online services as part of the Internet of Things. Node-RED provides a web browser-based flow editor, which can be used to create JavaScript functions. -Prior to installing IIAB, make sure your `/etc/iiab/local_vars.yml `_ contains: +Using It +-------- + +Prior to installing IIAB, make sure your `/etc/iiab/local_vars.yml `_ contains:: nodered_install: True nodered_enabled: True After installing Node-RED as part IIAB, please log in to http://box:1880 with: - Username: Admin - Password: changeme +Username: ``Admin`` -SEE ALSO: `Mosquitto (MQTT) <../mosquitto/README.rst>`_ +Password: ``changeme`` + +See Also +-------- + +`Mosquitto (MQTT) <../mosquitto/README.rst>`_ From 363c588d3cc0c328ba3f77b4ca79cea92ae23952 Mon Sep 17 00:00:00 2001 From: Anish Mangal Date: Wed, 16 Jan 2019 12:31:42 +0530 Subject: [PATCH 46/52] Update main.yml --- roles/nodered/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/nodered/tasks/main.yml b/roles/nodered/tasks/main.yml index 57f4da42f..840d69635 100644 --- a/roles/nodered/tasks/main.yml +++ b/roles/nodered/tasks/main.yml @@ -68,7 +68,7 @@ dest: /etc/systemd/system/node-red.service owner: root group: root - mode: 0755 + mode: 0666 when: nodered_install - name: Enable & Start node-red service From 955fa8601223b60287e4da0daf28da3544c98412 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 16 Jan 2019 02:03:48 -0500 Subject: [PATCH 47/52] Update main.yml --- roles/nodered/defaults/main.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/roles/nodered/defaults/main.yml b/roles/nodered/defaults/main.yml index a02540ec6..7e6b61729 100644 --- a/roles/nodered/defaults/main.yml +++ b/roles/nodered/defaults/main.yml @@ -1,7 +1,9 @@ nodered_install: False nodered_enabled: False + nodered_user: Admin -# To generate a new password, run 'node-red-admin hash-pw' and enter the new password. -# Copy the resulting hash to /home/nodered/.node-red/settings.js nodered_password: changeme nodered_password_hash: $2b$08$oxgvoU9et3deSbXY8UNVTOWHSTQAyEASIal86RHVMqYQJhpPMNz7q +# To generate a new password hash, run 'node-red-admin hash-pw' and enter the +# new password. Paste the resulting hash above. After Ansible runs, username +# and password hash will be placed in: /home/nodered/.node-red/settings.js From dcef97bd13ae1af3d9a95a2826105a9b449b6827 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 16 Jan 2019 02:06:10 -0500 Subject: [PATCH 48/52] Update main.yml --- roles/mosquitto/defaults/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/mosquitto/defaults/main.yml b/roles/mosquitto/defaults/main.yml index 2d7190be4..c27c3a538 100644 --- a/roles/mosquitto/defaults/main.yml +++ b/roles/mosquitto/defaults/main.yml @@ -1,4 +1,5 @@ mosquitto_install: False mosquitto_enabled: False + mosquitto_user: Admin mosquitto_password: changeme From 8262588dd948441bebc39e86416cd0e50e0636a6 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 16 Jan 2019 02:11:20 -0500 Subject: [PATCH 49/52] Update README.rst --- roles/mosquitto/README.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/roles/mosquitto/README.rst b/roles/mosquitto/README.rst index 1ac3e4b41..197e741aa 100644 --- a/roles/mosquitto/README.rst +++ b/roles/mosquitto/README.rst @@ -1,5 +1,12 @@ +================ +Mosquitto README +================ + Adds the `Mosquitto `_ (`MQTT `_) `pub-sub `_ broker to Internet-in-a-Box (IIAB) for educational experiments with `IoT `_. Roughly follows this guide: https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-the-mosquitto-mqtt-messaging-broker-on-ubuntu-16-04 -SEE ALSO: `Node-RED <../nodered/README.rst>`_ +See Also +-------- + +`Node-RED <../nodered/README.rst>`_ From e7fa7e410d2128594000086ee81be15bcc9ac772 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 16 Jan 2019 02:19:02 -0500 Subject: [PATCH 50/52] Update README.rst --- roles/mosquitto/README.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/roles/mosquitto/README.rst b/roles/mosquitto/README.rst index 197e741aa..d497af936 100644 --- a/roles/mosquitto/README.rst +++ b/roles/mosquitto/README.rst @@ -6,6 +6,19 @@ Adds the `Mosquitto `_ (`MQTT `_) Roughly follows this guide: https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-the-mosquitto-mqtt-messaging-broker-on-ubuntu-16-04 +Using It +------- + +The mosquitto service is authenticated with: + +Username: ``Admin`` + +Password: ``changeme`` + +You can monitor the service with command:: + + systemctl status mosquitto + See Also -------- From bcaa932feb7828586b61e9b3bf5cd24d4ea3910e Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 16 Jan 2019 02:22:54 -0500 Subject: [PATCH 51/52] Update README.rst --- roles/nodered/README.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/roles/nodered/README.rst b/roles/nodered/README.rst index fbd264110..a51de7e97 100644 --- a/roles/nodered/README.rst +++ b/roles/nodered/README.rst @@ -20,6 +20,10 @@ Username: ``Admin`` Password: ``changeme`` +You can monitor the Node-RED service with command:: + + systemctl status node-red + See Also -------- From 7fa4300e52ffc0ce1649c0a4dee72871dd1312fb Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 16 Jan 2019 02:23:51 -0500 Subject: [PATCH 52/52] Update README.rst --- roles/mosquitto/README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/mosquitto/README.rst b/roles/mosquitto/README.rst index d497af936..31641c045 100644 --- a/roles/mosquitto/README.rst +++ b/roles/mosquitto/README.rst @@ -9,13 +9,13 @@ Roughly follows this guide: https://www.digitalocean.com/community/tutorials/how Using It ------- -The mosquitto service is authenticated with: +The Mosquitto service is authenticated with: Username: ``Admin`` Password: ``changeme`` -You can monitor the service with command:: +You can monitor it with command:: systemctl status mosquitto