kitchen-yansible 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/kitchen-yansible.gemspec +0 -1
- data/lib/kitchen-yansible/tools/dependencies.rb +56 -25
- data/lib/kitchen-yansible/version.rb +1 -1
- data/lib/kitchen/provisioner/yansible.rb +2 -2
- metadata +3 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3042f87171f0711d2879002115c0b61f235c28a75ecec3ca504832d0cada06e
|
4
|
+
data.tar.gz: 3c74feaede09b76cd984c486dc5c6b44828dfb5d10094a7034f5b0832c2edac4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba5b5367db8ab1aa7d322e6022ad2c2d0438066d2e2af552232f022fb1d4cae08245a7ab9949d406c351ee555ecd2f32dbb9ea558cc2e6eb61920e82307a39b0
|
7
|
+
data.tar.gz: 42be482cffb962b3f7ed0b93fc5dd03784951b99227c09c5a0ac7b1e08d135314764464b5d8ae1b2064bad2b816180936141f42f81fc8a4b875cb7156769a92c
|
data/kitchen-yansible.gemspec
CHANGED
@@ -18,15 +18,34 @@
|
|
18
18
|
# specific language governing permissions and limitations
|
19
19
|
# under the License.
|
20
20
|
|
21
|
-
require 'rugged'
|
22
|
-
|
23
21
|
module Kitchen
|
24
22
|
module Yansible
|
25
23
|
module Tools
|
26
24
|
module Dependencies
|
27
25
|
def git_clone(name, url, path)
|
28
26
|
info("Cloning '#{name}' Git repository.")
|
29
|
-
|
27
|
+
execute_local_command("git clone --progress --verbose #{url} #{path}")
|
28
|
+
end
|
29
|
+
|
30
|
+
def git_get_origin(path)
|
31
|
+
debug("Get '#{path}' origin.")
|
32
|
+
execute_local_command( 'git remote get-url origin', opts: { :chdir => path }, return_stdout: true )
|
33
|
+
end
|
34
|
+
|
35
|
+
def git_clean(path)
|
36
|
+
debug("Cleaning up '#{path}' origin.")
|
37
|
+
execute_local_command('git clean -fdx', opts: { :chdir => path })
|
38
|
+
execute_local_command('git reset --hard', opts: { :chdir => path })
|
39
|
+
end
|
40
|
+
|
41
|
+
def git_checkout(path, ref, force: false)
|
42
|
+
debug("Checking out #{ref} on #{path}.")
|
43
|
+
execute_local_command("git checkout #{ref}#{force ? ' -f' : ''}", opts: { :chdir => path })
|
44
|
+
end
|
45
|
+
|
46
|
+
def git_check_ref(path, ref)
|
47
|
+
debug("Checking out #{ref} on #{path}.")
|
48
|
+
execute_local_command("git show-ref #{ref}", opts: { :chdir => path })
|
30
49
|
end
|
31
50
|
|
32
51
|
def prepare_dependencies(dependencies)
|
@@ -44,40 +63,52 @@ module Kitchen
|
|
44
63
|
if dependency.key?(:repo)
|
45
64
|
if dependency[:repo].downcase == 'git'
|
46
65
|
info('Processing as Git repository.')
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
66
|
+
if command_exists('git')
|
67
|
+
if File.exist?(dependency_target_path)
|
68
|
+
if execute_local_command('git status .', opts: { :chdir => dependency_target_path })
|
69
|
+
if git_get_origin(dependency_target_path).chomp.eql?(dependency[:url])
|
70
|
+
warn("Dependency downloaded already, resetting to HEAD.")
|
71
|
+
git_clean(dependency_target_path)
|
72
|
+
else
|
73
|
+
warn("Removing directory #{dependency_target_path} due to repository origin difference.")
|
74
|
+
FileUtils.remove_entry_secure(dependency_target_path)
|
75
|
+
git_clone(dependency[:name], dependency[:url], dependency_target_path)
|
76
|
+
end
|
77
|
+
else
|
78
|
+
warn("Dependency path '#{dependency_target_path}' is not a valid Git repository. Removing then.")
|
79
|
+
FileUtils.remove_entry_secure(dependency_target_path)
|
80
|
+
git_clone(dependency[:name], dependency[:url], dependency_target_path)
|
81
|
+
end
|
51
82
|
else
|
52
|
-
warn("Removing directory #{dependency_target_path} due to repository origin difference.")
|
53
|
-
FileUtils.remove_entry_secure(dependency_target_path)
|
54
83
|
git_clone(dependency[:name], dependency[:url], dependency_target_path)
|
55
84
|
end
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
85
|
+
|
86
|
+
raw_ref = dependency.key?(:ref) ? dependency[:ref] : 'master'
|
87
|
+
begin
|
88
|
+
git_check_ref(dependency_target_path, raw_ref)
|
89
|
+
rescue
|
90
|
+
message = unindent(<<-MSG)
|
91
|
+
|
92
|
+
===============================================================================
|
93
|
+
Invalid Git reference - #{raw_ref}
|
94
|
+
Please check '#{dependency[:name]}' dependency configuration.
|
95
|
+
===============================================================================
|
96
|
+
MSG
|
97
|
+
raise UserError, message
|
60
98
|
end
|
61
|
-
repo = git_clone(dependency[:name], dependency[:url], dependency_target_path)
|
62
|
-
end
|
63
99
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
rescue
|
100
|
+
info("Resetting repository to '#{raw_ref}' reference.")
|
101
|
+
git_checkout(dependency_target_path, raw_ref, force: true)
|
102
|
+
else
|
68
103
|
message = unindent(<<-MSG)
|
69
104
|
|
70
105
|
===============================================================================
|
71
|
-
|
72
|
-
Please
|
106
|
+
Couldn't find git binary.
|
107
|
+
Please make sure execution host has Git binaries installed.
|
73
108
|
===============================================================================
|
74
109
|
MSG
|
75
110
|
raise UserError, message
|
76
111
|
end
|
77
|
-
|
78
|
-
info("Resetting '#{dependency[:name]}' repository to '#{raw_ref}' reference.")
|
79
|
-
repo.checkout(raw_ref, {:strategy => :force})
|
80
|
-
repo.close
|
81
112
|
else
|
82
113
|
raise UserError, "Working with '#{dependency[:repo]}' repository is not implemented yet."
|
83
114
|
end
|
@@ -236,8 +236,8 @@ module Kitchen
|
|
236
236
|
@command_args = []
|
237
237
|
@config[:ansible_extra_arguments].each { |arg| @command_args.push(arg) } if @config[:ansible_extra_arguments]
|
238
238
|
@config[:ansible_verbose] ? @command_args.push('-' + 'v' * @config[:ansible_verbosity]) : ''
|
239
|
-
@command_args.push("--inventory
|
240
|
-
@command_args.push("--limit
|
239
|
+
@command_args.push("--inventory='#{remote_file_path(ANSIBLE_INVENTORY, fallback: inventory_file)}'")
|
240
|
+
@command_args.push("--limit='#{@instance.name}'")
|
241
241
|
@command_args.push(remote_file_path(@config[:playbook]))
|
242
242
|
|
243
243
|
@command_args
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-yansible
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eugene Akhmetkhanov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-kitchen
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rugged
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0.25'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0.25'
|
41
27
|
description: |+
|
42
28
|
= Yet Another Ansible Test Kitchen Provisioner
|
43
29
|
---
|
@@ -96,8 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
82
|
- !ruby/object:Gem::Version
|
97
83
|
version: '0'
|
98
84
|
requirements: []
|
99
|
-
|
100
|
-
rubygems_version: 2.7.7
|
85
|
+
rubygems_version: 3.0.8
|
101
86
|
signing_key:
|
102
87
|
specification_version: 4
|
103
88
|
summary: Yet Another Ansible Test-Kitchen Provisioner
|