-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from dafyddj/kitchen-vagrant
Windows testing using kitchen-vagrant
- Loading branch information
Showing
15 changed files
with
183 additions
and
111 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=yaml | ||
--- | ||
driver: | ||
name: vagrant | ||
|
||
platforms: | ||
- name: windows-81-2019-2-py3 | ||
driver: | ||
box: techneg/win81x64-pro-salt | ||
gui: false | ||
linked_clone: true | ||
provisioner: | ||
init_environment: > | ||
salt-call --local state.single file.managed | ||
C:\Users\vagrant\AppData\Local\Temp\kitchen\srv\salt\win\repo-ng\openvpn.sls | ||
source=https://github.com/saltstack/salt-winrepo-ng/raw/master/openvpn.sls | ||
skip_verify=True makedirs=True |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ | |
include: | ||
- openvpn.repo | ||
- openvpn.install | ||
- openvpn.adapters | ||
- openvpn.dhparams | ||
- openvpn.service |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,45 @@ | ||
# Overide by OS | ||
# frozen_string_literal: true | ||
|
||
if os[:family] == 'windows' | ||
conf_dir = 'C:\\Program Files\\OpenVPN\\config' | ||
conf_ext = 'ovpn' | ||
else | ||
conf_dir = '/etc/openvpn' | ||
conf_ext = 'conf' | ||
end | ||
|
||
user = 'root' | ||
group = 'openvpn' | ||
|
||
control 'OpenVPN server configuration' do | ||
title 'should match desired lines' | ||
|
||
%w[server client].each do |role| | ||
cfgfile = | ||
case os[:name] | ||
when 'debian' | ||
'/etc/openvpn/server/myserver1.conf' | ||
when 'fedora' | ||
'/etc/openvpn/server/myserver1.conf' | ||
when 'ubuntu' | ||
'/etc/openvpn/server/myserver1.conf' | ||
when 'debian', 'fedora', 'ubuntu' | ||
"#{conf_dir}/#{role}/my#{role}1.#{conf_ext}" | ||
else | ||
'/etc/openvpn/myserver1.conf' | ||
"#{conf_dir}/my#{role}1.#{conf_ext}" | ||
end | ||
|
||
describe file(cfgfile) do | ||
it { should be_file } | ||
it { should be_owned_by user } | ||
it { should be_grouped_into group } | ||
its('mode') { should cmp '0640' } | ||
its('content') { should include '# OpenVPN server configuration' } | ||
its('content') { should include '# Managed by Salt' } | ||
its('content') { should include 'user' } | ||
control "OpenVPN #{role} configuration" do | ||
title 'should match desired lines' | ||
|
||
describe file(cfgfile) do | ||
it { should be_file } | ||
its('content') { should include "# OpenVPN #{role} configuration" } | ||
its('content') { should include '# Managed by Salt' } | ||
its('content') { should include 'user' } | ||
end | ||
end | ||
end | ||
|
||
control 'OpenVPN client configuration' do | ||
title 'should match desired lines' | ||
control "OpenVPN #{role} configuration file permissions" do | ||
title 'should be correct' | ||
|
||
cfgfile = | ||
case os[:name] | ||
when 'debian' | ||
'/etc/openvpn/client/myclient1.conf' | ||
when 'fedora' | ||
'/etc/openvpn/client/myclient1.conf' | ||
when 'ubuntu' | ||
'/etc/openvpn/client/myclient1.conf' | ||
else | ||
'/etc/openvpn/myclient1.conf' | ||
end | ||
only_if('Skip on Windows') { os[:family] != 'windows' } | ||
|
||
describe file(cfgfile) do | ||
it { should be_file } | ||
it { should be_owned_by user } | ||
it { should be_grouped_into group } | ||
its('mode') { should cmp '0640' } | ||
its('content') { should include '# OpenVPN client configuration' } | ||
its('content') { should include '# Managed by Salt' } | ||
its('content') { should include 'user' } | ||
describe file(cfgfile) do | ||
it { should be_owned_by user } | ||
it { should be_grouped_into group } | ||
its('mode') { should cmp '0640' } | ||
end | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
control 'OpenVPN package' do | ||
title 'should be installed' | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,45 @@ | ||
# frozen_string_literal: true | ||
|
||
control 'OpenVPN service' do | ||
impact 0.5 | ||
title 'should be running and enabled' | ||
|
||
# single service | ||
if os[:name] == 'centos' && os[:release].start_with?('6') | ||
describe service("openvpn") do | ||
it { should be_enabled } | ||
it { should be_running } | ||
end | ||
require 'rspec/retry' | ||
|
||
# multiple services | ||
else | ||
%w(server client).each do |role| | ||
log_dir = '/var/log/openvpn/' | ||
|
||
if os[:name] == 'centos' && os[:release].start_with?('6') | ||
services = ['openvpn'] | ||
elsif os[:family] == 'windows' | ||
log_dir = 'C:\\Program Files\\OpenVPN\\log\\' | ||
services = ['OpenVPNService'] | ||
else | ||
services = [] | ||
%w[server client].each do |role| | ||
prefix = | ||
case os[:name] | ||
when 'debian' | ||
"openvpn-#{role}" | ||
when 'fedora' | ||
"openvpn-#{role}" | ||
when 'ubuntu' | ||
when 'debian', 'fedora', 'ubuntu' | ||
"openvpn-#{role}" | ||
else | ||
'openvpn' | ||
end | ||
|
||
describe service("#{prefix}@my#{role}1.service") do | ||
it { should be_enabled } | ||
it { should be_running } | ||
end | ||
services << "#{prefix}@my#{role}1.service" | ||
end | ||
end | ||
|
||
%w(server client).each do |role| | ||
logfile = "/var/log/openvpn/my#{role}1.log" | ||
services.each do |service| | ||
describe service(service) do | ||
it { should be_enabled } | ||
it { should be_running } | ||
end | ||
end | ||
|
||
describe command("sh -c 'for i in $(seq 1 60); do if grep \"Initialization Sequence Completed\" #{logfile}; then exit 0; fi; echo -n '.'; sleep 1; done; cat #{logfile}; exit 1'") do | ||
its('exit_status') { should be 0 } | ||
its('stdout') { should include "Initialization Sequence Completed" } | ||
%w[server client].each do |role| | ||
logfile = "#{log_dir}my#{role}1.log" | ||
describe 'Initialization' do | ||
it 'should be completed', retry: 60, retry_wait: 1 do | ||
expect(file(logfile).content).to include 'Initialization Sequence Completed' | ||
end | ||
end | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ supports: | |
- platform-name: freebsd | ||
- platform-name: amazon | ||
- platform-name: arch | ||
- platform: windows |
Oops, something went wrong.