kitchen-yansible-pusher 0.1.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +59 -3
- data/README.md +68 -18
- data/lib/kitchen/provisioner/yansible_pusher.rb +67 -8
- data/lib/kitchen/yansible/pusher/version.rb +1 -1
- data/sig/kitchen/yansible/pusher.rbs +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b71ce84978f4c0c04f3bf960f22cb555ebd102da45854477215e8fec8c2dc030
|
4
|
+
data.tar.gz: f36dd7eb60a4e3ffb01990ca40cb6d6049503eaa47e3af751abedc4f0036aed4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6cc7b7ba60df6febe0c8f96cf86a7349945483e049ad37e3ddbd27afd36f6ef9c621514d9321f256476a42220396da864a93459b98890ceb010805f29a02025
|
7
|
+
data.tar.gz: 50ec8b60ecc6595597a1ea6c4d7cb74eaead95719bd1308a5954e9a40a0bd2f7750a4f81289fefac27ec3e983ec957973fa7437ba73e76538e80ae1f322cf8ca
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,61 @@
|
|
1
|
-
|
1
|
+
# Changelog
|
2
2
|
|
3
|
-
## [
|
3
|
+
## [Unreleased](https://github.com/jmtx1020/kitchen-yansible-pusher/tree/HEAD)
|
4
4
|
|
5
|
-
-
|
5
|
+
[Full Changelog](https://github.com/jmtx1020/kitchen-yansible-pusher/compare/v0.2.0...HEAD)
|
6
|
+
|
7
|
+
**Merged pull requests:**
|
8
|
+
|
9
|
+
- added chocolatey to reqs [\#13](https://github.com/jmtx1020/kitchen-yansible-pusher/pull/13) ([jmtx1020](https://github.com/jmtx1020))
|
10
|
+
- add winrm support [\#12](https://github.com/jmtx1020/kitchen-yansible-pusher/pull/12) ([jmtx1020](https://github.com/jmtx1020))
|
11
|
+
- added CHANGELOG update action [\#11](https://github.com/jmtx1020/kitchen-yansible-pusher/pull/11) ([jmtx1020](https://github.com/jmtx1020))
|
12
|
+
|
13
|
+
## [v0.2.0](https://github.com/jmtx1020/kitchen-yansible-pusher/tree/v0.2.0) (2024-08-31)
|
14
|
+
|
15
|
+
[Full Changelog](https://github.com/jmtx1020/kitchen-yansible-pusher/compare/v0.1.3...v0.2.0)
|
16
|
+
|
17
|
+
**Merged pull requests:**
|
18
|
+
|
19
|
+
- updated gem version [\#10](https://github.com/jmtx1020/kitchen-yansible-pusher/pull/10) ([jmtx1020](https://github.com/jmtx1020))
|
20
|
+
- Feature: Added support for extra flags [\#9](https://github.com/jmtx1020/kitchen-yansible-pusher/pull/9) ([jmtx1020](https://github.com/jmtx1020))
|
21
|
+
- rename `extra_vars` to `env_vars` since it's for setting environment variables [\#8](https://github.com/jmtx1020/kitchen-yansible-pusher/pull/8) ([jmtx1020](https://github.com/jmtx1020))
|
22
|
+
|
23
|
+
## [v0.1.3](https://github.com/jmtx1020/kitchen-yansible-pusher/tree/v0.1.3) (2024-08-31)
|
24
|
+
|
25
|
+
[Full Changelog](https://github.com/jmtx1020/kitchen-yansible-pusher/compare/v0.1.2...v0.1.3)
|
26
|
+
|
27
|
+
**Merged pull requests:**
|
28
|
+
|
29
|
+
- fixed issue where user had to submit a vault file, updated version, enable fix branches in integration tests [\#7](https://github.com/jmtx1020/kitchen-yansible-pusher/pull/7) ([jmtx1020](https://github.com/jmtx1020))
|
30
|
+
|
31
|
+
## [v0.1.2](https://github.com/jmtx1020/kitchen-yansible-pusher/tree/v0.1.2) (2024-08-31)
|
32
|
+
|
33
|
+
[Full Changelog](https://github.com/jmtx1020/kitchen-yansible-pusher/compare/v0.1.1...v0.1.2)
|
34
|
+
|
35
|
+
**Merged pull requests:**
|
36
|
+
|
37
|
+
- bumping version [\#6](https://github.com/jmtx1020/kitchen-yansible-pusher/pull/6) ([jmtx1020](https://github.com/jmtx1020))
|
38
|
+
|
39
|
+
## [v0.1.1](https://github.com/jmtx1020/kitchen-yansible-pusher/tree/v0.1.1) (2024-08-31)
|
40
|
+
|
41
|
+
[Full Changelog](https://github.com/jmtx1020/kitchen-yansible-pusher/compare/v0.1.0...v0.1.1)
|
42
|
+
|
43
|
+
## [v0.1.0](https://github.com/jmtx1020/kitchen-yansible-pusher/tree/v0.1.0) (2024-08-31)
|
44
|
+
|
45
|
+
[Full Changelog](https://github.com/jmtx1020/kitchen-yansible-pusher/compare/v0.0.1pre...v0.1.0)
|
46
|
+
|
47
|
+
**Merged pull requests:**
|
48
|
+
|
49
|
+
- added allowed host push urls [\#5](https://github.com/jmtx1020/kitchen-yansible-pusher/pull/5) ([jmtx1020](https://github.com/jmtx1020))
|
50
|
+
- added better names, and release pipeline to rubygems [\#4](https://github.com/jmtx1020/kitchen-yansible-pusher/pull/4) ([jmtx1020](https://github.com/jmtx1020))
|
51
|
+
- Added Integration Tests [\#3](https://github.com/jmtx1020/kitchen-yansible-pusher/pull/3) ([jmtx1020](https://github.com/jmtx1020))
|
52
|
+
- additional-ruby-versions [\#2](https://github.com/jmtx1020/kitchen-yansible-pusher/pull/2) ([jmtx1020](https://github.com/jmtx1020))
|
53
|
+
- added github actions release pipeline [\#1](https://github.com/jmtx1020/kitchen-yansible-pusher/pull/1) ([jmtx1020](https://github.com/jmtx1020))
|
54
|
+
|
55
|
+
## [v0.0.1pre](https://github.com/jmtx1020/kitchen-yansible-pusher/tree/v0.0.1pre) (2024-08-30)
|
56
|
+
|
57
|
+
[Full Changelog](https://github.com/jmtx1020/kitchen-yansible-pusher/compare/1bf46ae6cbbff66f85fd2d3857271c44af727b56...v0.0.1pre)
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/README.md
CHANGED
@@ -8,7 +8,14 @@ The goal of this project was to make a modern and minimalistic test-kitchen prov
|
|
8
8
|
|
9
9
|
From using Ansible for a while, I believe Gems like [kitchen-ansible](https://github.com/neillturner/kitchen-ansible) and [kitchen-ansiblepush](https://github.com/ahelal/kitchen-ansiblepush) both do too much, as well as seem to have been abandoned by their respective creators.
|
10
10
|
|
11
|
-
By doing less, and expecting the user to install their own Ansible, provide their configuration in the form of environment variables, an `ansible.cfg` file
|
11
|
+
By doing less, and expecting the user to install their own Ansible, provide their configuration in the form of environment variables, an `ansible.cfg` file, tags, CLI flags and running only in `push` mode(normal mode) we free ourselves from having to support all kinds of installation methods across platforms and in a way future proof ourselves.
|
12
|
+
|
13
|
+
With that in mind, if there's something you think is missing please feel free to submit an issue or pull request and I will do my best to accomodate but keep in mind the goals of this project.
|
14
|
+
|
15
|
+
Additionally, these links to the documentation for `ansible-playbook` and `ansible.cfg` settings are here for convenience.
|
16
|
+
|
17
|
+
* [ansible-playbook](https://docs.ansible.com/ansible/latest/cli/ansible-playbook.html)
|
18
|
+
* [ansible-config](https://docs.ansible.com/ansible/latest/reference_appendices/config.html)
|
12
19
|
|
13
20
|
## Installation
|
14
21
|
|
@@ -21,7 +28,7 @@ gem 'kitchen-yansible-pusher',
|
|
21
28
|
branch: 'main'
|
22
29
|
|
23
30
|
# Install via RubyGems
|
24
|
-
gem 'kitchen-yansible-pusher', '~> 0.
|
31
|
+
gem 'kitchen-yansible-pusher', '~> 0.2.0'
|
25
32
|
```
|
26
33
|
|
27
34
|
## Usage
|
@@ -36,28 +43,71 @@ platforms:
|
|
36
43
|
- name: ubuntu-22.04
|
37
44
|
|
38
45
|
provisioner:
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
46
|
+
name: yansible_pusher
|
47
|
+
playbook: "/path/to/playbook.yaml"
|
48
|
+
config: "/path/to/ansible.cfg"
|
49
|
+
env_vars:
|
50
|
+
MARIO: "MUSHROOM_KINGDOM"
|
51
|
+
LINK: "HYRULE_KINGDOM"
|
52
|
+
extra_flags:
|
53
|
+
- --flush-cache
|
54
|
+
- --timeout 60
|
55
|
+
tags:
|
56
|
+
- tag1
|
57
|
+
- tag2
|
58
|
+
skip_tags:
|
59
|
+
- tag3
|
60
|
+
- tag4
|
61
|
+
verbosity: 1
|
62
|
+
vault_password_file: "/path/to/vault.password"
|
63
|
+
username: username
|
64
|
+
private_key: "/path/to/private.key"
|
55
65
|
|
56
66
|
suites:
|
57
67
|
- name: default
|
58
68
|
|
59
69
|
```
|
60
70
|
|
71
|
+
### Usage on Windows - Requirements
|
72
|
+
|
73
|
+
To use this gem and with a Windows target you need to install [PyWinRM](https://pypi.org/project/pywinrm/) as it is not part of the standard Ansible core distributed when you install through any methods.
|
74
|
+
|
75
|
+
```
|
76
|
+
pip install pywinrm
|
77
|
+
```
|
78
|
+
|
79
|
+
This error is known to occur when using the WinRM gem on Mac OS hosts due to the way Python forking works.
|
80
|
+
|
81
|
+
```
|
82
|
+
objc[78682]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
|
83
|
+
```
|
84
|
+
|
85
|
+
The solution is to run this command and then you should be able to run your role successfully.
|
86
|
+
|
87
|
+
```
|
88
|
+
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
|
89
|
+
```
|
90
|
+
|
91
|
+
### Windows Usage - Configuration
|
92
|
+
|
93
|
+
This provisoner infers the settings needed to connect to the box using the connection data from the instance, however if you need to overwrite any of these settings they are overwritable by specifying these values.
|
94
|
+
|
95
|
+
```yaml
|
96
|
+
provisioner:
|
97
|
+
name: yansible_pusher
|
98
|
+
winrm:
|
99
|
+
host: ""
|
100
|
+
port: 1234
|
101
|
+
user: username1
|
102
|
+
password: SuperSecurePassword!
|
103
|
+
connection: 'winrm'
|
104
|
+
server_cert_validation: 'ignore'
|
105
|
+
transport: 'ssl'
|
106
|
+
scheme: 'http'
|
107
|
+
```
|
108
|
+
|
109
|
+
More information about these settings can be found [here](https://docs.ansible.com/ansible/latest/os_guide/windows_winrm.html).
|
110
|
+
|
61
111
|
## Contributing
|
62
112
|
|
63
113
|
Bug reports and pull requests are welcome on GitHub at https://github.com/jmtx1020/kitchen-yansible-pusher.
|
@@ -13,7 +13,7 @@ module Kitchen
|
|
13
13
|
# provisioner:
|
14
14
|
# name: yansible_pusher
|
15
15
|
# playbook: playbooks/playbook.yml
|
16
|
-
#
|
16
|
+
# env_vars:
|
17
17
|
# MARIO: "MUSHROOM_KINGDOM"
|
18
18
|
# LINK: "HYRULE_KINGDOM"
|
19
19
|
#
|
@@ -27,13 +27,15 @@ module Kitchen
|
|
27
27
|
|
28
28
|
default_config :playbook, nil
|
29
29
|
default_config :config, nil
|
30
|
-
default_config :
|
30
|
+
default_config :env_vars, {}
|
31
|
+
default_config :extra_flags, []
|
31
32
|
default_config :tags, []
|
32
33
|
default_config :skip_tags, []
|
33
34
|
default_config :verbosity, 1
|
34
35
|
default_config :vault_password_file, nil
|
35
36
|
default_config :username, nil
|
36
37
|
default_config :private_key, nil
|
38
|
+
default_config :windows_config, nil
|
37
39
|
|
38
40
|
attr_reader :sandbox_path
|
39
41
|
|
@@ -61,6 +63,7 @@ module Kitchen
|
|
61
63
|
ensure
|
62
64
|
cleanup_sandbox
|
63
65
|
end
|
66
|
+
ensure_windows_exit_code if windows_instance?
|
64
67
|
end
|
65
68
|
|
66
69
|
private
|
@@ -88,6 +91,14 @@ module Kitchen
|
|
88
91
|
end
|
89
92
|
|
90
93
|
def build_host_config(state)
|
94
|
+
if windows_instance?
|
95
|
+
build_windows_config(state)
|
96
|
+
else
|
97
|
+
build_linux_config(state)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def build_linux_config(state)
|
91
102
|
{
|
92
103
|
'ansible_host' => state[:hostname],
|
93
104
|
'ansible_port' => state[:port],
|
@@ -95,6 +106,28 @@ module Kitchen
|
|
95
106
|
}
|
96
107
|
end
|
97
108
|
|
109
|
+
def build_windows_config(state)
|
110
|
+
uri = URI(state[:endpoint])
|
111
|
+
defaults = default_windows_config(state, uri)
|
112
|
+
user_windows_config(defaults)
|
113
|
+
end
|
114
|
+
|
115
|
+
def user_windows_config(defaults)
|
116
|
+
user_config = (config[:winrm_config] || {}).transform_keys { |key| "ansible_#{key}" }
|
117
|
+
defaults.merge(user_config.compact)
|
118
|
+
end
|
119
|
+
|
120
|
+
def default_windows_config(state, uri)
|
121
|
+
{ 'ansible_host' => uri.host,
|
122
|
+
'ansible_port' => state[:port] || uri.port,
|
123
|
+
'ansible_user' => state[:user],
|
124
|
+
'ansible_password' => state[:password],
|
125
|
+
'ansible_connection' => 'winrm',
|
126
|
+
'ansible_winrm_server_cert_validation' => 'ignore',
|
127
|
+
'ansible_winrm_transport' => 'ssl',
|
128
|
+
'ansible_winrm_scheme' => uri.scheme }
|
129
|
+
end
|
130
|
+
|
98
131
|
def write_inventory_file(inventory)
|
99
132
|
inventory_file = File.join(sandbox_path, 'inventory.yml')
|
100
133
|
File.write(inventory_file, inventory.to_yaml)
|
@@ -112,9 +145,10 @@ module Kitchen
|
|
112
145
|
def ansible_options
|
113
146
|
%i[
|
114
147
|
ansible_config
|
115
|
-
|
148
|
+
ansible_env_vars
|
116
149
|
ansible_use_private_key
|
117
150
|
ansible_use_vault_password_file
|
151
|
+
ansible_extra_flags
|
118
152
|
ansible_tags
|
119
153
|
ansible_skip_tags
|
120
154
|
ansible_verbosity
|
@@ -126,18 +160,23 @@ module Kitchen
|
|
126
160
|
cmd
|
127
161
|
end
|
128
162
|
|
129
|
-
def
|
130
|
-
config[:
|
163
|
+
def ansible_env_vars(cmd)
|
164
|
+
config[:env_vars]&.each { |k, v| cmd.prepend("#{k}=\"#{v}\"") }
|
165
|
+
cmd
|
166
|
+
end
|
167
|
+
|
168
|
+
def ansible_extra_flags(cmd)
|
169
|
+
cmd << config[:extra_flags].join(' ') unless config[:extra_flags].empty?
|
131
170
|
cmd
|
132
171
|
end
|
133
172
|
|
134
173
|
def ansible_tags(cmd)
|
135
|
-
cmd << "--tags \"#{config[:tags].join}\"" unless config[:tags].empty?
|
174
|
+
cmd << "--tags \"#{config[:tags].join(',')}\"" unless config[:tags].empty?
|
136
175
|
cmd
|
137
176
|
end
|
138
177
|
|
139
178
|
def ansible_skip_tags(cmd)
|
140
|
-
cmd << "--skip-tags \"#{config[:skip_tags].join}\"" unless config[:skip_tags].empty?
|
179
|
+
cmd << "--skip-tags \"#{config[:skip_tags].join(',')}\"" unless config[:skip_tags].empty?
|
141
180
|
cmd
|
142
181
|
end
|
143
182
|
|
@@ -146,7 +185,7 @@ module Kitchen
|
|
146
185
|
cmd << "--private-key #{config[:private_key]}"
|
147
186
|
else
|
148
187
|
state = instance.transport.instance_variable_get(:@connection_options)
|
149
|
-
cmd << "--private-key #{state[:keys][0]}"
|
188
|
+
cmd << "--private-key #{state[:keys][0]}" if state.key?(:keys)
|
150
189
|
end
|
151
190
|
cmd
|
152
191
|
end
|
@@ -158,6 +197,7 @@ module Kitchen
|
|
158
197
|
|
159
198
|
def ansible_verbosity(cmd)
|
160
199
|
cmd << "-#{'v' * config[:verbosity]}" if config[:verbosity] >= 1
|
200
|
+
cmd
|
161
201
|
end
|
162
202
|
|
163
203
|
def create_sandbox
|
@@ -179,6 +219,25 @@ module Kitchen
|
|
179
219
|
error("Failed to clean up sandbox: #{e.message}")
|
180
220
|
raise
|
181
221
|
end
|
222
|
+
|
223
|
+
def windows_instance?
|
224
|
+
instance.transport.instance_variable_get(:@connection_options).key?(:endpoint)
|
225
|
+
end
|
226
|
+
|
227
|
+
# Ensures proper exit code handling for Windows instances in Test Kitchen.
|
228
|
+
#
|
229
|
+
# @return [String] A PowerShell command string to be executed on the remote Windows system.
|
230
|
+
#
|
231
|
+
# This method is only called for Windows instances. It returns a PowerShell command that:
|
232
|
+
# 1. Outputs the status of the last command ($?)
|
233
|
+
# 2. Exits with 0 if the last command succeeded, or 1 if it failed
|
234
|
+
#
|
235
|
+
# This approach addresses a specific issue with Test Kitchen's WinRM transport,
|
236
|
+
# where it expects a command string to execute rather than a boolean result.
|
237
|
+
# It ensures that the correct exit code is returned to Test Kitchen.
|
238
|
+
def ensure_windows_exit_code
|
239
|
+
'$?; if($?) { exit 0 } else { exit 1 }'
|
240
|
+
end
|
182
241
|
end
|
183
242
|
end
|
184
243
|
end
|
@@ -23,7 +23,7 @@ module Kitchen
|
|
23
23
|
def build_ansible_command: () -> String
|
24
24
|
def ansible_options: () -> Array[Symbol]
|
25
25
|
def ansible_config: (Array[String]) -> Array[String]
|
26
|
-
def
|
26
|
+
def ansible_env_vars: (Array[String]) -> Array[String]
|
27
27
|
def ansible_tags: (Array[String]) -> Array[String]
|
28
28
|
def ansible_skip_tags: (Array[String]) -> Array[String]
|
29
29
|
def ansible_use_private_key: (Array[String]) -> Array[String]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-yansible-pusher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jose M. Tobar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A modern & minimalistic Ansible provisioner for Test Kitchen.
|
14
14
|
email:
|