In order to use erb templates with capistrano (no rails) I followed the instructions given in https://github.com/faber-lotto/capistrano-template, but when running [bundle exec] cap staging define_usermacros -n --trace
capistrano tells me that the template
method was unknown to SSHKit::Backend::Printer
:
** Invoke staging (first_time)
** Execute staging
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke define_usermacros (first_time)
** Execute define_usermacros
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@10.33.66.12: undefined method `template' for #<SSHKit::Backend::Printer:0x007ff383bd4d80>
/usr/local/var/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.13.1/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute'
/usr/local/var/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.13.1/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
NoMethodError: undefined method `template' for #<SSHKit::Backend::Printer:0x007ff383bd4d80>
config/deploy.rb:42:in `block (2 levels) in <top (required)>'
/usr/local/var/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.13.1/lib/sshkit/backends/abstract.rb:29:in `instance_exec'
/usr/local/var/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.13.1/lib/sshkit/backends/abstract.rb:29:in `run'
/usr/local/var/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.13.1/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => define_usermacros
I tried to up- and downgrade capistrano, airbrussh, sshkit in the bundle but to no avail, things remain broken.
At the moment cap doctor tells me I'm using the following versions:
Environment
Ruby ruby 2.2.5p319 (2016-04-26 revision 54774) [x86_64-darwin15]
Rubygems 2.6.10
Bundler 1.14.3
Command /usr/local/var/rbenv/versions/2.2.5/bin/cap staging doctor
Gems
capistrano 3.7.2 (update available)
airbrussh 1.2.0
rake 12.0.0
sshkit 1.13.1
net-ssh 4.1.0
capistrano-template 0.0.8
And here's the capistrano stuff:
Gemfile:
source "https://rubygems.org"
group :development do
gem "capistrano", "~> 3.7.0"
gem "capistrano-template"
end
Capfile:
require "capistrano/setup"
require "capistrano/deploy"
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
require 'capistrano/capistrano_plugin_template'
config/deploy.rb:
[...]
desc 'Upload user macros as rendered erb-template'
task :define_usermacros do
on roles :all do
template 'resource.cfg', "#{release_path}/resource_file",
0o640,
locals: {
'user1' => 'blah'
}
end
end
... and there is of course an erb template in config/deploy/templates/shared/resource.cfg.erb
.
Any hints on the solution or how to debug the issue welcome!