kitchen-omnibus-chef 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,229 @@
1
+ tmp_stderr="/tmp/stderr";
2
+
3
+ # capture_tmp_stderr SOURCE
4
+ capture_tmp_stderr() {
5
+ # spool up $tmp_stderr from all the commands we called
6
+ if test -f "$tmp_stderr"; then
7
+ output="`cat $tmp_stderr`";
8
+ stderr_results="${stderr_results}\nSTDERR from $1:\n\n${output}\n";
9
+ rm $tmp_stderr;
10
+ fi
11
+ }
12
+
13
+ # do_curl URL FILENAME
14
+ do_curl() {
15
+ echo "Trying curl...";
16
+ curl -sL -D "$tmp_stderr" "$1" > "$2";
17
+ ec=$?;
18
+ # check for 404
19
+ grep "404 Not Found" "$tmp_stderr" 2>&1 >/dev/null;
20
+ if test $? -eq 0; then
21
+ http_404_error "$1";
22
+ fi
23
+
24
+ # check for bad return status or empty output
25
+ if test $ec -ne 0 || test ! -s "$2"; then
26
+ capture_tmp_stderr "curl";
27
+ return 1;
28
+ else
29
+ echo "Download complete.";
30
+ return 0;
31
+ fi
32
+ }
33
+
34
+ # do_download URL FILENAME
35
+ do_download() {
36
+ echo "Downloading ${1} to file ${2}";
37
+
38
+ exists wget;
39
+ if test $? -eq 0; then
40
+ do_wget "$1" "$2" && return 0;
41
+ fi
42
+
43
+ exists curl;
44
+ if test $? -eq 0; then
45
+ do_curl "$1" "$2" && return 0;
46
+ fi
47
+
48
+ exists fetch;
49
+ if test $? -eq 0; then
50
+ do_fetch "$1" "$2" && return 0;
51
+ fi
52
+
53
+ exists python;
54
+ if test $? -eq 0; then
55
+ do_python "$1" "$2" && return 0;
56
+ fi
57
+
58
+ exists perl;
59
+ if test $? -eq 0; then
60
+ do_perl "$1" "$2" && return 0;
61
+ fi
62
+
63
+ unable_to_download "$1" "$2";
64
+ }
65
+
66
+ # do_fetch URL FILENAME
67
+ do_fetch() {
68
+ echo "Trying fetch...";
69
+ fetch -o "$2" "$1" 2>"$tmp_stderr";
70
+ ec=$?;
71
+ # check for 404
72
+ grep "Not Found" "$tmp_stderr" 2>&1 >/dev/null;
73
+ if test $? -eq 0; then
74
+ http_404_error "$1";
75
+ fi
76
+
77
+ # check for bad return status or empty output
78
+ if test $ec -ne 0 || test ! -s "$2"; then
79
+ capture_tmp_stderr "fetch";
80
+ return 1;
81
+ else
82
+ echo "Download complete.";
83
+ return 0;
84
+ fi
85
+ }
86
+
87
+ # do_perl URL FILENAME
88
+ do_perl() {
89
+ echo "Trying perl...";
90
+ perl -e "use LWP::Simple; getprint(\$ARGV[0]);" "$1" > "$2" 2>"$tmp_stderr";
91
+ ec=$?;
92
+ # check for 404
93
+ grep "404 Not Found" "$tmp_stderr" 2>&1 >/dev/null;
94
+ if test $? -eq 0; then
95
+ http_404_error "$1";
96
+ fi
97
+
98
+ # check for bad return status or empty output
99
+ if test $ec -ne 0 || test ! -s "$2"; then
100
+ capture_tmp_stderr "perl";
101
+ return 1;
102
+ else
103
+ echo "Download complete.";
104
+ return 0;
105
+ fi
106
+ }
107
+
108
+ # do_python URL FILENAME
109
+ do_python() {
110
+ echo "Trying python...";
111
+ python -c "import sys,urllib2 ; sys.stdout.write(urllib2.urlopen(sys.argv[1]).read())" "$1" > "$2" 2>"$tmp_stderr";
112
+ ec=$?;
113
+ # check for 404
114
+ grep "HTTP Error 404" "$tmp_stderr" 2>&1 >/dev/null;
115
+ if test $? -eq 0; then
116
+ http_404_error "$1";
117
+ fi
118
+
119
+ # check for bad return status or empty output
120
+ if test $ec -ne 0 || test ! -s "$2"; then
121
+ capture_tmp_stderr "python";
122
+ return 1;
123
+ else
124
+ echo "Download complete.";
125
+ return 0;
126
+ fi
127
+ }
128
+
129
+ # do_wget URL FILENAME
130
+ do_wget() {
131
+ echo "Trying wget...";
132
+ wget -O "$2" "$1" 2>"$tmp_stderr";
133
+ ec=$?;
134
+ # check for 404
135
+ grep "ERROR 404" "$tmp_stderr" 2>&1 >/dev/null;
136
+ if test $? -eq 0; then
137
+ http_404_error "$1";
138
+ fi
139
+
140
+ # check for bad return status or empty output
141
+ if test $ec -ne 0 || test ! -s "$2"; then
142
+ capture_tmp_stderr "wget";
143
+ return 1;
144
+ else
145
+ echo "Download complete.";
146
+ return 0;
147
+ fi
148
+ }
149
+
150
+ # exists COMMAND
151
+ exists() {
152
+ if command -v "$1" >/dev/null 2>&1; then
153
+ return 0;
154
+ else
155
+ return 1;
156
+ fi
157
+ }
158
+
159
+ # http_404_error URL
160
+ http_404_error() {
161
+ echo ">>>>>> Downloading ${1} resulted in an HTTP/404, aborting";
162
+ exit 40;
163
+ }
164
+
165
+ # should_update_chef ROOT VERSION
166
+ should_update_chef() {
167
+ if test ! -d "$1"; then
168
+ return 0;
169
+ elif test "$2" = "true"; then
170
+ return 1;
171
+ elif test "$2" = "latest"; then
172
+ return 0;
173
+ fi
174
+
175
+ if test -f "${1}/version-manifest.txt"; then
176
+ chef_version="`head -n 1 ${1}/version-manifest.txt | cut -d \" \" -f 2`";
177
+ else
178
+ chef_version="`${1}/bin/chef-solo -v | cut -d \" \" -f 2`";
179
+ fi
180
+
181
+ echo "$chef_version" | grep "^${2}" 2>&1 >/dev/null;
182
+ if test $? -eq 0; then
183
+ return 1;
184
+ else
185
+ echo "${2}" | grep "^$chef_version" 2>&1 >/dev/null;
186
+ if test $? -eq 0; then
187
+ return 1;
188
+ else
189
+ return 0;
190
+ fi
191
+ fi
192
+ }
193
+
194
+ # unable_to_download URL FILE
195
+ unable_to_download() {
196
+ echo "Unable to download $1 to $2, aborting";
197
+
198
+ if test "x${stderr_results}" != "x"; then
199
+ echo "\nDEBUG OUTPUT FOLLOWS:\n${stderr_results}";
200
+ fi
201
+
202
+ exit 10;
203
+ }
204
+
205
+ # main
206
+ main() {
207
+ should_update_chef "$chef_omnibus_root" "$version"
208
+ if test $? -eq 0; then
209
+ echo "-----> Installing Chef Infra Client package (${pretty_version})";
210
+
211
+ # solaris 10 lacks recent enough credentials, so http url is used
212
+ platform="`/usr/bin/uname -s 2>/dev/null`";
213
+ platform_version="`/usr/bin/uname -r 2>/dev/null`";
214
+ if test "x${platform}" = "xSunOS" && test "x${platform_version}" = "x5.10"; then
215
+ chef_omnibus_url=`echo "$chef_omnibus_url" | sed -e "s/https/http/"`;
216
+ fi
217
+
218
+ do_download "$chef_omnibus_url" /tmp/install.sh;
219
+ $sudo_sh /tmp/install.sh $install_flags;
220
+ else
221
+ echo "-----> Chef Infra Client package installation detected (${pretty_version})";
222
+ fi
223
+ }
224
+
225
+ # augment path in an attempt to find a download program
226
+ PATH="${PATH}:/opt/local/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/sfw/bin";
227
+ export PATH;
228
+
229
+ main
@@ -0,0 +1,109 @@
1
+ # Check whether a command exists - returns 0 if it does, 1 if it does not
2
+ exists() {
3
+ if command -v $1 >/dev/null 2>&1
4
+ then
5
+ return 0
6
+ else
7
+ return 1
8
+ fi
9
+ }
10
+
11
+ # do_wget URL FILENAME
12
+ do_wget() {
13
+ echo "trying wget..."
14
+ wget -O "$2" "$1" 2>/tmp/stderr
15
+ # check for bad return status
16
+ test $? -ne 0 && return 1
17
+ # check for 404 or empty file
18
+ grep "ERROR 404" /tmp/stderr 2>&1 >/dev/null
19
+ if test $? -eq 0 || test ! -s "$2"; then
20
+ return 1
21
+ fi
22
+ return 0
23
+ }
24
+
25
+ # do_curl URL FILENAME
26
+ do_curl() {
27
+ echo "trying curl..."
28
+ curl -L "$1" > "$2"
29
+ # check for bad return status
30
+ [ $? -ne 0 ] && return 1
31
+ # check for bad output or empty file
32
+ grep "The specified key does not exist." "$2" 2>&1 >/dev/null
33
+ if test $? -eq 0 || test ! -s "$2"; then
34
+ return 1
35
+ fi
36
+ return 0
37
+ }
38
+
39
+ # do_fetch URL FILENAME
40
+ do_fetch() {
41
+ echo "trying fetch..."
42
+ fetch -o "$2" "$1" 2>/tmp/stderr
43
+ # check for bad return status
44
+ test $? -ne 0 && return 1
45
+ return 0
46
+ }
47
+
48
+ # do_perl URL FILENAME
49
+ do_perl() {
50
+ echo "trying perl..."
51
+ perl -e "use LWP::Simple; getprint($ARGV[0]);" "$1" > "$2"
52
+ # check for bad return status
53
+ test $? -ne 0 && return 1
54
+ # check for bad output or empty file
55
+ # grep "The specified key does not exist." "$2" 2>&1 >/dev/null
56
+ # if test $? -eq 0 || test ! -s "$2"; then
57
+ # unable_to_retrieve_package
58
+ # fi
59
+ return 0
60
+ }
61
+
62
+ # do_python URL FILENAME
63
+ do_python() {
64
+ echo "trying python..."
65
+ python -c "import sys,urllib2 ; sys.stdout.write(urllib2.urlopen(sys.argv[1]).read())" "$1" > "$2"
66
+ # check for bad return status
67
+ test $? -ne 0 && return 1
68
+ # check for bad output or empty file
69
+ #grep "The specified key does not exist." "$2" 2>&1 >/dev/null
70
+ #if test $? -eq 0 || test ! -s "$2"; then
71
+ # unable_to_retrieve_package
72
+ #fi
73
+ return 0
74
+ }
75
+
76
+ # do_download URL FILENAME
77
+ do_download() {
78
+ PATH=/opt/local/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
79
+ export PATH
80
+
81
+ echo "downloading $1"
82
+ echo " to file $2"
83
+
84
+ # we try all of these until we get success.
85
+ # perl, in particular may be present but LWP::Simple may not be installed
86
+
87
+ if exists wget; then
88
+ do_wget $1 $2 && return 0
89
+ fi
90
+
91
+ if exists curl; then
92
+ do_curl $1 $2 && return 0
93
+ fi
94
+
95
+ if exists fetch; then
96
+ do_fetch $1 $2 && return 0
97
+ fi
98
+
99
+ if exists perl; then
100
+ do_perl $1 $2 && return 0
101
+ fi
102
+
103
+ if exists python; then
104
+ do_python $1 $2 && return 0
105
+ fi
106
+
107
+ echo ">>>>>> wget, curl, fetch, perl or python not found on this instance."
108
+ return 16
109
+ }
@@ -0,0 +1,27 @@
1
+ -----BEGIN RSA PRIVATE KEY-----
2
+ MIIEpAIBAAKCAQEA0sOY9tHvVtLZ6xmVmH8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18
+ JRqLfnlei5Ndo1lu286yL74c5rdTLs/nI2p4e+0CgYB079ZmcLeILrmfBoFI8+Y/
19
+ gJLmPrFvXBOE6+lRV7kqUFPtZ6I3yQzyccETZTDvrnx0WjaiFavUPH27WMjY01S2
20
+ TMtO0Iq1MPsbSrglO1as8MvjB9ldFcvp7gy4Q0Sv6XT0yqJ/S+vo8Df0m+H4UBpU
21
+ f5o6EwBSd/UQxwtZIE0lsQKBgQCswfjX8Eg8KL/lJNpIOOE3j4XXE9ptksmJl2sB
22
+ jxDnQYoiMqVO808saHVquC/vTrpd6tKtNpehWwjeTFuqITWLi8jmmQ+gNTKsC9Gn
23
+ 1Pxf2Gb67PqnEpwQGln+TRtgQ5HBrdHiQIi+5am+gnw89pDrjjO5rZwhanAo6KPJ
24
+ 1zcPNQKBgQDxFu8v4frDmRNCVaZS4f1B6wTrcMrnibIDlnzrK9GG6Hz1U7dDv8s8
25
+ Nf4UmeMzDXjlPWZVOvS5+9HKJPdPj7/onv8B2m18+lcgTTDJBkza7R1mjL1Cje/Z
26
+ KcVGsryKN6cjE7yCDasnA7R2rVBV/7NWeJV77bmzT5O//rW4yIfUIg==
27
+ -----END RSA PRIVATE KEY-----
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kitchen-omnibus-chef
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Fletcher Nichol
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-01-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: test-kitchen
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: mixlib-install
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: mixlib-shellout
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '1.2'
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: '4.0'
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '1.2'
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '4.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: license-acceptance
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 1.0.11
68
+ - - "<"
69
+ - !ruby/object:Gem::Version
70
+ version: '3.0'
71
+ type: :runtime
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: 1.0.11
78
+ - - "<"
79
+ - !ruby/object:Gem::Version
80
+ version: '3.0'
81
+ description: ''
82
+ email:
83
+ - fnichol@nichol.ca
84
+ executables: []
85
+ extensions: []
86
+ extra_rdoc_files: []
87
+ files:
88
+ - Gemfile
89
+ - LICENSE
90
+ - Rakefile
91
+ - kitchen-omnibus-chef.gemspec
92
+ - lib/kitchen/provisioner/chef/berkshelf.rb
93
+ - lib/kitchen/provisioner/chef/common_sandbox.rb
94
+ - lib/kitchen/provisioner/chef/policyfile.rb
95
+ - lib/kitchen/provisioner/chef_apply.rb
96
+ - lib/kitchen/provisioner/chef_base.rb
97
+ - lib/kitchen/provisioner/chef_infra.rb
98
+ - lib/kitchen/provisioner/chef_solo.rb
99
+ - lib/kitchen/provisioner/chef_target.rb
100
+ - lib/kitchen/provisioner/chef_zero.rb
101
+ - lib/kitchen/provisioner/omnibus_chef_version.rb
102
+ - support/chef-client-fail-if-update-handler.rb
103
+ - support/chef_base_init_command.ps1
104
+ - support/chef_base_init_command.sh
105
+ - support/chef_base_install_command.ps1
106
+ - support/chef_base_install_command.sh
107
+ - support/download_helpers.sh
108
+ - support/dummy-validation.pem
109
+ homepage: https://kitchen.ci/
110
+ licenses:
111
+ - Apache-2.0
112
+ metadata: {}
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '3.1'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubygems_version: 3.5.9
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: ''
132
+ test_files: []