How to use Fabric with Salt-Stack

Posted on 2015-09-20 in dev

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.