title: 'Don't know how to build task' error in Capistrano 3
body: <p>I'm trying to learn to use Capistrano 3 by following the DOCS and I've written a simple task to test my understanding.</p>
  
  <p>The <strong>task</strong> is created in the default <code>task</code> dir in <code>lib/capistrano/tasks</code>:</p>
  
  <pre><code>  desc "Check status of web server"
      task :nginx_status do
        on roles(:web) do |host|
          execute 'service nginx status'
        end
      end
  </code></pre>
  
  <p>My <code>config/deploy/staging.rb</code> file contains the following:</p>
  
  <pre><code>set :stage, :staging
  
  role :web, "192.168.0.11"
  role :app,  "192.168.0.11"
  role :db, "192.168.0.11", primary:true
  
  server '192.168.0.11', user: 'vagrant', roles: %w{web app}
  </code></pre>
  
  <p><strong>Capfile</strong></p>
  
  <pre><code># Load DSL and Setup Up Stages
  require 'capistrano/setup'
  
  # Includes default deployment tasks
  require 'capistrano/deploy'
  
  # Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
  Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
  </code></pre>
  
  <p>My <code>deploy.rb</code> contains an app name and a repo url to github.</p>
  
  <p>When I run <code>cap staging nginx_status</code> I get the following error:</p>
  
  <pre><code>** Invoke staging (first_time)
  ** Execute staging
  ** Invoke load:defaults (first_time)
  ** Execute load:defaults
  cap aborted!
  Don't know how to build task 'nginx_status'
  /Users/H/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.1/lib/rake/task_manager.rb:62:in `[]'
  /Users/H/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.1/lib/rake/application.rb:149:in `invoke_task'
  /Users/H/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.1/lib/rake/application.rb:106:in `block (2 levels) in top_level'
  /Users/H/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.1/lib/rake/application.rb:106:in `each'
  /Users/H/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.1/lib/rake/application.rb:106:in `block in top_level'
  /Users/H/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.1/lib/rake/application.rb:115:in `run_with_threads'
  /Users/H/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.1/lib/rake/application.rb:100:in `top_level'
  /Users/H/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.1/lib/rake/application.rb:78:in `block in run'
  /Users/H/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.1/lib/rake/application.rb:176:in `standard_exception_handling'
  /Users/H/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.1/lib/rake/application.rb:75:in `run'
  /Users/H/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/capistrano-3.2.1/lib/capistrano/application.rb:15:in `run'
  /Users/H/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/capistrano-3.2.1/bin/cap:3:in `&lt;top (required)&gt;'
  /Users/H/.rbenv/versions/2.1.1/bin/cap:23:in `load'
  /Users/H/.rbenv/versions/2.1.1/bin/cap:23:in `&lt;main&gt;'
  </code></pre>
  
  <p>I also noticed that if I ran <code>cap -vT</code> the task <code>nginx_status</code> is not in the list(?)</p>
  
  <p>On a side note, <strong>are SSH keys a must</strong> to connect to remote servers?</p>
  
  <h2>UPDATE 1</h2>
  
  <p>I found that if I place my task in <code>config/deploy.rb</code> it works. So the question I now have is how do you run tasks from the task dir? </p>
  
  <h2>UPDATE 2</h2>
  
  <p>So as per the <strong>Capfile</strong> the <code>tasks</code> dir is looked at by the following:</p>
  
  <pre><code># Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
  Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
  </code></pre>
  
  <p>So I changed  the task extension to <code>.rake</code> and it worked. However the documentation says it should be <code>.cap</code></p>
  
  <p><a href="http://capistranorb.com/documentation/getting-started/cold-start/">"We'll dive into those more later, but add those lines to a file in ./lib/capistrano/tasks, call it something like access_check.cap"</a></p>