All Projects → ryanwalder → saltstack-lxc-vagrant

ryanwalder / saltstack-lxc-vagrant

Licence: GPL-2.0 license
Vagrantfile for setting up a SaltStack test/dev environment.

Projects that are alternatives of or similar to saltstack-lxc-vagrant

saltdash
A read-only dashboard for Salt jobs
Stars: ✭ 18 (+38.46%)
Mutual labels:  salt, saltstack
community
SaltStack Community
Stars: ✭ 27 (+107.69%)
Mutual labels:  salt, saltstack
vscode-saltstack
SaltStack extension for Microsoft Visual Studio Code
Stars: ✭ 26 (+100%)
Mutual labels:  salt, saltstack
alcali-formula
Saltstack formula to install Alcali: a web based tool(GUI) for monitoring and administrating Saltstack Salt.
Stars: ✭ 15 (+15.38%)
Mutual labels:  salt, saltstack
Lxdock
Build and orchestrate your development environments with LXD - a.k.a. Vagrant is Too Heavy™
Stars: ✭ 350 (+2592.31%)
Mutual labels:  vagrant, lxc
saltstack-cheatsheet
🧂 SaltStack Cheat Sheet Plus
Stars: ✭ 31 (+138.46%)
Mutual labels:  salt, saltstack
ISalt
ISalt: Interactive Salt Programming
Stars: ✭ 61 (+369.23%)
Mutual labels:  salt, saltstack
salt-lint
A command-line utility that checks for best practices in SaltStack.
Stars: ✭ 111 (+753.85%)
Mutual labels:  salt, saltstack
ansible virtualization
Ansible Collection: Virtualization roles
Stars: ✭ 31 (+138.46%)
Mutual labels:  vagrant, lxc
kubernetes-dev-stack
Automation of Kubernetes 1.6.0.alpha3 on Centos 7.3 (kernel 4.9.5, docker 1.13.1, flannel 0.7.0)
Stars: ✭ 15 (+15.38%)
Mutual labels:  vagrant, saltstack
generate-secure-pillar
Salt Secure Pillar Tool
Stars: ✭ 30 (+130.77%)
Mutual labels:  salt, saltstack
salt-ssh-install-salt-minion
利用salt-ssh批量部署salt-minion
Stars: ✭ 19 (+46.15%)
Mutual labels:  salt, saltstack
pepperboard
Simple and modular dashboard toolkit for SaltStack
Stars: ✭ 26 (+100%)
Mutual labels:  salt, saltstack
salt-sproxy
Salt plugin to automate the management and configuration of (network) devices at scale, without running (Proxy) Minions.
Stars: ✭ 105 (+707.69%)
Mutual labels:  saltstack
kubernetes-basico
Demonstração dos componentes do Kubernetes
Stars: ✭ 26 (+100%)
Mutual labels:  vagrant
cv4pve-api-php
Proxmox VE Client API for PHP
Stars: ✭ 45 (+246.15%)
Mutual labels:  lxc
awesome-lxc-lxd
A curated list of awesome LXC and LXD tools, libraries and related projects.
Stars: ✭ 34 (+161.54%)
Mutual labels:  lxc
nustuff
Useful scripting and Linux configuration examples
Stars: ✭ 39 (+200%)
Mutual labels:  vagrant
vagrant-sprinkle
A Sprinkle provisioner for Vagrant.
Stars: ✭ 12 (-7.69%)
Mutual labels:  vagrant
ceph-salt
Ceph cluster deployment with SaltStack
Stars: ✭ 83 (+538.46%)
Mutual labels:  saltstack

saltstack-lxc-vagrant

Vagrantfile for spinning up a local Salt Master and minions, all defined in YAML because YAML is nice to read and anyone using salt should be familiar with it!

Requirements

This assumes Ubuntu a 16.04 host, but should work on any modern linux distro (package names are likely vary)

A Note on Boxes

For now the default box is the fgrehm/trusty64-lxc box which is reasonably out of date due to the maintainer of the Vagrant lxc base boxes stepping down so this box is no longer updated or uploaded to Atlas, you can however really easily make your own boxes from the forked and maintained repo which you can use either locally or upload to a server and use the url.

Packages

  1. Vagrant 1.5+ (tested with 1.7.2)
  2. lxc 0.7.5+
  3. tar 1.27 (the lxc-template script uses the --xattrs option)
  4. redir (if you are planning to use port forwarding)
  5. brctl (if you are planning to use private networks, on Ubuntu this means apt-get install bridge-utils)
  6. kernel !=3.5.0-17.28

Vagrant plugins

  1. vagrant-lxc
  2. salty-vagrant-grains (optional)

If installed the vagrant-salty-grains plugin will be used for creating grains on the minions and devmaster.

