From d175f02e84ea8b73ab12a70f1bd5b9f2337994fc Mon Sep 17 00:00:00 2001 From: hogenj Date: Tue, 3 Mar 2015 15:25:34 -0500 Subject: [PATCH] Adding vagrant testbed --- test/Vagrantfile | 60 +++++++++++++++++++++++++++++++++++ test/minion | 2 ++ test/roots/pillar/sudoers.sls | 50 +++++++++++++++++++++++++++++ test/roots/pillar/top.sls | 3 ++ test/roots/salt/top.sls | 3 ++ 5 files changed, 118 insertions(+) create mode 100644 test/Vagrantfile create mode 100644 test/minion create mode 100644 test/roots/pillar/sudoers.sls create mode 100644 test/roots/pillar/top.sls create mode 100644 test/roots/salt/top.sls diff --git a/test/Vagrantfile b/test/Vagrantfile new file mode 100644 index 0000000..b3f5e7d --- /dev/null +++ b/test/Vagrantfile @@ -0,0 +1,60 @@ +Vagrant.configure('2') do |config| + + # configure box to use host http_proxy if + # vagrant-proxyconf is enabled + def configure_proxy(vm_def) + if Vagrant.has_plugin?("vagrant-proxyconf") && ENV['http_proxy'] + vm_def.proxy.http = ENV['http_proxy'] + vm_def.proxy.https = ENV['https_proxy'] + vm_def.apt_proxy.http = ENV['http_proxy'] + vm_def.apt_proxy.https = ENV['https_proxy'] + vm_def.proxy.no_proxy = ENV['no_proxy'] + end + end + + DEFAULT_VAGRANT_BOX = 'rubicon/ubuntu1404-salt' + + def set_box(vm_def) + vm_def.vm.box = ENV['VAGRANT_BOX'] || DEFAULT_VAGRANT_BOX + if ENV['VAGRANT_BOX_VERSION'] + vm_def.vm.box_version = ENV['VAGRANT_BOX_VERSION'] + vm_def.vm.box_check_update = false + end + end + + def configure_vm_size(vm_def) + if ENV['VAGRANT_VM_MEM'] + vm_def.vm.provider 'virtualbox' do |vb| + vb.memory = ENV['VAGRANT_VM_MEM'] + end + end + if ENV['VAGRANT_VM_CPU'] + vm_def.vm.provider 'virtualbox' do |vb| + vb.cpus = ENV['VAGRANT_VM_CPU'] + end + end + end + + config.vm.define :sudoers01 do |sudoers01| + + configure_proxy(sudoers01) + set_box(sudoers01) + configure_vm_size(sudoers01) + + sudoers01.vm.hostname = 'sudoers01' + sudoers01.vm.synced_folder 'roots/salt', '/srv/salt' + sudoers01.vm.synced_folder 'roots/pillar', '/srv/pillar' + sudoers01.vm.synced_folder '../sudoers', '/srv/salt/sudoers' + + sudoers01.vm.provision :salt do |salt| + salt.minion_config = 'minion' + salt.run_highstate = true + salt.verbose = true + + if ENV['salt_install_args'] + salt.install_args = ENV['salt_install_args'] + end + + end + end +end diff --git a/test/minion b/test/minion new file mode 100644 index 0000000..995d6f7 --- /dev/null +++ b/test/minion @@ -0,0 +1,2 @@ +master: localhost +file_client: local diff --git a/test/roots/pillar/sudoers.sls b/test/roots/pillar/sudoers.sls new file mode 100644 index 0000000..27731e5 --- /dev/null +++ b/test/roots/pillar/sudoers.sls @@ -0,0 +1,50 @@ +sudoers: + users: + johndoe: + - 'ALL=(ALL) ALL' + - 'ALL=(root) NOPASSWD: /etc/init.d/httpd' + groups: + sudo: + - 'ALL=(ALL) ALL' + - 'ALL=(nodejs) NOPASSWD: ALL' + defaults: + generic: + - env_reset + - mail_badpass + - secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + user_list: + johndoe: '!requiretty' + ADMINS: '!lecture' + host_list: + www1: 'log_year, logfile=/var/log/sudo.log' + command_list: + PROCESSES: 'noexec' + runas_list: + root: '!set_logname' + aliases: + hosts: + WEBSERVERS: + - www1 + - www2 + - www3 + users: + ADMINS: + - millert + - dowdy + - mikef + commands: + PROCESSES: + - /usr/bin/nice + - /bin/kill + - /usr/bin/renice + - /usr/bin/pkill + - /usr/bin/top + includedir: /etc/sudoers.d + included_files: + /etc/sudoers.d/extra-file: + users: + foo: + - 'ALL=(ALL) ALL' + groups: + bargroup: + - 'ALL=(ALL) NOPASSWD: ALL' diff --git a/test/roots/pillar/top.sls b/test/roots/pillar/top.sls new file mode 100644 index 0000000..d461613 --- /dev/null +++ b/test/roots/pillar/top.sls @@ -0,0 +1,3 @@ +base: + '*': + - sudoers diff --git a/test/roots/salt/top.sls b/test/roots/salt/top.sls new file mode 100644 index 0000000..d461613 --- /dev/null +++ b/test/roots/salt/top.sls @@ -0,0 +1,3 @@ +base: + '*': + - sudoers