Skip to content

Commit 5a263e0

Browse files
authored
Merge pull request #112 from dafyddj/kitchen-vagrant
Windows testing using kitchen-vagrant
2 parents 06a09f2 + 0229d14 commit 5a263e0

File tree

15 files changed

+183
-111
lines changed

15 files changed

+183
-111
lines changed

.rubocop.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ Metrics/LineLength:
88
Max: 88
99

1010
# Any offenses that should be fixed, e.g. collected via. `rubocop --auto-gen-config`
11+
Metrics/BlockLength:
12+
Max: 36

.travis.yml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,14 @@ stages:
2121
- name: release
2222
if: branch = master AND type != pull_request
2323
jobs:
24-
allow_failures:
25-
- env: Lint_rubocop
26-
fast_finish: true
2724
include:
2825
## Define the test stage that runs the linters (and testing matrix, if applicable)
2926

30-
# Run all of the linters in a single job (except `rubocop`)
27+
# Run all of the linters in a single job
3128
- language: node_js
3229
node_js: lts/*
3330
env: Lint
34-
name: 'Lint: salt-lint, yamllint & commitlint'
31+
name: 'Lint: salt-lint, yamllint, rubocop & commitlint'
3532
before_install: skip
3633
script:
3734
# Install and run `salt-lint`
@@ -42,21 +39,13 @@ jobs:
4239
# Need at least `v1.17.0` for the `yaml-files` setting
4340
- pip install --user yamllint>=1.17.0
4441
- yamllint -s .
42+
# Install and run `rubocop`
43+
- gem install rubocop
44+
- rubocop -d
4545
# Install and run `commitlint`
4646
- npm i -D @commitlint/config-conventional
4747
@commitlint/travis-cli
4848
- commitlint-travis
49-
# Run the `rubocop` linter in a separate job that is allowed to fail
50-
# Once these lint errors are fixed, this can be merged into a single job
51-
- language: node_js
52-
node_js: lts/*
53-
env: Lint_rubocop
54-
name: 'Lint: rubocop'
55-
before_install: skip
56-
script:
57-
# Install and run `rubocop`
58-
- gem install rubocop
59-
- rubocop -d
6049

6150
## Define the rest of the matrix based on Kitchen testing
6251
# Make sure the instances listed below match up with

.yamllint

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ ignore: |
1212
node_modules/
1313
test/**/states/**/*.sls
1414
.kitchen/
15+
test/salt/pillar/default.sls
1516
1617
yaml-files:
1718
# Default settings

Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
source 'https://rubygems.org'
44

5+
gem 'inspec'
56
gem 'kitchen-docker', '>= 2.9'
67
gem 'kitchen-inspec', '>= 1.1'
78
gem 'kitchen-salt', '>= 0.6.0'
9+
gem 'rspec-retry'
10+
11+
group :vagrant do
12+
gem 'kitchen-vagrant'
13+
end

docs/README.rst

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,65 @@ Runs all of the stages above in one go: i.e. ``destroy`` + ``converge`` + ``veri
131131
^^^^^^^^^^^^^^^^^^^^^
132132

133133
Gives you SSH access to the instance for manual testing.
134+
135+
Testing with Vagrant
136+
--------------------
137+
138+
Windows testing is done with ``kitchen-salt``.
139+
140+
Requirements
141+
^^^^^^^^^^^^
142+
143+
* Ruby
144+
* Virtualbox
145+
* Vagrant
146+
147+
Setup
148+
^^^^^
149+
150+
.. code-block:: bash
151+
152+
$ gem install bundler
153+
$ bundle install --with=vagrant
154+
$ bin/kitchen test [platform]
155+
156+
Where ``[platform]`` is the platform name defined in ``kitchen.yml``,
157+
e.g. ``windows-81-2019-2-py3``.
158+
159+
Note
160+
^^^^
161+
162+
When testing using Vagrant you must set the environment variable ``KITCHEN_LOCAL_YAML`` to ``kitchen.vagrant.yml``. For example:
163+
164+
.. code-block:: bash
165+
166+
$ KITCHEN_LOCAL_YAML=kitchen.vagrant.yml bin/kitchen test # Alternatively,
167+
$ export KITCHEN_LOCAL_YAML=kitchen.vagrant.yml
168+
$ bin/kitchen test
169+
170+
Then run the following commands as needed.
171+
172+
``bin/kitchen converge``
173+
^^^^^^^^^^^^^^^^^^^^^^^^
174+
175+
Creates the Vagrant instance and runs the ``openvpn`` main state, ready for testing.
176+
177+
``bin/kitchen verify``
178+
^^^^^^^^^^^^^^^^^^^^^^
179+
180+
Runs the ``inspec`` tests on the actual instance.
181+
182+
``bin/kitchen destroy``
183+
^^^^^^^^^^^^^^^^^^^^^^^
184+
185+
Removes the Vagrant instance.
186+
187+
``bin/kitchen test``
188+
^^^^^^^^^^^^^^^^^^^^
189+
190+
Runs all of the stages above in one go: i.e. ``destroy`` + ``converge`` + ``verify`` + ``destroy``.
191+
192+
``bin/kitchen login``
193+
^^^^^^^^^^^^^^^^^^^^^
194+
195+
Gives you RDP access to the instance for manual testing.

kitchen.vagrant.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
4+
driver:
5+
name: vagrant
6+
7+
platforms:
8+
- name: windows-81-2019-2-py3
9+
driver:
10+
box: techneg/win81x64-pro-salt
11+
gui: false
12+
linked_clone: true
13+
provisioner:
14+
init_environment: >
15+
salt-call --local state.single file.managed
16+
C:\Users\vagrant\AppData\Local\Temp\kitchen\srv\salt\win\repo-ng\openvpn.sls
17+
source=https://github.com/saltstack/salt-winrepo-ng/raw/master/openvpn.sls
18+
skip_verify=True makedirs=True

openvpn/defaults.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# vim: ft=yaml
33
---
44
openvpn:
5+
bin_dir: ~
56
conf_dir: /etc/openvpn
67
conf_ext: conf
78
dh_files: ['2048', '4096']

openvpn/dhparams.sls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{%- set dh_file = config_dir ~ "/dh" ~ dh ~ ".pem" %}
99
openvpn_create_dh_{{ dh }}:
1010
cmd.run:
11-
- name: openssl dhparam {% if map.dsaparam %}-dsaparam {% endif %}-out {{ dh_file }} {{ dh }}
11+
- name: '"{{ map.bin_dir | default('', true) }}openssl" dhparam {% if map.dsaparam %}-dsaparam {% endif %}-out "{{ dh_file }}" {{ dh }}'
1212
- creates: {{ dh_file }}
1313
- require:
1414
- pkg: openvpn_pkgs

openvpn/init.sls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
include:
44
- openvpn.repo
55
- openvpn.install
6+
- openvpn.adapters
67
- openvpn.dhparams
78
- openvpn.service

openvpn/osfamilymap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ FreeBSD:
2626
manage_user: false
2727
manage_group: false
2828
Windows:
29+
bin_dir: C:\Program Files\OpenVPN\bin\
2930
conf_dir: C:\Program Files\OpenVPN\config
3031
conf_ext: ovpn
3132
service: OpenVPNServiceInteractive

0 commit comments

Comments
 (0)