Quickstart

  1. Clone the repo
    • git clone https://github.com/ryanwalder/saltstack-lxc-vagrant.git
  2. Copy the vagrant.example.yaml to vagrant.yaml
    • cd saltstack-lxc-vagrant && cp vagrant.example.yaml vagrant.yaml
  3. Check your available boxes
    • vagrant status
  4. Spin up the devmaster
    • vagrant up devmaster
  5. Spin up the minions as desired
    • vagrant up box-01

Once you're up and running you'll need to create some top.sls files in salt/salt and salt/pillar (the master will automatically load these when you create them) from here you can get on with developing some salt.

Note: This Vagrantfile does not run a highstate by default (configurable below) as I find it can slow things down when developing states. Once you're all up and running you can ssh into it and run a highstate manually with vagrant ssh minion-box then sudo salt-call state.highstate

YAML file

All settings and minions are defined in the vagrant.yaml file with everything having sane defaults and being customizable as needed.

Both the Master and Minion configs are automatically generated if they don't exist or when you update the vagrant.yaml.

NOTE: Updating either the master or minion config will require reprovisioning all machines as these files are injected during machine creation

Global Settings

All global settings are stored under the settings key, some can be overidden on a per machine basis (detailed below).

Key Use Default Value
salt_version Set version of salt to use/install stable
install_args When performing a git install, you can specify a branch, tag, or any treeish. Not supported on Windows.
domain Appended to the end of minion names
default_box Default box to use for minions fgrehm/trusty64-lxc
default_box_url Default box URL
network Network to use for vagrant (/24), without last octect 10.0.3
bridge Network bridge device to use 'lxcbr0'

Example

settings:
  default_box: fgrehm/trusty64-lxc
  network: 10.66.6
  salt_version: git
  install_args: 2016.11.7

Master Settings

Key Use Default Value
box Master box to use default_box
box_url Master box URL
grains Grains to apply to the master
folders Dict of folders and destinations to be mounted on the master

Master Config

This is a block of YAML that will be translated to the master config on the saltmaster machine.

Master Grains

If you're using the vagrant-salty-grains plugin you can set master grains via the YAML file (probably not needed as the devmaster doesn't really do much other than mount local files and run the master process)

Example

In the below example I'm settings some custom grains, remapping the shared folders as I want everything under one directory (/srv/salt) so I need to salso update the master config to match the new locations. This could also be used for mapping folders which exist outside this repo.

settings:
  salt:
    master:
      grains:
        one: two
        alist:
          - foo
          - bar
      folders:
        - from: salt/states
          to: /srv/salt/states
        - from: salt/formulas
          to: /srv/salt/formulas
        - from: salt/pillar
          to: /srv/salt/pillar
      config:
        file_roots:
          base:
            - /srv/salt/states
            - /srv/salt/formulas/*
        pillar_roots:
          base:
            - /srv/salt/pillar

Global Minion Config

Exactly the same as the master config just using the minion YAML key instead.

settings:
  salt:
    minion:
      config:
        foo: bar
        some_options:
          - one
          - two
          - three

Default Minion Grains

If you're using the vagrant-salty-grains plugin you can set default grains which will be applied to all minions, these will be merged with any grains specified on a per minion basis (detailed below)

settings:
  salt:
    minions:
      default_grains:
        foo: bar
        grains_list:
          - baz
          - qux

Defining Minions

Minions are defined under the minions key with a number of settings available per minion

Key Use Default Value
name Name of the minion none (required)
cpu Number of CPUs assigned to the container 1
ram Amount of RAM assigned to the container 512M
box Box to use for the minion default_box
box_url Box URL for the above box none
folders Folders to share with the minion none
grains Grains to set on the minion {}
highstate Run highstate on minion during provisioning flase

Minimum YAML Needed for a Minion

minions:
  - name: minion-box

Shared Folders

If you need to share folders with the minion you can add them in like so:

minions:
  - name: minion-box
    folders:
      - from: ~/source/folder
        to: /destination/folder

You can repeat this as many times as needed:

minions:
  - name:
    folders:
      - from: ~/source/folder1
        to: /destination/folder1
      - from: ~/source/folder2
        to: /destination/folder2
      - from: ~/source/folder3
        to: /destination/folder3

Per Minion Grains

minions:
  - name: minion-box
    grains:
      foo: bar
      baz:
        one: 1
      qux:
        - blah

Example minion.yaml

minions:
  - name: minion-01
  - name: minion-02
    box: fakebox
    box_url: http://example.com/fakebox.box
    grains:
      i_like_turtles: true
  - name: minion-03
    ram: 1024M
    cpu: 4
    highstate: true
    folders:
      - from: ~/boom
        to: /shanka

Notes

It's always best to fire up the devmaster before the minions or you can get everything in a bit of a race condition where the minions come up before the master which leads to a broken setup where the minions are up before the master where you need to manually restart the salt-minion on each minion box to get them talking to the master properly, and that's no fun.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].