How to create Abstract Test aka Contract Test using pytest fixtures

Posted on 2015-09-20 in dev • Tagged with Python, pytest, test

The solution I came up with:

Further reading:


How to use Fabric with Salt-Stack

Posted on 2015-09-20 in dev • Tagged with Python, Fabric, Salt-Stack, envdir

I like to use Fabric in combination with Salt-Stack. My current setup looks like:

Bootstrap master:

fab master bootstrap_master

To add new minion run:

fab -H <minion_host> -u <minion_user> bootstrap:<master_ip>,<human_readable_minion_hostname>

Project layout:

├── config
│   ├── master.template
│   ├── minion.template
│   ├── pillar
│   │   ├── base.sls
│   │   ├── homepage.sls
│   │   └── top.sls
│   └── salt
│       ├── _modules
│       ├── _states
│       ├── apps
│       ├── firewall
│       ├── nginx
│       ├── python
│       ├── supervisor
│       └── top.sls
├── env
│   ├── AS_MASTER_HOST
│   └── AS_MASTER_USER
├── fabfile.py
└── requirements.txt
  • Keep configuration outside code with envdir. $AS_MASTER_USER, $AS_MASTER_HOST environment variables contains master host details.
  • Explicitly copy state files to master. Allows to cheat and check states without committing to configuration repository.

Alwas on USB connector

Posted on 2014-12-26 in misc • Tagged with USB, RTFM, future self

I'm fed up with RTFM. High-current or sleep-and-charge USB connector is usually color coded yellow, orange or red. In ThinkPad manual it's called Always on USB connector.