Top Level Namespace
Defined Under Namespace
Modules: PrunOps
Instance Method Summary collapse
- #apt_nointeractive ⇒ Object
-
#bastion(host, user:) ⇒ Object
Bastion config.
-
#template(template_name, target_path) ⇒ Object
Common libraries.
Instance Method Details
#apt_nointeractive ⇒ Object
27 28 29 |
# File 'lib/capistrano/prun-ops.rb', line 27 def apt_nointeractive 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y' end |
#bastion(host, user:) ⇒ Object
Bastion config
21 22 23 24 25 |
# File 'lib/capistrano/prun-ops.rb', line 21 def bastion(host, user:) require 'net/ssh/proxy/command' ssh_command = "ssh -W %h:%p -o StrictHostKeyChecking=no #{user}@#{host}" set :ssh_options, proxy: Net::SSH::Proxy::Command.new(ssh_command) end |
#template(template_name, target_path) ⇒ Object
Common libraries
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/capistrano/prun-ops.rb', line 5 def template(template_name, target_path) begin file = File.read("#{File.dirname(__FILE__)}/config/templates/#{template_name}.erb") rescue file = File.read("lib/capistrano/config/templates/#{template_name}.erb") end template = ERB.new file, nil, "%" rendered = template.result(binding) tmp_file = "/tmp/#{SecureRandom.hex}.#{template_name}" upload! StringIO.new(rendered), tmp_file execute "sudo cp #{tmp_file} #{target_path}" execute "rm #{tmp_file}" end |