opswalrus 1.0.57 → 1.0.59
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/opswalrus/app.rb +19 -24
- data/lib/opswalrus/bundler.rb +12 -12
- data/lib/opswalrus/cli.rb +3 -1
- data/lib/opswalrus/host.rb +2 -2
- data/lib/opswalrus/invocation.rb +4 -4
- data/lib/opswalrus/operation_runner.rb +0 -7
- data/lib/opswalrus/ops_file_script_dsl.rb +26 -8
- data/lib/opswalrus/version.rb +1 -1
- data/test.rb +88 -0
- data/vms/arch/Vagrantfile +27 -0
- data/vms/debian/Vagrantfile +26 -0
- data/vms/{web-fedora → fedora}/Vagrantfile +2 -2
- data/vms/freebsd/Vagrantfile +55 -0
- data/vms/rocky/Vagrantfile +55 -0
- data/vms/ubuntu/Vagrantfile +26 -0
- metadata +9 -5
- data/vms/web-arch/Vagrantfile +0 -92
- data/vms/web-ubuntu/Vagrantfile +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c02e6cf3098713124796fdaddf3630d91434d40a6f0df607cf4184e5cd060c3
|
4
|
+
data.tar.gz: bedbfd919aba32a943ac22a1596c439d74879f1e88b0f42a1062dd6fe3c5cc08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79e953bac9a4c83104431d0c2ccf871b684810a81283b52ad677d4bff7bee27c804f93ec94be43b3b24a7b6504a40419c6932de1525ed7d1fbc5a4b0293036a6
|
7
|
+
data.tar.gz: 1ed925365dd182c27dc922da7aa99319566aefc01154dd8227253bfcf2798f6fc92686c6832941dddb0d55ce1d28148b2e7a3c341c5a4d1c80fa1ba739a74ace
|
data/Gemfile.lock
CHANGED
data/lib/opswalrus/app.rb
CHANGED
@@ -32,7 +32,7 @@ module OpsWalrus
|
|
32
32
|
end
|
33
33
|
|
34
34
|
LOCAL_SUDO_PASSWORD_PROMPT = "[opswalrus] Please enter sudo password to run sudo in local environment: "
|
35
|
-
|
35
|
+
SCRIPT_RESULT_HEADER = "#### OpsWalrus Script Result JSON ".ljust(80, '#')
|
36
36
|
|
37
37
|
attr_reader :local_hostname
|
38
38
|
attr_reader :identity_file_paths
|
@@ -58,7 +58,7 @@ module OpsWalrus
|
|
58
58
|
@pwd = pwd.to_pathname
|
59
59
|
@bundler = Bundler.new(self, @pwd)
|
60
60
|
@local_hostname = "localhost"
|
61
|
-
@
|
61
|
+
@script_mode = false
|
62
62
|
@dry_run = false
|
63
63
|
@zip_mutex = Thread::Mutex.new
|
64
64
|
end
|
@@ -72,15 +72,11 @@ module OpsWalrus
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def script_mode!
|
75
|
-
@
|
76
|
-
end
|
77
|
-
|
78
|
-
def report_mode?
|
79
|
-
@mode == :report
|
75
|
+
@script_mode = true
|
80
76
|
end
|
81
77
|
|
82
78
|
def script_mode?
|
83
|
-
@
|
79
|
+
@script_mode
|
84
80
|
end
|
85
81
|
|
86
82
|
def dry_run?
|
@@ -269,13 +265,7 @@ module OpsWalrus
|
|
269
265
|
result = op.run([], params_json_hash: {ops_file: ops_file, operation_kv_args: operation_kv_args}.stringify_keys)
|
270
266
|
exit_status = result.exit_status
|
271
267
|
|
272
|
-
|
273
|
-
debug exit_status
|
274
|
-
|
275
|
-
debug "Op output"
|
276
|
-
debug JSON.pretty_generate(result.value)
|
277
|
-
|
278
|
-
puts JSON.pretty_generate(result.value)
|
268
|
+
print_script_result(result)
|
279
269
|
|
280
270
|
exit_status
|
281
271
|
rescue Error => e
|
@@ -305,13 +295,7 @@ module OpsWalrus
|
|
305
295
|
result = op.run(operation_kv_args, params_json_hash: @params)
|
306
296
|
exit_status = result.exit_status
|
307
297
|
|
308
|
-
|
309
|
-
debug exit_status
|
310
|
-
|
311
|
-
debug "Op output"
|
312
|
-
debug JSON.pretty_generate(result.value)
|
313
|
-
|
314
|
-
puts JSON.pretty_generate(result.value)
|
298
|
+
print_script_result(result)
|
315
299
|
|
316
300
|
exit_status
|
317
301
|
rescue Error => e
|
@@ -321,6 +305,17 @@ module OpsWalrus
|
|
321
305
|
FileUtils.remove_entry(tmp_bundle_root_dir) if tmp_bundle_root_dir
|
322
306
|
end
|
323
307
|
|
308
|
+
def print_script_result(result)
|
309
|
+
if script_mode?
|
310
|
+
output = StringIO.open do |io|
|
311
|
+
io.print(SCRIPT_RESULT_HEADER)
|
312
|
+
io.puts JSON.pretty_generate(result.value)
|
313
|
+
io.string
|
314
|
+
end
|
315
|
+
puts output
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
324
319
|
def load_entry_point_ops_file(ops_file_path, tmp_bundle_root_dir)
|
325
320
|
ops_file = OpsFile.new(self, ops_file_path)
|
326
321
|
|
@@ -449,8 +444,8 @@ module OpsWalrus
|
|
449
444
|
def bundle_status
|
450
445
|
end
|
451
446
|
|
452
|
-
def bundle_update
|
453
|
-
bundler.update
|
447
|
+
def bundle_update(force = false)
|
448
|
+
bundler.update(force)
|
454
449
|
end
|
455
450
|
|
456
451
|
def report_inventory(host_references, tags: nil)
|
data/lib/opswalrus/bundler.rb
CHANGED
@@ -55,7 +55,7 @@ module OpsWalrus
|
|
55
55
|
# bundler_for_package.include_directory_in_bundle_as_self_pkg(pwd)
|
56
56
|
# end
|
57
57
|
|
58
|
-
def update()
|
58
|
+
def update(force = false)
|
59
59
|
# delete_pwd_bundle_directory # this was causing problems when we do: ops run -r -b ... because a dynamic package reference was being
|
60
60
|
# downloaded to the bundle dir, and then update was being called afterward, which was blowing away
|
61
61
|
# the entire bundle dir, so when the bundle dir was copied to the remote host, the ops file being
|
@@ -66,22 +66,22 @@ module OpsWalrus
|
|
66
66
|
package_yaml_files = pwd.glob("./**/package.yaml") - pwd.glob("./**/#{BUNDLE_DIR}/**/package.yaml")
|
67
67
|
package_files_within_pwd = package_yaml_files.map {|path| PackageFile.new(path.realpath) }
|
68
68
|
|
69
|
-
download_package_dependency_tree(package_files_within_pwd)
|
69
|
+
download_package_dependency_tree(package_files_within_pwd, force: force)
|
70
70
|
|
71
71
|
ops_files = pwd.glob("./**/*.ops") - pwd.glob("./**/#{BUNDLE_DIR}/**/*.ops")
|
72
72
|
ops_files_within_pwd = ops_files.map {|path| OpsFile.new(@app, path.realpath) }
|
73
73
|
|
74
|
-
download_import_dependencies(ops_files_within_pwd)
|
74
|
+
download_import_dependencies(ops_files_within_pwd, force: force)
|
75
75
|
end
|
76
76
|
|
77
77
|
# downloads all transitive package dependencies associated with ops_files_and_package_files
|
78
78
|
# all downloaded packages are placed into @bundle_dir
|
79
|
-
def download_package_dependency_tree(*ops_files_and_package_files)
|
79
|
+
def download_package_dependency_tree(*ops_files_and_package_files, force: false)
|
80
80
|
package_files = ops_files_and_package_files.flatten.map(&:package_file).compact.uniq
|
81
81
|
|
82
82
|
package_files.each do |root_package_file|
|
83
83
|
pre_order_traverse(root_package_file) do |package_file|
|
84
|
-
download_package_dependencies(package_file).map do |downloaded_package_directory_path|
|
84
|
+
download_package_dependencies(package_file, force: force).map do |downloaded_package_directory_path|
|
85
85
|
package_file_path = File.join(downloaded_package_directory_path, "package.yaml")
|
86
86
|
PackageFile.new(package_file_path)
|
87
87
|
end
|
@@ -89,13 +89,13 @@ module OpsWalrus
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
def download_import_dependencies(*ops_files)
|
92
|
+
def download_import_dependencies(*ops_files, force: false)
|
93
93
|
ops_files.flatten.each do |ops_file|
|
94
94
|
ops_file.imports.each do |local_name, import_reference|
|
95
95
|
case import_reference
|
96
96
|
when PackageDependencyReference, DynamicPackageImportReference
|
97
97
|
package_reference = import_reference.package_reference
|
98
|
-
download_package(ops_file.dirname, ops_file.ops_file_path, package_reference)
|
98
|
+
download_package(ops_file.dirname, ops_file.ops_file_path, package_reference, force: force)
|
99
99
|
when DirectoryReference
|
100
100
|
# noop
|
101
101
|
when OpsFileReference
|
@@ -107,11 +107,11 @@ module OpsWalrus
|
|
107
107
|
|
108
108
|
# returns the array of the destination directories that the packages that ops_file depend on were downloaded to
|
109
109
|
# e.g. [dir_path1, dir_path2, dir_path3, ...]
|
110
|
-
def download_package_dependencies(package_file)
|
110
|
+
def download_package_dependencies(package_file, force: false)
|
111
111
|
containing_directory = package_file.containing_directory
|
112
112
|
package_file_source = package_file.package_file_path
|
113
113
|
package_file.dependencies.map do |local_name, package_reference|
|
114
|
-
download_package(containing_directory, package_file_source, package_reference)
|
114
|
+
download_package(containing_directory, package_file_source, package_reference, force: force)
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
@@ -138,7 +138,7 @@ module OpsWalrus
|
|
138
138
|
# returns the destination directory that the package was downloaded to
|
139
139
|
#
|
140
140
|
# relative_base_path is the relative base path that any relative file paths captured in the package_reference should be evaluated relative to
|
141
|
-
def download_package(relative_base_path, source_of_package_reference, package_reference)
|
141
|
+
def download_package(relative_base_path, source_of_package_reference, package_reference, force: false)
|
142
142
|
ensure_pwd_bundle_directory_exists
|
143
143
|
|
144
144
|
local_name = package_reference.local_name
|
@@ -152,11 +152,11 @@ module OpsWalrus
|
|
152
152
|
|
153
153
|
# we return early here under the assumption that an already downloaded package/version combo will not
|
154
154
|
# differ if we download it again multiple times to the same location
|
155
|
-
if destination_package_path.exist?
|
155
|
+
if destination_package_path.exist? && !force
|
156
156
|
App.instance.log("Skipping #{package_reference} referenced in #{source_of_package_reference} since it already has been downloaded to #{destination_package_path}")
|
157
157
|
return destination_package_path
|
158
158
|
end
|
159
|
-
|
159
|
+
FileUtils.remove_dir(destination_package_path) if destination_package_path.exist?
|
160
160
|
|
161
161
|
# download_package_contents(package_file.containing_directory, local_name, package_url, version, destination_package_path)
|
162
162
|
download_package_contents(relative_base_path, local_name, package_url, version, destination_package_path)
|
data/lib/opswalrus/cli.rb
CHANGED
@@ -275,10 +275,12 @@ module OpsWalrus
|
|
275
275
|
desc 'Update bundle dependencies'
|
276
276
|
long_desc 'Download and bundle the latest versions of dependencies for the current package'
|
277
277
|
c.command :update do |update|
|
278
|
+
update.switch [:f, :force], desc: "Force update even if the package has already been downloaded"
|
279
|
+
|
278
280
|
update.action do |global_options, options, args|
|
279
281
|
$app.set_log_level(global_options[:loudest] && :trace || global_options[:louder] && :debug || global_options[:loud] && :info || :warn)
|
280
282
|
|
281
|
-
$app.bundle_update
|
283
|
+
$app.bundle_update(options[:force])
|
282
284
|
end
|
283
285
|
end
|
284
286
|
|
data/lib/opswalrus/host.rb
CHANGED
@@ -288,8 +288,8 @@ module OpsWalrus
|
|
288
288
|
io.puts Style.cyan(out)
|
289
289
|
io.puts Style.red(err)
|
290
290
|
elsif App.instance.info?
|
291
|
-
|
292
|
-
|
291
|
+
io.puts Style.cyan(out)
|
292
|
+
io.puts Style.red(err)
|
293
293
|
end
|
294
294
|
io.print Style.yellow(cmd_id)
|
295
295
|
io.print Style.blue(" | Finished in #{seconds} seconds with exit status ")
|
data/lib/opswalrus/invocation.rb
CHANGED
@@ -122,8 +122,8 @@ module OpsWalrus
|
|
122
122
|
end
|
123
123
|
|
124
124
|
# invoke the ops command on the remote host to run the specified ops script on the remote host
|
125
|
-
ops_command_options = ""
|
126
|
-
ops_command_options << "--pass" if @ops_prompt_for_sudo_password
|
125
|
+
ops_command_options = "--script"
|
126
|
+
ops_command_options << " --pass" if @ops_prompt_for_sudo_password
|
127
127
|
ops_command_options << " --params #{remote_json_kwargs_tempfile_basename}" if remote_json_kwargs_tempfile_basename
|
128
128
|
retval = if ops_command_options.empty?
|
129
129
|
@host_proxy.run_ops(:run, remote_run_command_args, ops_prompt_for_sudo_password: @ops_prompt_for_sudo_password)
|
@@ -232,8 +232,8 @@ module OpsWalrus
|
|
232
232
|
end
|
233
233
|
|
234
234
|
# invoke the ops command on the remote host to run the specified ops script on the remote host
|
235
|
-
ops_command_options = ""
|
236
|
-
ops_command_options << "--pass" if @ops_prompt_for_sudo_password
|
235
|
+
ops_command_options = "--script"
|
236
|
+
ops_command_options << " --pass" if @ops_prompt_for_sudo_password
|
237
237
|
ops_command_options << " --params #{remote_json_kwargs_tempfile_basename}" if remote_json_kwargs_tempfile_basename
|
238
238
|
retval = if ops_command_options.empty?
|
239
239
|
@host_proxy.run_ops(:run, remote_run_command_args, ops_prompt_for_sudo_password: @ops_prompt_for_sudo_password)
|
@@ -110,13 +110,6 @@ module OpsWalrus
|
|
110
110
|
Invocation::Error.new(e)
|
111
111
|
end
|
112
112
|
|
113
|
-
# if result.failure?
|
114
|
-
# App.instance.debug "Ops script error details:"
|
115
|
-
# App.instance.debug "Error: #{result.value}"
|
116
|
-
# App.instance.debug "Status code: #{result.exit_status}"
|
117
|
-
# App.instance.debug @entry_point_ops_file.script.to_s
|
118
|
-
# end
|
119
|
-
|
120
113
|
result
|
121
114
|
end
|
122
115
|
end
|
@@ -322,21 +322,23 @@ module OpsWalrus
|
|
322
322
|
puts output_block unless output_block.empty?
|
323
323
|
|
324
324
|
t1 = Time.now
|
325
|
-
|
325
|
+
output, stderr, exit_status = yield
|
326
326
|
t2 = Time.now
|
327
327
|
seconds = t2 - t1
|
328
328
|
|
329
|
+
stdout, remote_ops_script_retval = parse_stdout_and_script_return_value(output)
|
330
|
+
|
329
331
|
output_block = StringIO.open do |io|
|
330
332
|
if App.instance.info? # this is true if log_level is trace, debug, info
|
331
333
|
if App.instance.trace?
|
332
|
-
io.puts Style.cyan(
|
333
|
-
io.puts Style.red(
|
334
|
+
io.puts Style.cyan(stdout)
|
335
|
+
io.puts Style.red(stderr)
|
334
336
|
elsif App.instance.debug?
|
335
|
-
io.puts Style.cyan(
|
336
|
-
io.puts Style.red(
|
337
|
+
io.puts Style.cyan(stdout)
|
338
|
+
io.puts Style.red(stderr)
|
337
339
|
elsif App.instance.info?
|
338
|
-
|
339
|
-
|
340
|
+
io.puts Style.cyan(stdout)
|
341
|
+
io.puts Style.red(stderr)
|
340
342
|
end
|
341
343
|
io.print Style.yellow(cmd_id)
|
342
344
|
io.print Style.blue(" | Finished in #{seconds} seconds with exit status ")
|
@@ -359,7 +361,23 @@ module OpsWalrus
|
|
359
361
|
end
|
360
362
|
puts output_block unless output_block.empty?
|
361
363
|
|
362
|
-
|
364
|
+
out = remote_ops_script_retval || stdout
|
365
|
+
[out, stderr, exit_status]
|
366
|
+
end
|
367
|
+
|
368
|
+
def parse_stdout_and_script_return_value(command_output)
|
369
|
+
output_sections = command_output.split(/^#{::OpsWalrus::App::SCRIPT_RESULT_HEADER}$/)
|
370
|
+
case output_sections.count
|
371
|
+
when 1
|
372
|
+
stdout, ops_script_retval = output_sections.first, nil
|
373
|
+
when 2
|
374
|
+
stdout, ops_script_retval = *output_sections
|
375
|
+
else
|
376
|
+
# this is unexpected
|
377
|
+
ops_script_retval = output_sections.pop
|
378
|
+
stdout = output_sections.join(::OpsWalrus::App::SCRIPT_RESULT_HEADER)
|
379
|
+
end
|
380
|
+
[stdout, ops_script_retval]
|
363
381
|
end
|
364
382
|
|
365
383
|
end
|
data/lib/opswalrus/version.rb
CHANGED
data/test.rb
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'tty-option'
|
2
|
+
|
3
|
+
class Command
|
4
|
+
include TTY::Option
|
5
|
+
|
6
|
+
usage do
|
7
|
+
program "dock"
|
8
|
+
|
9
|
+
command "run"
|
10
|
+
|
11
|
+
desc "Run a command in a new container"
|
12
|
+
|
13
|
+
example "Set working directory (-w)",
|
14
|
+
" $ dock run -w /path/to/dir/ ubuntu pwd"
|
15
|
+
|
16
|
+
example <<~EOS
|
17
|
+
Mount volume
|
18
|
+
$ dock run -v `pwd`:`pwd` -w `pwd` ubuntu pwd
|
19
|
+
EOS
|
20
|
+
end
|
21
|
+
|
22
|
+
argument :image do
|
23
|
+
required
|
24
|
+
desc "The name of the image to use"
|
25
|
+
end
|
26
|
+
|
27
|
+
argument :command do
|
28
|
+
optional
|
29
|
+
desc "The command to run inside the image"
|
30
|
+
end
|
31
|
+
|
32
|
+
keyword :restart do
|
33
|
+
default "no"
|
34
|
+
permit %w[no on-failure always unless-stopped]
|
35
|
+
desc "Restart policy to apply when a container exits"
|
36
|
+
end
|
37
|
+
|
38
|
+
option :verbose do
|
39
|
+
arity "+"
|
40
|
+
short "-v"
|
41
|
+
desc "Verbose mode"
|
42
|
+
end
|
43
|
+
|
44
|
+
flag :detach do
|
45
|
+
short "-d"
|
46
|
+
long "--detach"
|
47
|
+
desc "Run container in background and print container ID"
|
48
|
+
end
|
49
|
+
|
50
|
+
flag :help do
|
51
|
+
short "-h"
|
52
|
+
long "--help"
|
53
|
+
desc "Print usage"
|
54
|
+
end
|
55
|
+
|
56
|
+
option :name do
|
57
|
+
required
|
58
|
+
long "--name string"
|
59
|
+
desc "Assign a name to the container"
|
60
|
+
end
|
61
|
+
|
62
|
+
option :port do
|
63
|
+
arity one_or_more
|
64
|
+
short "-p"
|
65
|
+
long "--publish list"
|
66
|
+
convert :list
|
67
|
+
desc "Publish a container's port(s) to the host"
|
68
|
+
end
|
69
|
+
|
70
|
+
def run
|
71
|
+
puts params[:verbose].inspect
|
72
|
+
if params[:help]
|
73
|
+
print help
|
74
|
+
elsif params.errors.any?
|
75
|
+
puts params.errors.summary
|
76
|
+
else
|
77
|
+
pp params.to_h
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def main
|
83
|
+
cmd = Command.new
|
84
|
+
cmd.parse
|
85
|
+
puts cmd.run
|
86
|
+
end
|
87
|
+
|
88
|
+
main
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
Vagrant.configure("2") do |config|
|
5
|
+
config.vm.box = "archlinux/archlinux"
|
6
|
+
|
7
|
+
config.vm.network "private_network", ip: "192.168.56.10"
|
8
|
+
|
9
|
+
# config.ssh.insert_key = false
|
10
|
+
config.ssh.forward_agent = true
|
11
|
+
|
12
|
+
config.vm.provision "shell" do |s|
|
13
|
+
ssh_pub_key = File.readlines("#{Dir.home}/.ssh/id_ops.pub").first.strip
|
14
|
+
s.inline = <<-SHELL
|
15
|
+
echo #{ssh_pub_key} >> /home/vagrant/.ssh/authorized_keys
|
16
|
+
echo #{ssh_pub_key} >> /root/.ssh/authorized_keys
|
17
|
+
|
18
|
+
sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
|
19
|
+
sudo systemctl restart sshd
|
20
|
+
|
21
|
+
# change vagrant user to require sudo password
|
22
|
+
sudo sed -i 's/vagrant ALL=(ALL) NOPASSWD: ALL/vagrant ALL=(ALL:ALL) ALL/g' /etc/sudoers.d/vagrant
|
23
|
+
|
24
|
+
# sudo sh -c 'echo root:foo | chpasswd'
|
25
|
+
SHELL
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
Vagrant.configure("2") do |config|
|
5
|
+
config.vm.box = "bento/debian-12"
|
6
|
+
|
7
|
+
config.vm.network "private_network", ip: "192.168.56.11"
|
8
|
+
|
9
|
+
config.ssh.forward_agent = true
|
10
|
+
|
11
|
+
config.vm.provision "shell" do |s|
|
12
|
+
ssh_pub_key = File.readlines("#{Dir.home}/.ssh/id_ops.pub").first.strip
|
13
|
+
s.inline = <<-SHELL
|
14
|
+
# echo #{ssh_pub_key} >> /home/vagrant/.ssh/authorized_keys
|
15
|
+
# echo #{ssh_pub_key} >> /root/.ssh/authorized_keys
|
16
|
+
|
17
|
+
sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
|
18
|
+
sudo systemctl restart sshd
|
19
|
+
|
20
|
+
# change vagrant user to require sudo password
|
21
|
+
sudo sed -i 's/vagrant ALL=(ALL) NOPASSWD:ALL/vagrant ALL=(ALL:ALL) ALL/g' /etc/sudoers.d/vagrant
|
22
|
+
|
23
|
+
# sudo sh -c 'echo root:foo | chpasswd'
|
24
|
+
SHELL
|
25
|
+
end
|
26
|
+
end
|
@@ -8,11 +8,11 @@ Vagrant.configure("2") do |config|
|
|
8
8
|
|
9
9
|
# Every Vagrant development environment requires a box. You can search for
|
10
10
|
# boxes at https://vagrantcloud.com/search.
|
11
|
-
config.vm.box = "fedora
|
11
|
+
config.vm.box = "bento/fedora-38"
|
12
12
|
|
13
13
|
# Create a private network, which allows host-only access to the machine
|
14
14
|
# using a specific IP.
|
15
|
-
config.vm.network "private_network", ip: "192.168.56.
|
15
|
+
config.vm.network "private_network", ip: "192.168.56.12"
|
16
16
|
|
17
17
|
# config.ssh.insert_key = false
|
18
18
|
config.ssh.forward_agent = true
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
Vagrant.configure("2") do |config|
|
5
|
+
# The most common configuration options are documented and commented below.
|
6
|
+
# For a complete reference, please see the online documentation at
|
7
|
+
# https://docs.vagrantup.com.
|
8
|
+
|
9
|
+
# Every Vagrant development environment requires a box. You can search for
|
10
|
+
# boxes at https://vagrantcloud.com/search.
|
11
|
+
config.vm.box = "bento/freebsd-13"
|
12
|
+
|
13
|
+
# Create a private network, which allows host-only access to the machine
|
14
|
+
# using a specific IP.
|
15
|
+
config.vm.network "private_network", ip: "192.168.56.13"
|
16
|
+
|
17
|
+
# config.ssh.insert_key = false
|
18
|
+
config.ssh.forward_agent = true
|
19
|
+
|
20
|
+
config.vm.provider "virtualbox" do |vb|
|
21
|
+
# # Display the VirtualBox GUI when booting the machine
|
22
|
+
# vb.gui = true
|
23
|
+
#
|
24
|
+
# # Customize the amount of memory on the VM:
|
25
|
+
vb.memory = "1024"
|
26
|
+
end
|
27
|
+
|
28
|
+
# Enable provisioning with a shell script. Additional provisioners such as
|
29
|
+
# Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
|
30
|
+
# documentation for more information about their specific syntax and use.
|
31
|
+
config.vm.provision "shell", inline: <<-SHELL
|
32
|
+
echo "tmpfs /tmp tmpfs rw,nodev,nosuid,size=5G 0 0" | sudo tee -a /etc/fstab
|
33
|
+
|
34
|
+
# this helps to address the issue where new builds of fedora do not honor the vagrant network config settings
|
35
|
+
sudo dnf install -yq NetworkManager-initscripts-ifcfg-rh
|
36
|
+
|
37
|
+
# this migrates the old network management config to the new style
|
38
|
+
sudo nmcli connection migrate
|
39
|
+
|
40
|
+
# # per https://github.com/hashicorp/vagrant/issues/12762#issuecomment-1535957837 :
|
41
|
+
# sudo nmcli conn modify 'Wired connection 2' ipv4.addresses $(cat /etc/sysconfig/network-scripts/ifcfg-eth1 | grep IPADDR | cut -d "=" -f2)
|
42
|
+
# sudo nmcli conn modify 'Wired connection 2' ipv4.method manual
|
43
|
+
# sudo systemctl restart NetworkManager
|
44
|
+
|
45
|
+
sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
|
46
|
+
sudo systemctl restart sshd
|
47
|
+
|
48
|
+
nohup sudo -b bash -c 'sleep 3; reboot' &>/dev/null;
|
49
|
+
|
50
|
+
# change vagrant user to require sudo password
|
51
|
+
sudo sed -i 's/vagrant ALL=(ALL) NOPASSWD: ALL/vagrant ALL=(ALL:ALL) ALL/g' /etc/sudoers.d/vagrant-nopasswd
|
52
|
+
|
53
|
+
# sudo sh -c 'echo root:foo | chpasswd'
|
54
|
+
SHELL
|
55
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
Vagrant.configure("2") do |config|
|
5
|
+
# The most common configuration options are documented and commented below.
|
6
|
+
# For a complete reference, please see the online documentation at
|
7
|
+
# https://docs.vagrantup.com.
|
8
|
+
|
9
|
+
# Every Vagrant development environment requires a box. You can search for
|
10
|
+
# boxes at https://vagrantcloud.com/search.
|
11
|
+
config.vm.box = "bento/rockylinux-9"
|
12
|
+
|
13
|
+
# Create a private network, which allows host-only access to the machine
|
14
|
+
# using a specific IP.
|
15
|
+
config.vm.network "private_network", ip: "192.168.56.14"
|
16
|
+
|
17
|
+
# config.ssh.insert_key = false
|
18
|
+
config.ssh.forward_agent = true
|
19
|
+
|
20
|
+
config.vm.provider "virtualbox" do |vb|
|
21
|
+
# # Display the VirtualBox GUI when booting the machine
|
22
|
+
# vb.gui = true
|
23
|
+
#
|
24
|
+
# # Customize the amount of memory on the VM:
|
25
|
+
vb.memory = "1024"
|
26
|
+
end
|
27
|
+
|
28
|
+
# Enable provisioning with a shell script. Additional provisioners such as
|
29
|
+
# Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
|
30
|
+
# documentation for more information about their specific syntax and use.
|
31
|
+
config.vm.provision "shell", inline: <<-SHELL
|
32
|
+
echo "tmpfs /tmp tmpfs rw,nodev,nosuid,size=5G 0 0" | sudo tee -a /etc/fstab
|
33
|
+
|
34
|
+
# this helps to address the issue where new builds of fedora do not honor the vagrant network config settings
|
35
|
+
sudo dnf install -yq NetworkManager-initscripts-ifcfg-rh
|
36
|
+
|
37
|
+
# this migrates the old network management config to the new style
|
38
|
+
sudo nmcli connection migrate
|
39
|
+
|
40
|
+
# # per https://github.com/hashicorp/vagrant/issues/12762#issuecomment-1535957837 :
|
41
|
+
# sudo nmcli conn modify 'Wired connection 2' ipv4.addresses $(cat /etc/sysconfig/network-scripts/ifcfg-eth1 | grep IPADDR | cut -d "=" -f2)
|
42
|
+
# sudo nmcli conn modify 'Wired connection 2' ipv4.method manual
|
43
|
+
# sudo systemctl restart NetworkManager
|
44
|
+
|
45
|
+
sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
|
46
|
+
sudo systemctl restart sshd
|
47
|
+
|
48
|
+
nohup sudo -b bash -c 'sleep 3; reboot' &>/dev/null;
|
49
|
+
|
50
|
+
# change vagrant user to require sudo password
|
51
|
+
sudo sed -i 's/vagrant ALL=(ALL) NOPASSWD: ALL/vagrant ALL=(ALL:ALL) ALL/g' /etc/sudoers.d/vagrant-nopasswd
|
52
|
+
|
53
|
+
# sudo sh -c 'echo root:foo | chpasswd'
|
54
|
+
SHELL
|
55
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
Vagrant.configure("2") do |config|
|
5
|
+
config.vm.box = "bento/ubuntu-22.04"
|
6
|
+
|
7
|
+
config.vm.network "private_network", ip: "192.168.56.15"
|
8
|
+
|
9
|
+
config.ssh.forward_agent = true
|
10
|
+
|
11
|
+
config.vm.provision "shell" do |s|
|
12
|
+
ssh_pub_key = File.readlines("#{Dir.home}/.ssh/id_ops.pub").first.strip
|
13
|
+
s.inline = <<-SHELL
|
14
|
+
# echo #{ssh_pub_key} >> /home/vagrant/.ssh/authorized_keys
|
15
|
+
# echo #{ssh_pub_key} >> /root/.ssh/authorized_keys
|
16
|
+
|
17
|
+
sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
|
18
|
+
sudo systemctl restart sshd
|
19
|
+
|
20
|
+
# change vagrant user to require sudo password
|
21
|
+
sudo sed -i 's/vagrant ALL=(ALL) NOPASSWD:ALL/vagrant ALL=(ALL:ALL) ALL/g' /etc/sudoers.d/vagrant
|
22
|
+
|
23
|
+
# sudo sh -c 'echo root:foo | chpasswd'
|
24
|
+
SHELL
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opswalrus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.59
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Ellis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -229,9 +229,13 @@ files:
|
|
229
229
|
- lib/opswalrus/zip.rb
|
230
230
|
- opswalrus.gemspec
|
231
231
|
- sig/opswalrus.rbs
|
232
|
-
-
|
233
|
-
- vms/
|
234
|
-
- vms/
|
232
|
+
- test.rb
|
233
|
+
- vms/arch/Vagrantfile
|
234
|
+
- vms/debian/Vagrantfile
|
235
|
+
- vms/fedora/Vagrantfile
|
236
|
+
- vms/freebsd/Vagrantfile
|
237
|
+
- vms/rocky/Vagrantfile
|
238
|
+
- vms/ubuntu/Vagrantfile
|
235
239
|
homepage: https://github.com/opswalrus/opswalrus
|
236
240
|
licenses:
|
237
241
|
- EPL-2.0
|
data/vms/web-arch/Vagrantfile
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
# -*- mode: ruby -*-
|
2
|
-
# vi: set ft=ruby :
|
3
|
-
|
4
|
-
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
5
|
-
# configures the configuration version (we support older styles for
|
6
|
-
# backwards compatibility). Please don't change it unless you know what
|
7
|
-
# you're doing.
|
8
|
-
Vagrant.configure("2") do |config|
|
9
|
-
# The most common configuration options are documented and commented below.
|
10
|
-
# For a complete reference, please see the online documentation at
|
11
|
-
# https://docs.vagrantup.com.
|
12
|
-
|
13
|
-
# Every Vagrant development environment requires a box. You can search for
|
14
|
-
# boxes at https://vagrantcloud.com/search.
|
15
|
-
config.vm.box = "generic/arch"
|
16
|
-
|
17
|
-
# Disable automatic box update checking. If you disable this, then
|
18
|
-
# boxes will only be checked for updates when the user runs
|
19
|
-
# `vagrant box outdated`. This is not recommended.
|
20
|
-
# config.vm.box_check_update = false
|
21
|
-
|
22
|
-
# Create a forwarded port mapping which allows access to a specific port
|
23
|
-
# within the machine from a port on the host machine. In the example below,
|
24
|
-
# accessing "localhost:8080" will access port 80 on the guest machine.
|
25
|
-
# NOTE: This will enable public access to the opened port
|
26
|
-
# config.vm.network "forwarded_port", guest: 80, host: 8080
|
27
|
-
|
28
|
-
# Create a forwarded port mapping which allows access to a specific port
|
29
|
-
# within the machine from a port on the host machine and only allow access
|
30
|
-
# via 127.0.0.1 to disable public access
|
31
|
-
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
|
32
|
-
|
33
|
-
# Create a private network, which allows host-only access to the machine
|
34
|
-
# using a specific IP.
|
35
|
-
config.vm.network "private_network", ip: "192.168.56.12"
|
36
|
-
|
37
|
-
# config.ssh.insert_key = false
|
38
|
-
config.ssh.forward_agent = true
|
39
|
-
|
40
|
-
|
41
|
-
# Create a public network, which generally matched to bridged network.
|
42
|
-
# Bridged networks make the machine appear as another physical device on
|
43
|
-
# your network.
|
44
|
-
# config.vm.network "public_network"
|
45
|
-
|
46
|
-
# Share an additional folder to the guest VM. The first argument is
|
47
|
-
# the path on the host to the actual folder. The second argument is
|
48
|
-
# the path on the guest to mount the folder. And the optional third
|
49
|
-
# argument is a set of non-required options.
|
50
|
-
# config.vm.synced_folder "../data", "/vagrant_data"
|
51
|
-
|
52
|
-
# Disable the default share of the current code directory. Doing this
|
53
|
-
# provides improved isolation between the vagrant box and your host
|
54
|
-
# by making sure your Vagrantfile isn't accessable to the vagrant box.
|
55
|
-
# If you use this you may want to enable additional shared subfolders as
|
56
|
-
# shown above.
|
57
|
-
# config.vm.synced_folder ".", "/vagrant", disabled: true
|
58
|
-
|
59
|
-
# Provider-specific configuration so you can fine-tune various
|
60
|
-
# backing providers for Vagrant. These expose provider-specific options.
|
61
|
-
# Example for VirtualBox:
|
62
|
-
#
|
63
|
-
# config.vm.provider "virtualbox" do |vb|
|
64
|
-
# # Display the VirtualBox GUI when booting the machine
|
65
|
-
# vb.gui = true
|
66
|
-
#
|
67
|
-
# # Customize the amount of memory on the VM:
|
68
|
-
# vb.memory = "1024"
|
69
|
-
# end
|
70
|
-
#
|
71
|
-
# View the documentation for the provider you are using for more
|
72
|
-
# information on available options.
|
73
|
-
|
74
|
-
# Enable provisioning with a shell script. Additional provisioners such as
|
75
|
-
# Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
|
76
|
-
# documentation for more information about their specific syntax and use.
|
77
|
-
config.vm.provision "shell" do |s|
|
78
|
-
ssh_pub_key = File.readlines("#{Dir.home}/.ssh/id_ops.pub").first.strip
|
79
|
-
s.inline = <<-SHELL
|
80
|
-
echo #{ssh_pub_key} >> /home/vagrant/.ssh/authorized_keys
|
81
|
-
echo #{ssh_pub_key} >> /root/.ssh/authorized_keys
|
82
|
-
|
83
|
-
sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
|
84
|
-
sudo systemctl restart sshd
|
85
|
-
|
86
|
-
# change vagrant user to require sudo password
|
87
|
-
sudo sed -i 's/vagrant ALL=(ALL) NOPASSWD: ALL/vagrant ALL=(ALL:ALL) ALL/g' /etc/sudoers.d/vagrant
|
88
|
-
|
89
|
-
# sudo sh -c 'echo root:foo | chpasswd'
|
90
|
-
SHELL
|
91
|
-
end
|
92
|
-
end
|
data/vms/web-ubuntu/Vagrantfile
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# -*- mode: ruby -*-
|
2
|
-
# vi: set ft=ruby :
|
3
|
-
|
4
|
-
Vagrant.configure("2") do |config|
|
5
|
-
# The most common configuration options are documented and commented below.
|
6
|
-
# For a complete reference, please see the online documentation at
|
7
|
-
# https://docs.vagrantup.com.
|
8
|
-
|
9
|
-
# Every Vagrant development environment requires a box. You can search for
|
10
|
-
# boxes at https://vagrantcloud.com/search.
|
11
|
-
config.vm.box = "ubuntu/jammy64"
|
12
|
-
|
13
|
-
# Create a private network, which allows host-only access to the machine
|
14
|
-
# using a specific IP.
|
15
|
-
config.vm.network "private_network", ip: "192.168.56.10"
|
16
|
-
|
17
|
-
# config.ssh.insert_key = false
|
18
|
-
config.ssh.forward_agent = true
|
19
|
-
|
20
|
-
# Enable provisioning with a shell script. Additional provisioners such as
|
21
|
-
# Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
|
22
|
-
# documentation for more information about their specific syntax and use.
|
23
|
-
config.vm.provision "shell" do |s|
|
24
|
-
ssh_pub_key = File.readlines("#{Dir.home}/.ssh/id_ops.pub").first.strip
|
25
|
-
s.inline = <<-SHELL
|
26
|
-
# echo #{ssh_pub_key} >> /home/vagrant/.ssh/authorized_keys
|
27
|
-
# echo #{ssh_pub_key} >> /root/.ssh/authorized_keys
|
28
|
-
|
29
|
-
sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
|
30
|
-
sudo systemctl restart sshd
|
31
|
-
|
32
|
-
# change vagrant user to require sudo password
|
33
|
-
sudo sed -i 's/vagrant ALL=(ALL) NOPASSWD:ALL/vagrant ALL=(ALL:ALL) ALL/g' /etc/sudoers.d/vagrant
|
34
|
-
|
35
|
-
# sudo sh -c 'echo root:foo | chpasswd'
|
36
|
-
SHELL
|
37
|
-
end
|
38
|
-
end
|