Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Salt install/configure Vagrant 1.8 compatible #180

Merged
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Make Salt install/configure Vagrant 1.8 compatible

The original Vagrantfile was meant to be used with Vagrant 1.7.4, but
required 2 patches to Vagrant for proper functionality, which I had
submitted as pull requests. Vagrant has since released a new version,
1.8.0, which has updates the Salt provisioner. PR status:
 - [One PR](hashicorp/vagrant#6474) was merged
 - [Another PR](hashicorp/vagrant#6473) was not

The second PR was rejected "in favor" of [a third
PR](hashicorp/vagrant#6073) which simply removed
the config_dir option entirely instead of using sudo to be able to write
in a priveleged directory. [An unrelated
PR](https://github.com/mitchellh/vagrant/pull/6382/files) removed a
second option we had been using: install_command.

These changes in Vagrant were due to incompabilities with the official
Salt bootstrap script, so this commit brings the install_salt script's
behavior closer to that of the official Salt bootstrap script as well.
Namely, it can now copy over configuration files as part of
installation, using the same flags as the official script.

The configure_salt script is now used just to setup the salt and pillar
roots on Travis (this is accomplished via shared folders in Vagrant),
hence the renaming.

With this commit and the new Vagrant version, the included Vagrantfile
now works with a vanilla Vagrant 1.8.0 install, no patching needed.
  • Loading branch information
aneeshusa committed Dec 22, 2015
commit eccb32a380a87ec5ff7712b30428a3a8cd316614
@@ -32,10 +32,10 @@ matrix:
dist: trusty

before_install:
- .travis/install_salt "${TRAVIS_OS_NAME}"
- .travis/install_salt -F -c .travis -- "${TRAVIS_OS_NAME}"

install:
- .travis/configure_salt
- .travis/setup_salt_roots

# For debugging, check the grains reported by the Travis builder
- sudo salt-call --id="${SALT_NODE_ID}" grains.items

This file was deleted.

@@ -1,15 +1,9 @@
#!/usr/bin/env sh

install_salt () {
set -o errexit
set -o nounset

if [ "$#" -lt 1 ]; then
printf >&2 "usage: $0 os_name\n"
exit 1
fi
OS_NAME="$1"
set -o errexit
set -o nounset

install_salt () {
# Ensure that pinned versions match as closely as possible
if [ "${OS_NAME}" = "linux" ]; then
printf "$0: installing salt for Linux\n"
@@ -28,4 +22,46 @@ install_salt () {
fi
}

install_salt "$@"
configure_salt () {
printf "$0: copying Salt minion configuration from ${TEMPORARY_CONFIG_DIR}\n"
sudo mkdir -p /etc/salt
sudo cp "${FORCE_FLAG}" -- "${TEMPORARY_CONFIG_DIR}/minion" /etc/salt/minion
}

OPTIONS=$(getopt --options 'c:F' --name "$0" --shell sh -- "$@")

eval set -- "${OPTIONS}"

TEMPORARY_CONFIG_DIR=""
FORCE_FLAG=""
OS_NAME=""

while true; do
case "$1" in
-c)
shift
TEMPORARY_CONFIG_DIR="$1"
shift
;;
-F)
FORCE_FLAG="-f"
shift
;;
--)
shift
break
;;
esac
done

if [ "$#" -lt 1 ]; then
printf >&2 "usage: $0 [-c <config_dir> [-F]] [--] os_name\n"
exit 1
fi

OS_NAME="$1"
install_salt

if [ -n "${TEMPORARY_CONFIG_DIR}" ]; then
configure_salt
fi
@@ -0,0 +1,12 @@
#!/usr/bin/env sh

set -o errexit
set -o nounset

setup_salt_roots () {
sudo mkdir -p /srv/salt
sudo cp -r . /srv/salt/states
sudo cp -r .travis/test_pillars /srv/salt/pillars
}

setup_salt_roots "$@"
@@ -44,7 +44,7 @@ Vagrant.configure(2) do |config|
machine.vm.synced_folder File.join(dir, ".travis/test_pillars"), pillar_root
machine.vm.provision :salt do |salt|
salt.bootstrap_script = '.travis/install_salt'
salt.install_command = node[:os] # Pass OS type to install_salt script
salt.install_args = node[:os] # Pass OS type to install_salt script
salt.masterless = true
salt.minion_config = '.travis/minion'
# hack to provide additional options to salt-call
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.