Created
May 18, 2017 13:39
-
-
Save devinnasar/d9d1cf4b7aaeb94eee79d3871aeab040 to your computer and use it in GitHub Desktop.
Adapted bootstrapping script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Bootstaps a SaltStack master server | |
# salt-formula configures the salt master using salt itself. This includes establishing connections allowing salt to serve assets from git and s3 endpoints. | |
# Before this can happen, we need to perform a lightweight saltstack installation, clone salt-formula, and call a salt highstate. | |
# Note: The state and pillar for this formula stay in the repo from the formula and are copied into /srv/salt and /srv/pillar upon invocation of this script. | |
# This repo will be the source of truth for our state and pillar tops, even though we will recieve configuration via gitfs. | |
# Instructions | |
# 1) Ensure the root user has an ssh key. If not, create one with: | |
# $ ssh-keygen -t rsa; | |
# 2) Add the root user's ssh public key to the salt-formula repo's list of access keys. | |
# 3) Navigate to /srv/salt. Clone the salt-formula repo with: | |
# $ git clone [email protected]:opentempo/salt-formula.git . ; The . at the end is important so that we clone without the top level directory. | |
# 4) Run: | |
# $ /srv/salt/salt-formula/setup/bootstrap_salt_master_from_formula_aws.sh; | |
# Script self-awareness variables | |
_script_path=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ); | |
_script_filename=$(basename "${0}") | |
# Salt formula repo URL | |
_salt_formula_remote_url="[email protected]:opentempo/salt-formula.git" | |
# Salt statetree path | |
_salt_statetree_path="/srv/salt" | |
# Salt pillar path | |
_salt_pillar_path="/srv/pillar" | |
# Use the latest stable Salt from repo.saltstack.com | |
# Instructions from http://repo.saltstack.com/#amzn | |
sudo yum install https://repo.saltstack.com/yum/amazon/salt-amzn-repo-latest-2.amzn1.noarch.rpm | |
sudo yum clean expire-cache | |
sudo yum update -y | |
# Install the salt master and minion | |
sudo yum install salt-master -y | |
sudo yum install salt-minion -y | |
# Create the pillar directory | |
if [ ! -d "${_salt_pillar_path}" ]; then | |
sudo mkdir -p "${_salt_pillar_path}" | |
fi | |
# Copy salt-formula pillar and top file to /srv/pillar | |
sudo cp "${_salt_statetree_path}/setup/pillar/salt.sls" "${_salt_pillar_path}/" | |
sudo cp "${_salt_statetree_path}/setup/pillar/top.sls" "${_salt_pillar_path}/" | |
# Copy salt-formula state top to /srv/salt | |
sudo cp "${_salt_statetree_path}/setup/salt/top.sls" "${_salt_statetree_path}/" | |
# Accept all keys | |
sleep 15 #give the minion a few seconds to register | |
sudo salt-key -y -A | |
# By this point we should be in a state where we can call salt-call state.highstate to trigger configuration |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment