kitchen-yansible 0.0.2 → 0.0.3
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 +15 -14
- data/lib/kitchen-yansible/tools/install.rb +6 -5
- data/lib/kitchen-yansible/tools/install/amazon.rb +11 -4
- data/lib/kitchen-yansible/tools/install/darwin.rb +179 -0
- data/lib/kitchen-yansible/version.rb +1 -1
- data/lib/kitchen/provisioner/yansible.rb +8 -4
- metadata +18 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4416424c143f371bb9a09f4a072dc06f8445ee90dc08ad75e4189c3805ef4abb
|
4
|
+
data.tar.gz: 4f0cbde92dcd94e3a2acb9072d89668c646ce122833d79f57790bd5edeef798f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa8709f257d27ec5af58216a8e036fc776dbf9e9a5b2d112b8d2c472644a8ce9e68e81282c0ff586fc13f25d6267669d6c6a536b6ad3e2c6120a50bf6a47690e
|
7
|
+
data.tar.gz: 27f6c33a53aebc7886e02f5a650ff294fe02d6838d6008a2f72c0fa32ee83e7d26208f4516489f0e3c26d9e8abbfccb3bc0abeab7c26eb32b7d55bf937e1d197
|
data/kitchen-yansible.gemspec
CHANGED
@@ -37,20 +37,21 @@ Gem::Specification.new do |s|
|
|
37
37
|
= Yet Another Ansible Test Kitchen Provisioner
|
38
38
|
---
|
39
39
|
== Features
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
40
|
+
* Local and remote execution using single provisioner
|
41
|
+
* Local Ansible sandbox configuration using Virtualenv
|
42
|
+
* Local execution using Ansible from PATH
|
43
|
+
* Remote Ansible installation via Pip and Virtualenv
|
44
|
+
* Dependency management
|
45
|
+
* Path based
|
46
|
+
* Git repositories
|
47
|
+
* Drivers
|
48
|
+
* Docker
|
49
|
+
* Vagrant
|
50
|
+
* Platforms
|
51
|
+
* RHEL-based - CentOS, Fedora, Amazon Linux, Oracle Linux
|
52
|
+
* Debian-based - Debian, Ubuntu
|
53
|
+
* Windows via PS Remoting (Local executor only)
|
54
|
+
* MacOS Catalina 10.15.3
|
54
55
|
|
55
56
|
EOF
|
56
57
|
|
@@ -24,6 +24,7 @@ require 'kitchen-yansible/tools/install/fedora'
|
|
24
24
|
require 'kitchen-yansible/tools/install/amazon'
|
25
25
|
require 'kitchen-yansible/tools/install/debian'
|
26
26
|
require 'kitchen-yansible/tools/install/windows'
|
27
|
+
require 'kitchen-yansible/tools/install/darwin'
|
27
28
|
|
28
29
|
module Kitchen
|
29
30
|
module Yansible
|
@@ -56,14 +57,14 @@ module Kitchen
|
|
56
57
|
return Amazon.new(config, platform)
|
57
58
|
# when 'suse', 'opensuse', 'sles'
|
58
59
|
# return Suse.new(platform, config)
|
59
|
-
|
60
|
-
|
60
|
+
when 'darwin', 'mac', 'macos', 'macosx'
|
61
|
+
return Darwin.new(config, platform)
|
61
62
|
# when 'alpine'
|
62
|
-
# return Alpine.new(
|
63
|
+
# return Alpine.new(config, platform)
|
63
64
|
# when 'openbsd'
|
64
|
-
# return Openbsd.new(
|
65
|
+
# return Openbsd.new(config, platform)
|
65
66
|
# when 'freebsd'
|
66
|
-
# return Freebsd.new(
|
67
|
+
# return Freebsd.new(config, platform)
|
67
68
|
when /.*windows.*/
|
68
69
|
return Windows.new(config, platform)
|
69
70
|
else
|
@@ -34,6 +34,11 @@ module Kitchen
|
|
34
34
|
#{package_manager} -q info ${package} 2>/dev/null|grep installed &>/dev/null || #{install_package} ${package}
|
35
35
|
}
|
36
36
|
|
37
|
+
installPackageExtras () {
|
38
|
+
package=$1
|
39
|
+
#{package_manager} -q info ${package} 2>/dev/null|grep installed &>/dev/null || #{sudo('amazon-linux-extras')} install -y ${package}
|
40
|
+
}
|
41
|
+
|
37
42
|
preInstall () {
|
38
43
|
RHEL_VERSION=$(test -f /etc/system-release-cpe && awk -F':' '{print $5}' /etc/system-release-cpe || echo '0')
|
39
44
|
RHEL_DISTR=$(test -f /etc/system-release-cpe && awk -F':' '{print $3}' /etc/system-release-cpe || echo '0')
|
@@ -52,10 +57,12 @@ module Kitchen
|
|
52
57
|
esac
|
53
58
|
|
54
59
|
if [[ ${RHEL_VERSION} -eq 7 ]]; then
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
60
|
+
#{command_exists("ruby")} || {
|
61
|
+
echo \"Installing Ruby via Amazon Extras repository\"
|
62
|
+
RUBY_PACKAGE=$(#{sudo('amazon-linux-extras')} list|grep 'ruby\\([0-9\\.]\\+\\)\\?\\.'|sort -r|head -n1|awk '{print $2}')
|
63
|
+
installPackageExtras ${RUBY_PACKAGE}
|
64
|
+
installPackage rubygem-rdoc
|
65
|
+
}
|
59
66
|
fi
|
60
67
|
}
|
61
68
|
"""
|
@@ -0,0 +1,179 @@
|
|
1
|
+
# Author: Eugene Akhmetkhanov <axmetishe+github@gmail.com>
|
2
|
+
# Date: 27-02-2020
|
3
|
+
#
|
4
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
5
|
+
# or more contributor license agreements. See the NOTICE file
|
6
|
+
# distributed with this work for additional information
|
7
|
+
# regarding copyright ownership. The ASF licenses this file
|
8
|
+
# to you under the Apache License, Version 2.0 (the
|
9
|
+
# "License"); you may not use this file except in compliance
|
10
|
+
# with the License. You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing,
|
15
|
+
# software distributed under the License is distributed on an
|
16
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
17
|
+
# KIND, either express or implied. See the License for the
|
18
|
+
# specific language governing permissions and limitations
|
19
|
+
# under the License.
|
20
|
+
|
21
|
+
module Kitchen
|
22
|
+
module Yansible
|
23
|
+
module Tools
|
24
|
+
class Install
|
25
|
+
class Darwin < Install
|
26
|
+
def search_alternatives
|
27
|
+
"""
|
28
|
+
searchAlternatives() {
|
29
|
+
binaryCmd=$1
|
30
|
+
test -n \"${2}\" && installPrefix=\"${2}\" || installPrefix=#{BINARY_DEFAULT_PREFIX}
|
31
|
+
#{command_exists("${binaryCmd}")} || {
|
32
|
+
alternateCmd=$(ls -1A ${installPrefix}/${binaryCmd}*|sort -r|head -n1)
|
33
|
+
test -n \"${alternateCmd}\" && {
|
34
|
+
echo \"Attempt to install '${alternateCmd}' as an alternative.\"
|
35
|
+
#{sudo('ln')} -sf \"${alternateCmd}\" #{BINARY_DEFAULT_PREFIX}/${binaryCmd}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
"""
|
40
|
+
end
|
41
|
+
|
42
|
+
def preinstall_command
|
43
|
+
"""
|
44
|
+
#{update_path}
|
45
|
+
|
46
|
+
preInstall () {
|
47
|
+
updatePath
|
48
|
+
}
|
49
|
+
"""
|
50
|
+
end
|
51
|
+
|
52
|
+
def install_python
|
53
|
+
"""
|
54
|
+
installPython () {
|
55
|
+
PYTHON_CMD='/usr/bin/python3'
|
56
|
+
#{command_exists("${PYTHON_CMD}")} || {
|
57
|
+
PYTHON_CMD='/usr/bin/python'
|
58
|
+
}
|
59
|
+
grep 'ANSIBLE_PYTHON_INTERPRETER' ~/.profile &> /dev/null || {
|
60
|
+
echo \"ANSIBLE_PYTHON_INTERPRETER=${PYTHON_CMD}\" >> ~/.profile
|
61
|
+
echo 'export ANSIBLE_PYTHON_INTERPRETER' >> ~/.profile
|
62
|
+
}
|
63
|
+
#{sudo('grep')} ANSIBLE_PYTHON_INTERPRETER /etc/sudoers.d/ansible &> /dev/null || {
|
64
|
+
#{sudo('echo')} 'Defaults env_keep += \"ANSIBLE_PYTHON_INTERPRETER\"' | #{sudo('tee')} -a /etc/sudoers.d/ansible
|
65
|
+
}
|
66
|
+
|
67
|
+
source ~/.profile
|
68
|
+
}
|
69
|
+
"""
|
70
|
+
end
|
71
|
+
|
72
|
+
def install_ruby
|
73
|
+
"""
|
74
|
+
installRuby () {
|
75
|
+
searchAlternatives ruby
|
76
|
+
echo 'Install Busser'
|
77
|
+
#{sudo('gem')} list | grep busser || {
|
78
|
+
#{sudo('gem')} install busser
|
79
|
+
}
|
80
|
+
test -d /opt/chef/embedded/bin || {
|
81
|
+
#{sudo('mkdir')} -p /opt/chef/embedded/bin
|
82
|
+
}
|
83
|
+
echo 'Making links for Chef'
|
84
|
+
for binary in ruby gem busser; do
|
85
|
+
test -L /opt/chef/embedded/bin/${binary} || {
|
86
|
+
#{sudo('ln')} -sf $(command -v ${binary}) /opt/chef/embedded/bin/${binary}
|
87
|
+
}
|
88
|
+
done
|
89
|
+
}
|
90
|
+
"""
|
91
|
+
end
|
92
|
+
|
93
|
+
def install_virtualenv
|
94
|
+
"""
|
95
|
+
installVirtualenv () {
|
96
|
+
echo 'Checking Virtualenv installation.'
|
97
|
+
|
98
|
+
${ANSIBLE_PYTHON_INTERPRETER} -c 'help(\"modules\")'|grep ' pip ' &>/dev/null || {
|
99
|
+
${ANSIBLE_PYTHON_INTERPRETER} -m ensurepip
|
100
|
+
}
|
101
|
+
${ANSIBLE_PYTHON_INTERPRETER} -m pip list|grep 'virtualenv' &>/dev/null || {
|
102
|
+
${ANSIBLE_PYTHON_INTERPRETER} -m pip install --user virtualenv
|
103
|
+
}
|
104
|
+
}
|
105
|
+
"""
|
106
|
+
end
|
107
|
+
|
108
|
+
def update_path
|
109
|
+
"""
|
110
|
+
updatePath () {
|
111
|
+
#{sudo('grep')} secure_path /etc/sudoers.d/ansible &> /dev/null || {
|
112
|
+
#{sudo('echo')} 'Defaults secure_path = /usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin' | #{sudo('tee')} -a /etc/sudoers.d/ansible
|
113
|
+
}
|
114
|
+
|
115
|
+
grep 'PATH=/usr/local/bin:$PATH' ~/.profile &> /dev/null || {
|
116
|
+
echo 'PATH=/usr/local/bin:$PATH' >> ~/.profile
|
117
|
+
echo 'export PATH' >> ~/.profile
|
118
|
+
}
|
119
|
+
source ~/.profile
|
120
|
+
}
|
121
|
+
"""
|
122
|
+
end
|
123
|
+
|
124
|
+
def install_ansible_pip(sandbox_path)
|
125
|
+
"""
|
126
|
+
installAnsiblePip () {
|
127
|
+
echo \"Installing Ansible via Pip\"
|
128
|
+
VENV_MODULE=virtualenv
|
129
|
+
echo ${ANSIBLE_PYTHON_INTERPRETER} | grep 3 &>/dev/null && {
|
130
|
+
VENV_MODULE=venv
|
131
|
+
}
|
132
|
+
test -f #{sandbox_path}/venv/bin/pip || {
|
133
|
+
mkdir -p #{sandbox_path}
|
134
|
+
${ANSIBLE_PYTHON_INTERPRETER} -m ${VENV_MODULE} #{sandbox_path}/venv
|
135
|
+
#{sandbox_path}/venv/bin/pip install $PIP_ARGS --upgrade pip setuptools
|
136
|
+
}
|
137
|
+
#{sandbox_path}/venv/bin/pip install $PIP_ARGS #{pip_required_packages.join(' ')}
|
138
|
+
|
139
|
+
#{ansible_alternatives(BINARY_INSTALL_PREFIX, sandbox_path)}
|
140
|
+
}
|
141
|
+
"""
|
142
|
+
end
|
143
|
+
|
144
|
+
def ansible_alternatives(install_prefix, sandbox_path)
|
145
|
+
"""
|
146
|
+
#{command_exists("#{sandbox_path}/venv/bin/ansible")} && {
|
147
|
+
ansibleCommands=( \\
|
148
|
+
ansible \\
|
149
|
+
ansible-config \\
|
150
|
+
ansible-connection \\
|
151
|
+
ansible-console \\
|
152
|
+
ansible-doc \\
|
153
|
+
ansible-galaxy \\
|
154
|
+
ansible-inventory \\
|
155
|
+
ansible-playbook \\
|
156
|
+
ansible-pull \\
|
157
|
+
ansible-test \\
|
158
|
+
ansible-vault \\
|
159
|
+
)
|
160
|
+
for ansibleCommand in \"${ansibleCommands[@]}\"; do
|
161
|
+
#{sudo('ln -sf')} #{sandbox_path}/venv/bin/${ansibleCommand} #{install_prefix}/${ansibleCommand}
|
162
|
+
done
|
163
|
+
} || {
|
164
|
+
echo '===> Ansible is not installed, exiting now. <==='
|
165
|
+
exit 1
|
166
|
+
}
|
167
|
+
|
168
|
+
echo 'Check alternatives validity'
|
169
|
+
#{command_exists("#{install_prefix}/ansible")} || {
|
170
|
+
echo '===> Ansible alternative is incorrectly installed, exiting now. <==='
|
171
|
+
exit 1
|
172
|
+
}
|
173
|
+
"""
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
@@ -69,7 +69,7 @@ module Kitchen
|
|
69
69
|
if @config[:remote_executor]
|
70
70
|
if windows_os?
|
71
71
|
message = unindent(<<-MSG)
|
72
|
-
|
72
|
+
|
73
73
|
===============================================================================
|
74
74
|
We can't use Windows platform with remote installation.
|
75
75
|
Abandon ship!
|
@@ -89,7 +89,7 @@ module Kitchen
|
|
89
89
|
else
|
90
90
|
if RbConfig::CONFIG["host_os"] =~ /mswin|mingw/
|
91
91
|
message = unindent(<<-MSG)
|
92
|
-
|
92
|
+
|
93
93
|
===============================================================================
|
94
94
|
We can't use Windows platform as a Host system for sandboxing.
|
95
95
|
Abandon ship!
|
@@ -118,7 +118,7 @@ module Kitchen
|
|
118
118
|
)
|
119
119
|
else
|
120
120
|
message = unindent(<<-MSG)
|
121
|
-
|
121
|
+
|
122
122
|
===============================================================================
|
123
123
|
Couldn't find virtualenv binary for sandboxing.
|
124
124
|
Please make sure execution host has Python and VirtualEnv packages installed.
|
@@ -189,10 +189,14 @@ module Kitchen
|
|
189
189
|
info("Execute Ansible remotely.")
|
190
190
|
|
191
191
|
command_env_script = []
|
192
|
+
if %w(darwin mac macos macosx).include? detect_platform
|
193
|
+
command_env_script.push('source ~/.profile')
|
194
|
+
end
|
195
|
+
|
192
196
|
command_env.each {|k,v| command_env_script.push(shell_env_var(k, v))}
|
193
197
|
|
194
198
|
"""
|
195
|
-
#{command_env_script.join(' ')}; #{command} #{command_args.join(' ')}
|
199
|
+
#{command_env_script.join('; ')}; #{command} #{command_args.join(' ')}
|
196
200
|
"""
|
197
201
|
else
|
198
202
|
info("Execute Ansible locally.")
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eugene Akhmetkhanov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-kitchen
|
@@ -42,20 +42,21 @@ description: |+
|
|
42
42
|
= Yet Another Ansible Test Kitchen Provisioner
|
43
43
|
---
|
44
44
|
== Features
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
45
|
+
* Local and remote execution using single provisioner
|
46
|
+
* Local Ansible sandbox configuration using Virtualenv
|
47
|
+
* Local execution using Ansible from PATH
|
48
|
+
* Remote Ansible installation via Pip and Virtualenv
|
49
|
+
* Dependency management
|
50
|
+
* Path based
|
51
|
+
* Git repositories
|
52
|
+
* Drivers
|
53
|
+
* Docker
|
54
|
+
* Vagrant
|
55
|
+
* Platforms
|
56
|
+
* RHEL-based - CentOS, Fedora, Amazon Linux, Oracle Linux
|
57
|
+
* Debian-based - Debian, Ubuntu
|
58
|
+
* Windows via PS Remoting (Local executor only)
|
59
|
+
* MacOS Catalina 10.15.3
|
59
60
|
|
60
61
|
email:
|
61
62
|
- axmetishe+github@gmail.com
|
@@ -69,6 +70,7 @@ files:
|
|
69
70
|
- lib/kitchen-yansible/tools/files.rb
|
70
71
|
- lib/kitchen-yansible/tools/install.rb
|
71
72
|
- lib/kitchen-yansible/tools/install/amazon.rb
|
73
|
+
- lib/kitchen-yansible/tools/install/darwin.rb
|
72
74
|
- lib/kitchen-yansible/tools/install/debian.rb
|
73
75
|
- lib/kitchen-yansible/tools/install/fedora.rb
|
74
76
|
- lib/kitchen-yansible/tools/install/rhel.rb
|