1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

merge user input and password ask page

This commit is contained in:
Thomas Kriechbaumer 2015-01-22 19:10:42 +00:00
parent a4a3d57cd9
commit 34923b9814
3 changed files with 32 additions and 18 deletions

View file

@ -10,18 +10,17 @@
<li><a href="https://github.com/capistrano/capistrano/blob/master/README.md">The Readme, start here!</a></li>
<li><a href="/documentation/getting-started/installation/">Installation</a></li>
<li><a href="/documentation/getting-started/configuration/">Configuration</a></li>
<li><a href="/documentation/getting-started/structure/">Structure</a></li>
<li><a href="/documentation/getting-started/configuration/">Configuration</a></li>
<li><a href="/documentation/getting-started/user-input/">User Input</a></li>
<li><a href="/documentation/getting-started/preparing-your-application/">Preparing Your Application</a></li>
<li><a href="/documentation/getting-started/flow/">Flow</a></li>
<li><a href="/documentation/getting-started/rollbacks/">Rollbacks</a></li>
<li><a href="/documentation/getting-started/cold-start/">Cold Start</a></li>
<li><a href="/documentation/getting-started/tasks/">Tasks</a></li>
<li><a href="/documentation/getting-started/local-tasks/">Local Tasks</a></li>
<li><a href="/documentation/getting-started/user-input/">User Input</a></li>
<li><a href="/documentation/getting-started/before-after/">Before / After Hooks</a></li>
<li><a href="/documentation/getting-started/authentication-and-authorisation/">Authentication &amp; Authorisation</a></li>
<li><a href="/documentation/getting-started/password-authentication/">Password Authentication</a></li>
<li class="divider"></li>
<h5>Advanced Features</h5>

View file

@ -1,11 +0,0 @@
---
title: Password Authentication
layout: default
---
Password authentication can be done via `set` and `ask` in your deploy environment file (e.g.: config/deploy/production.rb)
{% highlight ruby %}
set :password, ask('Server password', nil)
server 'server.domain.com', user: 'ssh_user_name', port: 22, password: fetch(:password), roles: %w{web app db}
{% endhighlight %}

View file

@ -3,7 +3,13 @@ title: User Input
layout: default
---
User input can be required in a task or during configuration:
{% highlight ruby %}
# used in a configuration
set :database_name, ask('Enter the database name:')
# used in a task
desc "Ask about breakfast"
task :breakfast do
ask(:breakfast, "pancakes")
@ -13,10 +19,30 @@ task :breakfast do
end
{% endhighlight %}
Perfect, who needs telephones.
When using `ask` to get user input, you can pass `echo: false` to prevent the input from being displayed:
When using `ask` to get user input, you can pass `echo: false` to prevent the
input from being displayed. This option should be used to ask the user for
passwords and other sensitive data during a deploy run.
{% highlight ruby %}
ask(:database_password, "default", echo: false)
set :database_password, ask('Enter the database password:', 'default', echo: false)
{% endhighlight %}
If you only pass in a symbol this will be printed as text for the user and the
input will be saved to this variable:
{% highlight ruby %}
ask(:database_encoding, 'UTF-8')
fetch(:database_encoding)
# => contains the user input (or the default)
# once the above line got executed
{% endhighlight %}
You can use `ask` to set a server- or role-specific configuration variable.
{% highlight ruby %}
set :password, ask('Server password', nil)
server 'example.com', user: 'ssh_user_name', port: 22, password: fetch(:password), roles: %w{web app db}
{% endhighlight %}