Skip to content

Instantly share code, notes, and snippets.

@eykd
Last active April 6, 2016 19:01
Show Gist options
  • Select an option

  • Save eykd/51e16df1712e034baf13aeada0c65e9d to your computer and use it in GitHub Desktop.

Select an option

Save eykd/51e16df1712e034baf13aeada0c65e9d to your computer and use it in GitHub Desktop.

Revisions

  1. eykd created this gist Feb 19, 2016.
    1 change: 1 addition & 0 deletions .gitignore
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    .vagrant
    21 changes: 21 additions & 0 deletions Vagrantfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    # -*- mode: ruby -*-
    # vi: set ft=ruby :

    # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
    VAGRANTFILE_API_VERSION = "2"

    Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    config.vm.define :salt_testbed do |salt|
    # All Vagrant configuration is done here. The most common configuration
    # options are documented and commented below. For a complete reference,
    # please see the online documentation at vagrantup.com.

    # Every Vagrant virtual environment requires a box to build off of.
    salt.vm.box = "ubuntu/trusty64"

    # Share for masterless salt minion
    salt.vm.synced_folder "./", "/opt/salt"

    salt.vm.provision :shell, path: "provision_salt.sh", privileged: false
    end
    end
    12 changes: 12 additions & 0 deletions minion.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    fileserver_backend:
    - roots

    file_client: local

    file_roots:
    base:
    - /opt/salt

    pillar_roots:
    base:
    - /srv
    10 changes: 10 additions & 0 deletions my-env.sls
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    include:
    - nginx

    webapps-group:
    group.present:
    - name: webapps
    - addusers:
    - www-data
    - require:
    - pkg: nginx
    7 changes: 7 additions & 0 deletions nginx.sls
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    nginx:
    pkg.installed

    www-data:
    user.present:
    - require:
    - pkg: nginx
    21 changes: 21 additions & 0 deletions provision_salt.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    #!/bin/sh
    start_seconds="$(date +%s)"

    if [ ! -d "/etc/salt" ]; then
    echo "Bootstrap salt"
    sudo wget -O /root/install_salt.sh https://bootstrap.saltstack.com
    sudo sh /root/install_salt.sh -P git v2015.8.8
    fi

    sudo mkdir -p /etc/salt
    sudo cp /vagrant/minion.conf /etc/salt/minion
    echo "Restart salt-minion"
    sudo salt-minion -d
    sudo service salt-minion restart

    echo "Executing salt highstate (provisioning)"
    sudo salt-call state.highstate

    end_seconds="$(date +%s)"
    echo "-----------------------------"
    echo "Provisioning complete in "$(expr $end_seconds - $start_seconds)" seconds"
    4 changes: 4 additions & 0 deletions top.sls
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    base:
    '*':
    - nginx
    - my-env