It is the 26th of June 2017

How to setup a VPS (Virtual Private Server) with saltstack

These scripts will help you bootstrap your VPS like this:

./boot.sh root@<your.vps.ip>

boot.sh

MASTER=$1

ssh-keygen -f "/home/mike/.ssh/known_hosts" -R $MASTER
tar cz -C ../git-repos/ . | ssh root@$MASTER "mkdir -p /srv/git; cd /srv/git/; tar xzf -"
tar cz ../backups | ssh root@$MASTER "cd /tmp; tar xzf -"
ssh root@$MASTER 'bash -s' < setup-salt.sh

setup-salt.sh:

#!/bin/bash

salt-setup-conf() 
{
cat << EOF
fileserver_backend:
  - git
gitfs_remotes:
  - https://github.com/saltstack-formulas/salt-formula.git
ext_pillar:
  - git: master file:///srv/git/pillar.git
EOF
}

# ~~~~~~~~~~~~~~~~~~~~~~~~ MAIN

which salt
if [[ $? -ne 0 ]]; then
    mkdir -p /etc/salt/master.d && salt-setup-conf > /etc/salt/master.d/salt-setup.conf

    wget --no-check-certificate -O /tmp/install_salt.sh https://bootstrap.saltstack.com
    bash /tmp/install_salt.sh -U -p python-git -M -A localhost -i master
    sleep 5 && salt-key -y -A  && sleep 5
    salt-call state.sls 'salt.master'

    # cleanup stale cache (update.lk files...)
    service salt-master stop 
    rm -rf /var/cache/salt
    service salt-master start
fi

Featured Apps

Free Money