15 minutes from 0 to RPi cluster

2016-06-11 @ Pi and More, Trier

Christian Prior

Slides available

http://www.helotism.de \ ⏎
/business/marketing/presentation/piandmore_2016-06-11

Helotism

Wiktionary.org: Helotism (zoology): A form of mutualism in which one species is forced to perform tasks for another, for their mutual benefit.
## This talk Fast-forward through an installation Connect to an elasticsearch cluster
## about me business administration guy 20 years of Linux enthusiasm Currently working as a Backlevel Software Support Engineer for a retail solution /me 💞 complexity! https://github.com/cprior
## Helotism ## https://github.com/helotism/helotism Installer script for a 250€-cluster solving basic sysadmin requirements ![](/business/marketing/images/helotism-scope.svg)

Bill of Materials

## Bootstrap script ## ![](/application/physical/images/customization-workflow.svg)
## Basic config items ## | variable name | getopts parameter | |---------------|------------| | __GITREMOTEORIGINURL | -r | | __GITREMOTEORIGINBRANCH | -g | | __COUNT | -c | | __MASTERHOSTNAME | -m | | __HOSTNAMEPREFIX | -n | | __NETWORKSEGMENTCIDR | -s | | __FQDNNAME | -d |
## Inner workings ## | getopts | default | |----------------|---------| | -r | https://github.com/helotism/helotism.git | | -g | master | | -c | 2 | | -m | axle | | -n | spoke0 | | -s | 10.16.6.1/24 | | -d | wheel.example.com | | -b | /dev/null |
##Powersupply - prevent brown-out - one switch for all boards
##Power Consumption Rule of thumb: - 1 Pi idle == 2.5W (5V * 0,5 A) - 1 Pi under load, no USB == 5W (5V * 1 A) Caveat: GPIO-pins are no USB ports ;) - 5V passed straight through from USB - 3.3V rail max 50mA - GPIO pins 16ma in total
##On-Off-Switch - hardware - code ![](/technology/physical/myrack-v0.5/circuit/helotism_powersupply_bb_640x312.png) [raspberry-pi-geek.com On-Off-Switch](http://www.raspberry-pi-geek.com/Archive/2013/01/Adding-an-On-Off-switch-to-your-Raspberry-Pi "Adding an On/Off switch to your Raspberry Pi")
##Noise ![](/technology/logical/images/ElectricalWireNoise.svg)
##Discretization ![](/technology/logical/images/ElectricalDiscretization.svg)
##Debouncing ![](/technology/logical/images/ElectricalSwitchDebounce.svg)
##Python logic… ```Python def handleInterrupt(args): button20.pressed = True #that's a fact, but... button20.pressed_debounced = False interrupted_at = datetime.datetime.now() debounce_until = interrupted_at + datetime.timedelta(0,3) while True: if (datetime.datetime.now() > debounce_until): journal.send('GPIO20 pressed DEBOUNCED.', FIELD2='GPIO20') //do something button20.pressed_debounced = True return else: journal.send('GPIO20 pressed, not debounced', FIELD2='GPIO20') time.sleep(0.5) #inside this interrupt handler only ```
##…and systemd daemonization. ```INI [Unit] Description=An GPIO interrupt listener After=local-fs.target [Service] Type=simple ExecStart=/bin/bash -c 'cd /opt/helotism/powersupply-env; \ source bin/activate; \ python ./mraa_interrupt.py' [Install] WantedBy=multi-user.target ```
##SaltStack Ecosystem ![](/application/physical/images/saltstack-ecosystem.svg)
##SaltStack top file ```YAML base: # environment 'web*': # targeted minions - apache # state file 'apache.sls' ``` - the top.sls is a special state file as "entry point" into the fileserver - "apache" references ```./apache.sls``` file
##SaltStack state file ```YAML #apache.sls {% if grains['os'] == 'Debian' %} apache: apache2 {% elif grains['os'] == 'RedHat' %} apache: httpd {% endif %} ``` - Jinja2 template language - one should read the fine manual: http://jinja.pocoo.org/docs/dev/
##SaltStack environments ```YAML file_roots: dev: - /srv/salt/dev base: - /srv/salt ``` - environments are configured in the master config file
##SaltStack fileserver ```YAML fileserver_backend: #first filename match wins - roots - git gitfs_remotes: - git://github.com/example/first.git - https://github.com/example/second.git - root: salt #subdirectory - mountpoint: salt://sub/dir - base: myTag05 #git branch - file:///root/third #top_file_merging_strategy: merge #same #env_order: ['base', 'dev', 'prod'] ``` - these are powerful configuration mechanisms: "infrastructure as code" served from a Git repo - many ways to segment or override
##Sample Salt Usage ```bash #remote execution? salt '*' cmd.run 'uname -a' ``` ```bash #listing and accepting keys salt-key -L salt-key -A ``` ```bash #salt.modules.test.ping salt '*' test.ping ``` ```bash #targeting by grains salt -G 'os:(RedHat|Debian)' test.ping ``` ```bash #more sound than test.ping salt-run manage.up ``` ```bash #apply common.sls on all (accepted) minions salt '*' state.sls common #This is the "endgame" in salt salt '*' state.highstate #remote execution! salt '*' cmd.run 'uname -a' ```
##Demo …
##Questions? Fork it on GitHub! Issues welcome.