Initial import
This commit is contained in:
commit
c73da78ee9
|
@ -0,0 +1 @@
|
|||
.vagrant
|
|
@ -0,0 +1,7 @@
|
|||
# Vagrant based salt test environment
|
||||
|
||||
This is a simple multi machine vagrant test environment.
|
||||
It spins up one salt-master and two salt-minion machines, and creates a rough working salt skeleton environment on them for testing purposes.
|
||||
Simply run `vagrant up` to spin everything up.
|
||||
|
||||
In case you want to adjust the configuration, use `vagrant rsync` to refresh the files within the virtual machines.
|
|
@ -0,0 +1,68 @@
|
|||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
# Use this box as base for all machines
|
||||
config.vm.box = "debian/buster64"
|
||||
|
||||
|
||||
# Define primary salt-master vm
|
||||
config.vm.define "salt-master", primary: true do |master|
|
||||
master.vm.hostname = "salt-master"
|
||||
# Define network for salt management
|
||||
master.vm.network "private_network", ip: "10.254.254.2", virtualbox__intnet: "salt-management"
|
||||
|
||||
# Sync salt pillar + state files here
|
||||
master.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: [".git/",]
|
||||
|
||||
# Provide dependencies (also for gitfs)
|
||||
master.vm.provision :shell, :inline => "sudo apt-get -y install git-core python3-pygit2 python3-setuptools python3-tornado"
|
||||
|
||||
# Symlink states + pillar to /srv
|
||||
master.vm.provision :shell, :inline => "ln -s /vagrant/saltstack/salt /srv/"
|
||||
master.vm.provision :shell, :inline => "ln -s /vagrant/saltstack/pillar /srv/"
|
||||
|
||||
# Use vagrant salt provisioner (uses most recent salt-bootstrap script)
|
||||
# See https://www.vagrantup.com/docs/provisioning/salt.html
|
||||
master.vm.provision :salt do |salt|
|
||||
salt.bootstrap_options = '-F -c /tmp/ -P -x python3'
|
||||
salt.colorize = true
|
||||
salt.install_master = true
|
||||
salt.minion_config = "saltstack/config/minion-master"
|
||||
salt.master_config = "saltstack/config/master"
|
||||
salt.verbose = true
|
||||
end
|
||||
|
||||
master.vm.provision :shell, :inline => "echo salt-master is up!"
|
||||
master.vm.provision :shell, :inline => "ip addr show"
|
||||
|
||||
end # config.vm.define "salt-master"
|
||||
|
||||
|
||||
|
||||
# Define two salt-minion vms
|
||||
(1..2).each do |i|
|
||||
config.vm.define "salt-minion-#{i}" do |minion|
|
||||
minion.vm.hostname = "salt-minion-#{i}"
|
||||
|
||||
# Define network for salt management
|
||||
minion.vm.network "private_network", ip: "10.254.254.2#{i}", virtualbox__intnet: "salt-management"
|
||||
|
||||
# Use vagrant salt provisioner (uses most recent salt-bootstrap script)
|
||||
# See https://www.vagrantup.com/docs/provisioning/salt.html
|
||||
minion.vm.provision :salt do |salt|
|
||||
salt.bootstrap_options = '-F -c /tmp/ -P -x python3'
|
||||
salt.colorize = true
|
||||
salt.install_master = false
|
||||
salt.masterless = false
|
||||
salt.minion_config = "saltstack/config/minion-#{i}"
|
||||
salt.verbose = true
|
||||
end
|
||||
|
||||
minion.vm.provision :shell, :inline => "echo salt-minion #{i} is up!"
|
||||
minion.vm.provision :shell, :inline => "ip addr show"
|
||||
end # config.vm.define "salt-minion-#{i}"
|
||||
|
||||
end # (1..2).each do |i|
|
||||
|
||||
end # Vagrant.configure
|
|
@ -0,0 +1,14 @@
|
|||
interface: 10.254.254.2
|
||||
|
||||
auto_accept: True
|
||||
|
||||
fileserver_backend:
|
||||
- roots
|
||||
|
||||
file_roots:
|
||||
base:
|
||||
- /srv/salt/
|
||||
|
||||
pillar_roots:
|
||||
base:
|
||||
- /srv/pillar
|
|
@ -0,0 +1,2 @@
|
|||
id: 'minion-1'
|
||||
master: 10.254.254.2
|
|
@ -0,0 +1,2 @@
|
|||
id: 'minion-2'
|
||||
master: 10.254.254.2
|
|
@ -0,0 +1,2 @@
|
|||
id: 'minion-master'
|
||||
master: 10.254.254.2
|
|
@ -0,0 +1,7 @@
|
|||
test:
|
||||
foo: True
|
||||
bar: is open
|
||||
baz:
|
||||
- first
|
||||
- second
|
||||
- third
|
|
@ -0,0 +1,3 @@
|
|||
base:
|
||||
'*':
|
||||
- test.data
|
|
@ -0,0 +1,4 @@
|
|||
### THIS FILE IS MANAGED BY SALT STATE `test`.
|
||||
### YOUR CHANGES WILL BE OVERWRITTEN!
|
||||
{% set pillar = salt['pillar.get']('test') %}
|
||||
{{ pillar.foo }}
|
|
@ -0,0 +1,21 @@
|
|||
test_create_temp_file:
|
||||
file.managed:
|
||||
- name: /tmp/test.file
|
||||
- mode: 0666
|
||||
- user: root
|
||||
- group: root
|
||||
- template: jinja
|
||||
- contents: |
|
||||
{% set pillar = salt['pillar.get']('test') %}
|
||||
{{ pillar.foo }}
|
||||
{{ pillar.bar }}
|
||||
|
||||
|
||||
test_create_other_temp_file:
|
||||
file.managed:
|
||||
- name: /tmp/test2.file
|
||||
- mode: 0444
|
||||
- user: root
|
||||
- group: root
|
||||
- template: jinja
|
||||
- source: salt://test/files/test.template
|
|
@ -0,0 +1,6 @@
|
|||
base:
|
||||
'salt-master':
|
||||
- test
|
||||
|
||||
'minion-*':
|
||||
- test
|
Loading…
Reference in New Issue