commit 06ec94a86273c33a90025fafb592fbc4c2311347 Author: Tobias Wallura Date: Wed Feb 3 00:03:11 2016 +0100 initial import diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c11c1f3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.kitchen +Gemfile.lock diff --git a/.kitchen.yml b/.kitchen.yml new file mode 100644 index 0000000..e0eaa33 --- /dev/null +++ b/.kitchen.yml @@ -0,0 +1,27 @@ +driver: + name: docker + +platforms: + - name: centos-7 + driver_config: + image: corux/centos7-salt + - name: debian-8 + - name: fedora-latest + +provisioner: + name: salt_solo + formula: vagrant + pillars-from-files: + vagrant.sls: pillar.example + pillars: + top.sls: + base: + "*": + - vagrant + state_top: + base: + "*": + - vagrant + +suites: + - name: default diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..74e3d7d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +sudo: required +services: + - docker + +script: + - kitchen test diff --git a/FORMULA b/FORMULA new file mode 100644 index 0000000..3beec48 --- /dev/null +++ b/FORMULA @@ -0,0 +1,7 @@ +name: vagrant +os: CentOS, Fedora, Debian +os_family: RedHat, Debian +version: 201602 +release: 1 +summary: Formula for installing Vagrant +description: Formula for installing Vagrant diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..1947ff4 --- /dev/null +++ b/Gemfile @@ -0,0 +1,5 @@ +source "https://rubygems.org" + +gem "test-kitchen" +gem "kitchen-docker" +gem "kitchen-salt" diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..c8abc55 --- /dev/null +++ b/README.rst @@ -0,0 +1,19 @@ +=============== +vagrant-formula +=============== + +.. image:: https://travis-ci.org/corux/vagrant-formula.svg?branch=master + :target: https://travis-ci.org/corux/vagrant-formula + +Installs Vagrant. + +Available states +================ + +.. contents:: + :local: + +``vagrant`` +----------- + +Installs Vagrant. diff --git a/pillar.example b/pillar.example new file mode 100644 index 0000000..fa0cc6e --- /dev/null +++ b/pillar.example @@ -0,0 +1,3 @@ +vagrant: + plugins: + - vagrant-aws diff --git a/test/integration/default/serverspec/vagrant_spec.rb b/test/integration/default/serverspec/vagrant_spec.rb new file mode 100644 index 0000000..7195179 --- /dev/null +++ b/test/integration/default/serverspec/vagrant_spec.rb @@ -0,0 +1,11 @@ +require 'serverspec' + +set :backend, :exec + +describe command("which vagrant") do + its(:exit_status) { should eq 0 } +end + +describe command("vagrant plugin list | grep vagrant-aws") do + its(:exit_status) { should eq 0 } +end diff --git a/vagrant/defaults.yaml b/vagrant/defaults.yaml new file mode 100644 index 0000000..5f3aa3d --- /dev/null +++ b/vagrant/defaults.yaml @@ -0,0 +1,2 @@ +vagrant: + version: 1.8.1 diff --git a/vagrant/init.sls b/vagrant/init.sls new file mode 100644 index 0000000..7258e87 --- /dev/null +++ b/vagrant/init.sls @@ -0,0 +1,13 @@ +{% from "vagrant/map.jinja" import vagrant with context %} + +vagrant: + pkg.installed: + - sources: + - vagrant: {{ vagrant.url }} + +{% for plugin in vagrant.get('plugins', []) %} +vagrant-plugin-{{ plugin }}: + cmd.run: + - name: "vagrant plugin install '{{ plugin }}'" + - unless: "vagrant plugin list | grep '{{ plugin }}'" +{% endfor %} diff --git a/vagrant/map.jinja b/vagrant/map.jinja new file mode 100644 index 0000000..3e6cbf7 --- /dev/null +++ b/vagrant/map.jinja @@ -0,0 +1,12 @@ +{% import_yaml 'vagrant/defaults.yaml' as default_settings %} +{% set vagrant = salt['pillar.get']('vagrant', default=default_settings.get('vagrant'), merge=True) %} + +{% set baseurl = 'https://releases.hashicorp.com/vagrant/' ~ vagrant.version ~ '/vagrant_' ~ vagrant.version ~ '_x86_64' %} +{% set vagrant = salt['grains.filter_by']({ + 'RedHat': { + 'url': baseurl ~ '.rpm' + }, + 'Debian': { + 'url': baseurl ~ '.deb' + } +}, grain = 'os_family', merge=vagrant) %}