Skip to content

Instantly share code, notes, and snippets.

@bradland
Last active October 29, 2019 18:53
Show Gist options
  • Save bradland/2c32e298e24afade1205127be3e05ffb to your computer and use it in GitHub Desktop.
Save bradland/2c32e298e24afade1205127be3e05ffb to your computer and use it in GitHub Desktop.
# Server is defined in stage file deploy/staging.rb
# server 'staging.example.com', user: 'staginguser', roles: %i(app db web)
# Expect `say_hello` task to output:
# echo 'hello from "staginguser"'
# What `say_hello` task actually outputs:
# echo 'hello from nil'
task :say_hello do
on roles(:app) do
execute "echo 'hello from #{fetch(:user).inspect}'"
end
end
# By inspecting the output of `Capistrano::Configuration.env`, we can see
# that the server user is in the servers collection under configuration, but
# this variable is not exposed in the variables available through `fetch`.
namespace :dump do
task :env do
pp Capistrano::Configuration.env
end
task :servers do
pp Capistrano::Configuration.env.servers
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment