kitchen-yansible-pusher 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa8a79886e6402a3e4a5c8c788ac05e7e2c1e7e156b0f112d8512055b30bc595
4
- data.tar.gz: 7bc8189cd68321d3f9819caa02d0f8cc90800b8853043f8120e61d3345e97967
3
+ metadata.gz: b71ce84978f4c0c04f3bf960f22cb555ebd102da45854477215e8fec8c2dc030
4
+ data.tar.gz: f36dd7eb60a4e3ffb01990ca40cb6d6049503eaa47e3af751abedc4f0036aed4
5
5
  SHA512:
6
- metadata.gz: 67185ace3c508dc785f86a40bfe4868b1fd735549a3ac25a001fe2b06eda89354afad72296a439661d610156ad9e094fe63ab4e9b06e196943fe7c1542cff650
7
- data.tar.gz: 9ce899f9b3803df41c2a097bd8fdbe395769a2379d4dc395a0150650eb3857397594a011734c578f72de3917c22c2eb9f87910fb7f9a4f7a8aa123e9225c7461
6
+ metadata.gz: e6cc7b7ba60df6febe0c8f96cf86a7349945483e049ad37e3ddbd27afd36f6ef9c621514d9321f256476a42220396da864a93459b98890ceb010805f29a02025
7
+ data.tar.gz: 50ec8b60ecc6595597a1ea6c4d7cb74eaead95719bd1308a5954e9a40a0bd2f7750a4f81289fefac27ec3e983ec957973fa7437ba73e76538e80ae1f322cf8ca
data/CHANGELOG.md CHANGED
@@ -1,5 +1,61 @@
1
- ## [Unreleased]
1
+ # Changelog
2
2
 
3
- ## [0.1.0] - 2024-08-29
3
+ ## [Unreleased](https://github.com/jmtx1020/kitchen-yansible-pusher/tree/HEAD)
4
4
 
5
- - Initial release
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
@@ -68,6 +68,46 @@ suites:
68
68
 
69
69
  ```
70
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
+
71
111
  ## Contributing
72
112
 
73
113
  Bug reports and pull requests are welcome on GitHub at https://github.com/jmtx1020/kitchen-yansible-pusher.
@@ -35,6 +35,7 @@ module Kitchen
35
35
  default_config :vault_password_file, nil
36
36
  default_config :username, nil
37
37
  default_config :private_key, nil
38
+ default_config :windows_config, nil
38
39
 
39
40
  attr_reader :sandbox_path
40
41
 
@@ -62,6 +63,7 @@ module Kitchen
62
63
  ensure
63
64
  cleanup_sandbox
64
65
  end
66
+ ensure_windows_exit_code if windows_instance?
65
67
  end
66
68
 
67
69
  private
@@ -89,6 +91,14 @@ module Kitchen
89
91
  end
90
92
 
91
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)
92
102
  {
93
103
  'ansible_host' => state[:hostname],
94
104
  'ansible_port' => state[:port],
@@ -96,6 +106,28 @@ module Kitchen
96
106
  }
97
107
  end
98
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
+
99
131
  def write_inventory_file(inventory)
100
132
  inventory_file = File.join(sandbox_path, 'inventory.yml')
101
133
  File.write(inventory_file, inventory.to_yaml)
@@ -134,7 +166,7 @@ module Kitchen
134
166
  end
135
167
 
136
168
  def ansible_extra_flags(cmd)
137
- cmd << "#{config[:extra_flags].join(" ")}" unless config[:extra_flags].empty?
169
+ cmd << config[:extra_flags].join(' ') unless config[:extra_flags].empty?
138
170
  cmd
139
171
  end
140
172
 
@@ -153,7 +185,7 @@ module Kitchen
153
185
  cmd << "--private-key #{config[:private_key]}"
154
186
  else
155
187
  state = instance.transport.instance_variable_get(:@connection_options)
156
- cmd << "--private-key #{state[:keys][0]}"
188
+ cmd << "--private-key #{state[:keys][0]}" if state.key?(:keys)
157
189
  end
158
190
  cmd
159
191
  end
@@ -165,6 +197,7 @@ module Kitchen
165
197
 
166
198
  def ansible_verbosity(cmd)
167
199
  cmd << "-#{'v' * config[:verbosity]}" if config[:verbosity] >= 1
200
+ cmd
168
201
  end
169
202
 
170
203
  def create_sandbox
@@ -186,6 +219,25 @@ module Kitchen
186
219
  error("Failed to clean up sandbox: #{e.message}")
187
220
  raise
188
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
189
241
  end
190
242
  end
191
243
  end
@@ -3,7 +3,7 @@
3
3
  module Kitchen
4
4
  module Yansible
5
5
  module Pusher
6
- VERSION = "0.2.0"
6
+ VERSION = "0.3.0"
7
7
  end
8
8
  end
9
9
  end
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.2.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-08-31 00:00:00.000000000 Z
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: