title: capistrano 3 (ruby) variable scope
body: <p>I have some problems with a capistrano 3 script regarding the scope of variables. I read the variables from hiera like this:</p>
  
  <pre><code>deployment = hiera("deployment")
  deployment.each_pair{|k,v|
     binding.eval("#{k}='#{v}'")
  }
  </code></pre>
  
  <p>My hiera file looks like this:</p>
  
  <pre><code>---
  deployment:
    webserver_group: 'www-data'
    app_config_environment: 'prod'
    application: 'site_manager'
    translator_deploymentLockPath: '/tmp/translation_lockfile.lock'
  </code></pre>
  
  <p>If I try to access the variables in a task I receive an error message like this:</p>
  
  <blockquote>
    <p>Exception while executing on host xxxx: undefined local variable or
    method `translator_deploymentLockPath' for</p>
    
    <h1></h1>
  </blockquote>
  
  <p>Here is how a task looks like:</p>
  
  <pre><code>desc "creates a new lockfile"
  task :create_lock do
     on roles(:app), in: :parallel do
       execute :touch, "#{translator_deploymentLockPath}"
     end
   end
  </code></pre>
  
  <p>If I declare the variables global (like this: <code>binding.eval("$#{k}='#{v}'")</code> ) I can read them in the tasks using <code>$translator_deploymentLockPath</code> instead of <code>#{translator_deploymentLockPath}</code> but this is not a solution for me because I have a lot of code to modify.</p>
  
  <p>What am I missing? How can I read the variables from hiera (using eyaml backend) and declare them so I can use them in my tasks?</p>