mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Apply documentation changes
This commit is contained in:
parent
69a3cf8c29
commit
7161de7831
9 changed files with 174 additions and 142 deletions
|
@ -426,7 +426,7 @@ your application.</p>
|
|||
<p>An example of it's usage might be:</p>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-ruby'>h = SSHKit::Host.new 'example.com'
|
||||
<pre data-line=''><code class='language-ruby'>h = SSHKit::Host.new 'example.com'
|
||||
h.properties.roles ||= %i{wep app}</code></pre>
|
||||
</div>
|
||||
|
||||
|
@ -452,7 +452,7 @@ task :precompile do
|
|||
on :sprockets_asset_host, reject: lambda { |h| h.properties.no_release } do
|
||||
within fetch(:latest_release_directory)
|
||||
with rails_env: fetch(:rails_env) do
|
||||
execute :rake, 'assets:precompile'
|
||||
execute :rake, 'assets:precompile'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -505,7 +505,7 @@ arbitrary command, for example:</p>
|
|||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-ruby'># Rakefile (even without Capistrano loaded)
|
||||
require 'sshkit'
|
||||
require 'sshkit'
|
||||
desc "Check the uptime of example.com"
|
||||
task :uptime do |h|
|
||||
execute :uptime
|
||||
|
@ -560,7 +560,7 @@ execute :git, :clone, "........", "......."</code></pre>
|
|||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-ruby'># Capistrano 3.0.x
|
||||
file = '/tmp/somefile'
|
||||
file = '/tmp/somefile'
|
||||
unless test("-e #{file}")
|
||||
execute :touch, file
|
||||
end</code></pre>
|
||||
|
@ -644,7 +644,7 @@ logging infrastructure and streaming IO formatters:</p>
|
|||
<div>
|
||||
<pre data-line=''><code class='language-ruby'># Capistrano 3.0.x
|
||||
on hosts do |host|
|
||||
f = '/some/file'
|
||||
f = '/some/file'
|
||||
if test("[ -d #{f} ]")
|
||||
execute :touch, f
|
||||
else
|
||||
|
@ -1013,7 +1013,7 @@ your application.</p>
|
|||
<p>An example of it's usage might be:</p>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-ruby'>h = SSHKit::Host.new 'example.com'
|
||||
<pre data-line=''><code class='language-ruby'>h = SSHKit::Host.new 'example.com'
|
||||
h.properties.roles ||= %i{wep app}</code></pre>
|
||||
</div>
|
||||
|
||||
|
@ -1039,7 +1039,7 @@ task :precompile do
|
|||
on :sprockets_asset_host, reject: lambda { |h| h.properties.no_release } do
|
||||
within fetch(:latest_release_directory)
|
||||
with rails_env: fetch(:rails_env) do
|
||||
execute :rake, 'assets:precompile'
|
||||
execute :rake, 'assets:precompile'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1092,7 +1092,7 @@ arbitrary command, for example:</p>
|
|||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-ruby'># Rakefile (even without Capistrano loaded)
|
||||
require 'sshkit'
|
||||
require 'sshkit'
|
||||
desc "Check the uptime of example.com"
|
||||
task :uptime do |h|
|
||||
execute :uptime
|
||||
|
@ -1147,7 +1147,7 @@ execute :git, :clone, "........", "......."</code></pre>
|
|||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-ruby'># Capistrano 3.0.x
|
||||
file = '/tmp/somefile'
|
||||
file = '/tmp/somefile'
|
||||
unless test("-e #{file}")
|
||||
execute :touch, file
|
||||
end</code></pre>
|
||||
|
@ -1231,7 +1231,7 @@ logging infrastructure and streaming IO formatters:</p>
|
|||
<div>
|
||||
<pre data-line=''><code class='language-ruby'># Capistrano 3.0.x
|
||||
on hosts do |host|
|
||||
f = '/some/file'
|
||||
f = '/some/file'
|
||||
if test("[ -d #{f} ]")
|
||||
execute :touch, f
|
||||
else
|
||||
|
|
|
@ -166,9 +166,9 @@ what happens:</p>
|
|||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh me@remote
|
||||
me@remote $ [[ $- == *i* ]] && echo 'Interactive' || echo 'Not interactive'
|
||||
me@remote $ [[ $- == *i* ]] && echo 'Interactive' || echo 'Not interactive'
|
||||
Interactive
|
||||
me@remote $ shopt -q login_shell && echo 'Login shell' || echo 'Not login shell'
|
||||
me@remote $ shopt -q login_shell && echo 'Login shell' || echo 'Not login shell'
|
||||
Login shell</code></pre>
|
||||
</div>
|
||||
|
||||
|
@ -176,9 +176,9 @@ Login shell</code></pre>
|
|||
command line without logging in first...</p>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh me@remote "[[ $- == *i* ]] && echo 'Interactive' || echo 'Not interactive'"
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh me@remote "[[ $- == *i* ]] && echo 'Interactive' || echo 'Not interactive'"
|
||||
Interactive
|
||||
me@localhost $ ssh me@remote "shopt -q login_shell && echo 'Login shell' || echo 'Not login shell'"
|
||||
me@localhost $ ssh me@remote "shopt -q login_shell && echo 'Login shell' || echo 'Not login shell'"
|
||||
Not login shell</code></pre>
|
||||
</div>
|
||||
|
||||
|
@ -193,13 +193,13 @@ recipes to test this:</p>
|
|||
<div>
|
||||
<pre data-line=''><code class='language-ruby'># Capistrano 3.0.x
|
||||
task :query_interactive do
|
||||
on 'me@remote' do
|
||||
info capture("[[ $- == *i* ]] && echo 'Interactive' || echo 'Not interactive'")
|
||||
on 'me@remote' do
|
||||
info capture("[[ $- == *i* ]] && echo 'Interactive' || echo 'Not interactive'")
|
||||
end
|
||||
end
|
||||
task :query_login do
|
||||
on 'me@remote' do
|
||||
info capture("shopt -q login_shell && echo 'Login shell' || echo 'Not login shell'")
|
||||
on 'me@remote' do
|
||||
info capture("shopt -q login_shell && echo 'Login shell' || echo 'Not login shell'")
|
||||
end
|
||||
end</code></pre>
|
||||
</div>
|
||||
|
@ -294,9 +294,9 @@ what happens:</p>
|
|||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh me@remote
|
||||
me@remote $ [[ $- == *i* ]] && echo 'Interactive' || echo 'Not interactive'
|
||||
me@remote $ [[ $- == *i* ]] && echo 'Interactive' || echo 'Not interactive'
|
||||
Interactive
|
||||
me@remote $ shopt -q login_shell && echo 'Login shell' || echo 'Not login shell'
|
||||
me@remote $ shopt -q login_shell && echo 'Login shell' || echo 'Not login shell'
|
||||
Login shell</code></pre>
|
||||
</div>
|
||||
|
||||
|
@ -304,9 +304,9 @@ Login shell</code></pre>
|
|||
command line without logging in first...</p>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh me@remote "[[ $- == *i* ]] && echo 'Interactive' || echo 'Not interactive'"
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh me@remote "[[ $- == *i* ]] && echo 'Interactive' || echo 'Not interactive'"
|
||||
Interactive
|
||||
me@localhost $ ssh me@remote "shopt -q login_shell && echo 'Login shell' || echo 'Not login shell'"
|
||||
me@localhost $ ssh me@remote "shopt -q login_shell && echo 'Login shell' || echo 'Not login shell'"
|
||||
Not login shell</code></pre>
|
||||
</div>
|
||||
|
||||
|
@ -321,13 +321,13 @@ recipes to test this:</p>
|
|||
<div>
|
||||
<pre data-line=''><code class='language-ruby'># Capistrano 3.0.x
|
||||
task :query_interactive do
|
||||
on 'me@remote' do
|
||||
info capture("[[ $- == *i* ]] && echo 'Interactive' || echo 'Not interactive'")
|
||||
on 'me@remote' do
|
||||
info capture("[[ $- == *i* ]] && echo 'Interactive' || echo 'Not interactive'")
|
||||
end
|
||||
end
|
||||
task :query_login do
|
||||
on 'me@remote' do
|
||||
info capture("shopt -q login_shell && echo 'Login shell' || echo 'Not login shell'")
|
||||
on 'me@remote' do
|
||||
info capture("shopt -q login_shell && echo 'Login shell' || echo 'Not login shell'")
|
||||
end
|
||||
end</code></pre>
|
||||
</div>
|
||||
|
|
|
@ -142,7 +142,7 @@ to log in.</p>
|
|||
|
||||
<h4 id="toc_1">1.1 SSH keys from workstation to servers</h4>
|
||||
|
||||
<p><strong>Note:</strong> If you are on Windows, all bets are off, I'd love it if someone
|
||||
<p><strong>Note:</strong> If you are on Windows, all bets are off. I'd love it if someone
|
||||
could contribute a Windows guide to this, so we can include it here.</p>
|
||||
|
||||
<p>An SSH key is a mechanism that allows a <em>public</em> half one key to be placed on
|
||||
|
@ -156,7 +156,7 @@ quits or gets fired, you can remove their key from that file, and the rest of
|
|||
you can keep on shipping!</p>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh-keygen -t rsa -C 'me@my_email_address.com'</code></pre>
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh-keygen -t rsa -C 'me@my_email_address.com'</code></pre>
|
||||
</div>
|
||||
|
||||
<p>You'll be prompted for a passphrase, that's fine. Type one and keep it safe.
|
||||
|
@ -215,7 +215,7 @@ none, other none), in the <code>~/.ssh</code> directory which needs the permissi
|
|||
|
||||
<p>If you are on linux there often exists a command
|
||||
<a href="http://linux.die.net/man/1/ssh-copy-id"><code>ssh-copy-id</code></a> which streamlines this
|
||||
process, otherwise the worlflow is something like:</p>
|
||||
process, otherwise the workflow is something like:</p>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh root@remote
|
||||
|
@ -234,13 +234,13 @@ use the same key for each one, but only one key per developer is recommended.
|
|||
<p>If we did all that correctly, we should now be able to do something like this:</p>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh deploy@one-of-my-servers.com 'hostname; uptime'
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh deploy@one-of-my-servers.com 'hostname; uptime'
|
||||
one-of-my-servers.com
|
||||
19:23:32 up 62 days, 44 min, 1 user, load average: 0.00, 0.01, 0.05</code></pre>
|
||||
</div>
|
||||
|
||||
<p>That should happen without having to enter a passphrase for your SSH key, or
|
||||
promoting you for an SSH password (which the deploy user doesn't have anyway).</p>
|
||||
prompting you for an SSH password (which the deploy user doesn't have anyway).</p>
|
||||
|
||||
<p>Verify that this works for all of your servers, and put your private key
|
||||
somewhere safe. If you're working with multiple team members, it often pays to
|
||||
|
@ -275,7 +275,7 @@ repository automatically. The options in order of preference:</p>
|
|||
|
||||
<p>As we've already set up an SSH agent, we can use the <em>agent forwarding</em>
|
||||
feature of SSH to make this key agent available to further <em>hops</em>. In short,
|
||||
we can use <strong>our own ssh key</strong> to authenticate ourselves from the server, to
|
||||
we can use <strong>our own ssh key</strong> to authenticate ourselves from the server to
|
||||
Github.</p>
|
||||
|
||||
<p>Here's how we can check if that works, first get the URL of the repository:</p>
|
||||
|
@ -294,12 +294,12 @@ Tutorials project.</p>
|
|||
<div>
|
||||
<pre data-line=''><code class='language-bash'># List SSH keys that are loaded into the agent
|
||||
me@localhost $ ssh-add -l
|
||||
# Make sure they key is loaded if 'ssh-add -l' didn't show anything
|
||||
# Make sure they key is loaded if 'ssh-add -l' didn't show anything
|
||||
me@localhost $ ssh-add
|
||||
me@localhost $ ssh -A deploy@one-of-my-servers.com 'git ls-remote git@github.com:capistrano/rails3-bootstrap-devise-cancan.git</code></pre>
|
||||
me@localhost $ ssh -A deploy@one-of-my-servers.com 'git ls-remote git@github.com:capistrano/rails3-bootstrap-devise-cancan.git</code></pre>
|
||||
</div>
|
||||
|
||||
<p>We first check that the agent has the keys loaded, if not we simply load it,
|
||||
<p>We first check that the agent has the keys loaded. If not we simply load it
|
||||
and enter the passphrase when prompted.</p>
|
||||
|
||||
<p>Finally we use <code>ls-remote</code> from Git to list the remote objects, this is the
|
||||
|
@ -314,7 +314,7 @@ it both ways just to know how your system treats agent forwarding by default.</p
|
|||
specified on a per-host basis in a configuration file.
|
||||
|
||||
Agent forwarding should be enabled with caution. Users with the ability to
|
||||
bypass file permissions on the remote host (for the agent's UNIX-domain
|
||||
bypass file permissions on the remote host (for the agent's UNIX-domain
|
||||
socket) can access the local agent through the forwarded connection. An
|
||||
attacker cannot obtain key material from the agent, however they can perform
|
||||
operations on the keys that enable them to authenticate using the identities
|
||||
|
@ -331,7 +331,7 @@ servers!</p>
|
|||
|
||||
<p>In the case of HTTP authentication <strong>be sure to use HTTPS</strong>, otherwise your
|
||||
password will be sent in cleartext over the network, depending what your hosts
|
||||
network infratructure looks like that might be <em>very</em> bad news.</p>
|
||||
network infrastructure looks like that might be <em>very</em> bad news.</p>
|
||||
|
||||
<p>Typically when we try and list our remote objects, using the https method from
|
||||
Github, we'll be prompted for a username and password:</p>
|
||||
|
@ -340,8 +340,8 @@ Github, we'll be prompted for a username and password:</p>
|
|||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ git ls-remote https://github.com/capistrano/rails3-bootstrap-devise-cancan.git
|
||||
Username for 'https://github.com': myownusername
|
||||
Password for 'https://capistrano@github.com':</code></pre>
|
||||
Username for 'https://github.com': myownusername
|
||||
Password for 'https://capistrano@github.com':</code></pre>
|
||||
</div>
|
||||
|
||||
<p>This challenge response prompt doesn't work well for automating things, so
|
||||
|
@ -415,11 +415,11 @@ documentation, but sufficed to say something like:</p>
|
|||
/etc/init.d/mysql _________</code> and the same for the <code>apache2</code> control script.</p>
|
||||
|
||||
<p><strong>Granting passwordless sudo should not be done lightly.</strong> It can be dangerous.
|
||||
For example if an unprivilidged user can <em>edit</em> the script that they can run
|
||||
For example if an unprivileged user can <em>edit</em> the script that they can run
|
||||
as root, they can easily edit it to do anything they want that is evil. Use
|
||||
this carefully, and ideally architect your systems so that non-privlidged
|
||||
this carefully, and ideally architect your systems so that non-privileged
|
||||
users can restart services, or that services restart <em>themselves</em> when they
|
||||
notice change.</p>
|
||||
notice a change.</p>
|
||||
|
||||
<p>To configure this heirarchy, ignoring for the moment the passwordless <code>sudo</code>
|
||||
access that you may or may not need depending how well your servers are setup:</p>
|
||||
|
@ -427,7 +427,7 @@ access that you may or may not need depending how well your servers are setup:</
|
|||
<div>
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh root@remote
|
||||
# Capistrano will use /var/www/....... where ... is the value set in
|
||||
# :application, you can override this by setting the ':deploy_to' variable
|
||||
# :application, you can override this by setting the ':deploy_to' variable
|
||||
root@remote $ deploy_to=/var/www/rails3-bootstrap-devise-cancan-demo
|
||||
root@remote $ mkdir ${deploy_to}
|
||||
root@remote $ chown deploy:deploy ${deploy_to}
|
||||
|
@ -502,7 +502,7 @@ to log in.</p>
|
|||
|
||||
<h4 id="toc_1">1.1 SSH keys from workstation to servers</h4>
|
||||
|
||||
<p><strong>Note:</strong> If you are on Windows, all bets are off, I'd love it if someone
|
||||
<p><strong>Note:</strong> If you are on Windows, all bets are off. I'd love it if someone
|
||||
could contribute a Windows guide to this, so we can include it here.</p>
|
||||
|
||||
<p>An SSH key is a mechanism that allows a <em>public</em> half one key to be placed on
|
||||
|
@ -516,7 +516,7 @@ quits or gets fired, you can remove their key from that file, and the rest of
|
|||
you can keep on shipping!</p>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh-keygen -t rsa -C 'me@my_email_address.com'</code></pre>
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh-keygen -t rsa -C 'me@my_email_address.com'</code></pre>
|
||||
</div>
|
||||
|
||||
<p>You'll be prompted for a passphrase, that's fine. Type one and keep it safe.
|
||||
|
@ -575,7 +575,7 @@ none, other none), in the <code>~/.ssh</code> directory which needs the permissi
|
|||
|
||||
<p>If you are on linux there often exists a command
|
||||
<a href="http://linux.die.net/man/1/ssh-copy-id"><code>ssh-copy-id</code></a> which streamlines this
|
||||
process, otherwise the worlflow is something like:</p>
|
||||
process, otherwise the workflow is something like:</p>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh root@remote
|
||||
|
@ -594,13 +594,13 @@ use the same key for each one, but only one key per developer is recommended.
|
|||
<p>If we did all that correctly, we should now be able to do something like this:</p>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh deploy@one-of-my-servers.com 'hostname; uptime'
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh deploy@one-of-my-servers.com 'hostname; uptime'
|
||||
one-of-my-servers.com
|
||||
19:23:32 up 62 days, 44 min, 1 user, load average: 0.00, 0.01, 0.05</code></pre>
|
||||
</div>
|
||||
|
||||
<p>That should happen without having to enter a passphrase for your SSH key, or
|
||||
promoting you for an SSH password (which the deploy user doesn't have anyway).</p>
|
||||
prompting you for an SSH password (which the deploy user doesn't have anyway).</p>
|
||||
|
||||
<p>Verify that this works for all of your servers, and put your private key
|
||||
somewhere safe. If you're working with multiple team members, it often pays to
|
||||
|
@ -635,7 +635,7 @@ repository automatically. The options in order of preference:</p>
|
|||
|
||||
<p>As we've already set up an SSH agent, we can use the <em>agent forwarding</em>
|
||||
feature of SSH to make this key agent available to further <em>hops</em>. In short,
|
||||
we can use <strong>our own ssh key</strong> to authenticate ourselves from the server, to
|
||||
we can use <strong>our own ssh key</strong> to authenticate ourselves from the server to
|
||||
Github.</p>
|
||||
|
||||
<p>Here's how we can check if that works, first get the URL of the repository:</p>
|
||||
|
@ -654,12 +654,12 @@ Tutorials project.</p>
|
|||
<div>
|
||||
<pre data-line=''><code class='language-bash'># List SSH keys that are loaded into the agent
|
||||
me@localhost $ ssh-add -l
|
||||
# Make sure they key is loaded if 'ssh-add -l' didn't show anything
|
||||
# Make sure they key is loaded if 'ssh-add -l' didn't show anything
|
||||
me@localhost $ ssh-add
|
||||
me@localhost $ ssh -A deploy@one-of-my-servers.com 'git ls-remote git@github.com:capistrano/rails3-bootstrap-devise-cancan.git</code></pre>
|
||||
me@localhost $ ssh -A deploy@one-of-my-servers.com 'git ls-remote git@github.com:capistrano/rails3-bootstrap-devise-cancan.git</code></pre>
|
||||
</div>
|
||||
|
||||
<p>We first check that the agent has the keys loaded, if not we simply load it,
|
||||
<p>We first check that the agent has the keys loaded. If not we simply load it
|
||||
and enter the passphrase when prompted.</p>
|
||||
|
||||
<p>Finally we use <code>ls-remote</code> from Git to list the remote objects, this is the
|
||||
|
@ -674,7 +674,7 @@ it both ways just to know how your system treats agent forwarding by default.</p
|
|||
specified on a per-host basis in a configuration file.
|
||||
|
||||
Agent forwarding should be enabled with caution. Users with the ability to
|
||||
bypass file permissions on the remote host (for the agent's UNIX-domain
|
||||
bypass file permissions on the remote host (for the agent's UNIX-domain
|
||||
socket) can access the local agent through the forwarded connection. An
|
||||
attacker cannot obtain key material from the agent, however they can perform
|
||||
operations on the keys that enable them to authenticate using the identities
|
||||
|
@ -691,7 +691,7 @@ servers!</p>
|
|||
|
||||
<p>In the case of HTTP authentication <strong>be sure to use HTTPS</strong>, otherwise your
|
||||
password will be sent in cleartext over the network, depending what your hosts
|
||||
network infratructure looks like that might be <em>very</em> bad news.</p>
|
||||
network infrastructure looks like that might be <em>very</em> bad news.</p>
|
||||
|
||||
<p>Typically when we try and list our remote objects, using the https method from
|
||||
Github, we'll be prompted for a username and password:</p>
|
||||
|
@ -700,8 +700,8 @@ Github, we'll be prompted for a username and password:</p>
|
|||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ git ls-remote https://github.com/capistrano/rails3-bootstrap-devise-cancan.git
|
||||
Username for 'https://github.com': myownusername
|
||||
Password for 'https://capistrano@github.com':</code></pre>
|
||||
Username for 'https://github.com': myownusername
|
||||
Password for 'https://capistrano@github.com':</code></pre>
|
||||
</div>
|
||||
|
||||
<p>This challenge response prompt doesn't work well for automating things, so
|
||||
|
@ -775,11 +775,11 @@ documentation, but sufficed to say something like:</p>
|
|||
/etc/init.d/mysql _________</code> and the same for the <code>apache2</code> control script.</p>
|
||||
|
||||
<p><strong>Granting passwordless sudo should not be done lightly.</strong> It can be dangerous.
|
||||
For example if an unprivilidged user can <em>edit</em> the script that they can run
|
||||
For example if an unprivileged user can <em>edit</em> the script that they can run
|
||||
as root, they can easily edit it to do anything they want that is evil. Use
|
||||
this carefully, and ideally architect your systems so that non-privlidged
|
||||
this carefully, and ideally architect your systems so that non-privileged
|
||||
users can restart services, or that services restart <em>themselves</em> when they
|
||||
notice change.</p>
|
||||
notice a change.</p>
|
||||
|
||||
<p>To configure this heirarchy, ignoring for the moment the passwordless <code>sudo</code>
|
||||
access that you may or may not need depending how well your servers are setup:</p>
|
||||
|
@ -787,7 +787,7 @@ access that you may or may not need depending how well your servers are setup:</
|
|||
<div>
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh root@remote
|
||||
# Capistrano will use /var/www/....... where ... is the value set in
|
||||
# :application, you can override this by setting the ':deploy_to' variable
|
||||
# :application, you can override this by setting the ':deploy_to' variable
|
||||
root@remote $ deploy_to=/var/www/rails3-bootstrap-devise-cancan-demo
|
||||
root@remote $ mkdir ${deploy_to}
|
||||
root@remote $ chown deploy:deploy ${deploy_to}
|
||||
|
|
|
@ -123,7 +123,7 @@ technologies.</p>
|
|||
<h3 id="toc_0">1. Checking the directory structure on the remote machine:</h3>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh deploy@remote 'ls -lR /var/www/my-application'
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh deploy@remote 'ls -lR /var/www/my-application'
|
||||
my-application:
|
||||
total 8
|
||||
drwxrwsr-x 2 deploy deploy 4096 Jun 24 20:55 releases
|
||||
|
@ -190,7 +190,7 @@ INFO /var/www/my-application is writable on myserver.com</code></pre>
|
|||
</div>
|
||||
|
||||
<p>If we've done something wrong, that won't happen and we'll know that we need
|
||||
to jump on the mailing list to get help, or into IRC or ask a friend.</p>
|
||||
to jump on the mailing list to get help, into IRC or ask a friend.</p>
|
||||
|
||||
<p>Depending how you have set your Git authentication credentials up, checking
|
||||
Git can be a bit complicated, so we've shipped a task in the core library that
|
||||
|
@ -225,7 +225,7 @@ DEBUG [118bd3e4] Command: /usr/bin/env chmod +x /tmp/git-ssh.sh
|
|||
INFO [118bd3e4] Finished in 0.049 seconds command successful.
|
||||
INFO [a996463f] Running /usr/bin/env git ls-remote git@github.com:capistrano/rails3-bootstrap-devise-cancan.git on harrow
|
||||
DEBUG [a996463f] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/git-ssh.sh /usr/bin/env git ls-remote git@github.com:capistrano/rails3-bootstrap-devise-cancan.git )
|
||||
DEBUG [a996463f] Warning: Permanently added 'github.com,204.232.175.90' (RSA) to the list of known hosts.
|
||||
DEBUG [a996463f] Warning: Permanently added 'github.com,204.232.175.90' (RSA) to the list of known hosts.
|
||||
DEBUG [a996463f] Permission denied (publickey).
|
||||
DEBUG [a996463f] fatal: The remote end hung up unexpectedly
|
||||
cap aborted!
|
||||
|
@ -245,9 +245,9 @@ colour support, you may well see something like this:</p>
|
|||
|
||||
<ol>
|
||||
<li>We asked Capistrano to run the command <code>git:check</code>.</li>
|
||||
<li>Capistrano recognised that in order to fulfil this request, it had first
|
||||
to execute the task <code>git:wrapper</code>, a <em>prerequisite</em>.</li>
|
||||
<li>Capistrano exexuted the <code>git:wrapper</code> task, and uploaded the
|
||||
<li>Capistrano recognised that in order to fulfil this request, it had to first
|
||||
execute the task <code>git:wrapper</code>, a <em>prerequisite</em>.</li>
|
||||
<li>Capistrano executed the <code>git:wrapper</code> task, and uploaded the
|
||||
<code>/tmp/git-ssh.sh</code> file, and made it executable. This satisfies the
|
||||
<code>git:wrapper</code> task defined
|
||||
<a href="https://github.com/capistrano/capistrano/blob/v3/lib/capistrano/tasks/git.rake#L9">here</a>
|
||||
|
@ -256,7 +256,7 @@ in the source code. This script is actually processed as a template.</li>
|
|||
prompting us for input, so we ask git to <code>ls-remote</code> on the repository we
|
||||
defined. As this exited with an <a href="https://en.wikipedia.org/wiki/Exit_status">unclean
|
||||
status</a>, Capistrano aborted, and
|
||||
printed out the erorr messages for us to try and figure out what broke.</li>
|
||||
printed out the error messages for us to try and figure out what broke.</li>
|
||||
</ol>
|
||||
|
||||
<p>In this case, we'll be using SSH agent forwarding, we can check if that's
|
||||
|
@ -291,7 +291,7 @@ DEBUG [f1269276] Finished in 0.453 seconds command successful.
|
|||
<p>If you don't feel like writing a Capistrano task, one could simply do:</p>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh -A example.com 'env | grep SSH_AUTH_SOCK'
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh -A example.com 'env | grep SSH_AUTH_SOCK'
|
||||
SSH_AUTH_SOCK=/tmp/ssh-Tb6X8V53tm/agent.2934</code></pre>
|
||||
</div>
|
||||
|
||||
|
@ -343,7 +343,7 @@ technologies.</p>
|
|||
<h3 id="toc_0">1. Checking the directory structure on the remote machine:</h3>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh deploy@remote 'ls -lR /var/www/my-application'
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh deploy@remote 'ls -lR /var/www/my-application'
|
||||
my-application:
|
||||
total 8
|
||||
drwxrwsr-x 2 deploy deploy 4096 Jun 24 20:55 releases
|
||||
|
@ -410,7 +410,7 @@ INFO /var/www/my-application is writable on myserver.com</code></pre>
|
|||
</div>
|
||||
|
||||
<p>If we've done something wrong, that won't happen and we'll know that we need
|
||||
to jump on the mailing list to get help, or into IRC or ask a friend.</p>
|
||||
to jump on the mailing list to get help, into IRC or ask a friend.</p>
|
||||
|
||||
<p>Depending how you have set your Git authentication credentials up, checking
|
||||
Git can be a bit complicated, so we've shipped a task in the core library that
|
||||
|
@ -445,7 +445,7 @@ DEBUG [118bd3e4] Command: /usr/bin/env chmod +x /tmp/git-ssh.sh
|
|||
INFO [118bd3e4] Finished in 0.049 seconds command successful.
|
||||
INFO [a996463f] Running /usr/bin/env git ls-remote git@github.com:capistrano/rails3-bootstrap-devise-cancan.git on harrow
|
||||
DEBUG [a996463f] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/git-ssh.sh /usr/bin/env git ls-remote git@github.com:capistrano/rails3-bootstrap-devise-cancan.git )
|
||||
DEBUG [a996463f] Warning: Permanently added 'github.com,204.232.175.90' (RSA) to the list of known hosts.
|
||||
DEBUG [a996463f] Warning: Permanently added 'github.com,204.232.175.90' (RSA) to the list of known hosts.
|
||||
DEBUG [a996463f] Permission denied (publickey).
|
||||
DEBUG [a996463f] fatal: The remote end hung up unexpectedly
|
||||
cap aborted!
|
||||
|
@ -465,9 +465,9 @@ colour support, you may well see something like this:</p>
|
|||
|
||||
<ol>
|
||||
<li>We asked Capistrano to run the command <code>git:check</code>.</li>
|
||||
<li>Capistrano recognised that in order to fulfil this request, it had first
|
||||
to execute the task <code>git:wrapper</code>, a <em>prerequisite</em>.</li>
|
||||
<li>Capistrano exexuted the <code>git:wrapper</code> task, and uploaded the
|
||||
<li>Capistrano recognised that in order to fulfil this request, it had to first
|
||||
execute the task <code>git:wrapper</code>, a <em>prerequisite</em>.</li>
|
||||
<li>Capistrano executed the <code>git:wrapper</code> task, and uploaded the
|
||||
<code>/tmp/git-ssh.sh</code> file, and made it executable. This satisfies the
|
||||
<code>git:wrapper</code> task defined
|
||||
<a href="https://github.com/capistrano/capistrano/blob/v3/lib/capistrano/tasks/git.rake#L9">here</a>
|
||||
|
@ -476,7 +476,7 @@ in the source code. This script is actually processed as a template.</li>
|
|||
prompting us for input, so we ask git to <code>ls-remote</code> on the repository we
|
||||
defined. As this exited with an <a href="https://en.wikipedia.org/wiki/Exit_status">unclean
|
||||
status</a>, Capistrano aborted, and
|
||||
printed out the erorr messages for us to try and figure out what broke.</li>
|
||||
printed out the error messages for us to try and figure out what broke.</li>
|
||||
</ol>
|
||||
|
||||
<p>In this case, we'll be using SSH agent forwarding, we can check if that's
|
||||
|
@ -511,7 +511,7 @@ DEBUG [f1269276] Finished in 0.453 seconds command successful.
|
|||
<p>If you don't feel like writing a Capistrano task, one could simply do:</p>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh -A example.com 'env | grep SSH_AUTH_SOCK'
|
||||
<pre data-line=''><code class='language-bash'>me@localhost $ ssh -A example.com 'env | grep SSH_AUTH_SOCK'
|
||||
SSH_AUTH_SOCK=/tmp/ssh-Tb6X8V53tm/agent.2934</code></pre>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -151,11 +151,11 @@ cleanup process is usually different from deploy flow.</p>
|
|||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-ruby'># Capfile
|
||||
require 'capistrano/setup'
|
||||
require 'capistrano/deploy'
|
||||
require 'capistrano/bundler'
|
||||
require 'capistrano/rails/migrations'
|
||||
require 'capistrano/rails/assets'</code></pre>
|
||||
require 'capistrano/setup'
|
||||
require 'capistrano/deploy'
|
||||
require 'capistrano/bundler'
|
||||
require 'capistrano/rails/migrations'
|
||||
require 'capistrano/rails/assets'</code></pre>
|
||||
</div>
|
||||
|
||||
<p>When you run <code>cap production deploy</code>, it runs these tasks:</p>
|
||||
|
@ -269,11 +269,11 @@ cleanup process is usually different from deploy flow.</p>
|
|||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-ruby'># Capfile
|
||||
require 'capistrano/setup'
|
||||
require 'capistrano/deploy'
|
||||
require 'capistrano/bundler'
|
||||
require 'capistrano/rails/migrations'
|
||||
require 'capistrano/rails/assets'</code></pre>
|
||||
require 'capistrano/setup'
|
||||
require 'capistrano/deploy'
|
||||
require 'capistrano/bundler'
|
||||
require 'capistrano/rails/migrations'
|
||||
require 'capistrano/rails/assets'</code></pre>
|
||||
</div>
|
||||
|
||||
<p>When you run <code>cap production deploy</code>, it runs these tasks:</p>
|
||||
|
|
|
@ -160,11 +160,11 @@ gems</a>)</p>
|
|||
|
||||
<h3 id="toc_2">Usage in a Rails project</h3>
|
||||
|
||||
<p>Add the following lines to the Gemfile, to the group <code>:development</code> ideally.</p>
|
||||
<p>Add the following lines to the Gemfile to the <code>:development</code> group ideally.</p>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-ruby'>group :development do
|
||||
gem 'capistrano-rails', '~> 0.0.7'
|
||||
gem 'capistrano-rails', '~> 0.0.7'
|
||||
end</code></pre>
|
||||
</div>
|
||||
|
||||
|
@ -190,9 +190,9 @@ part, to get the best, and most sensible results, simply <code>require</code> th
|
|||
files:</p>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-ruby'>require 'capistrano/rails/assets'
|
||||
require 'capistrano/rails/gem-bundler'
|
||||
require 'capistrano/rails/database-migrations'</code></pre>
|
||||
<pre data-line=''><code class='language-ruby'>require 'capistrano/rails/assets'
|
||||
require 'capistrano/rails/gem-bundler'
|
||||
require 'capistrano/rails/database-migrations'</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="alert alert-info">
|
||||
|
@ -203,7 +203,7 @@ by mistake, then you can lock your Gem version for Capistrano at something
|
|||
like:
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-ruby'>gem 'capistrano', '~> 2.15' # Or whatever patch release you are using</code></pre>
|
||||
<pre data-line=''><code class='language-ruby'>gem 'capistrano', '~> 2.15' # Or whatever patch release you are using</code></pre>
|
||||
</div>
|
||||
|
||||
<p>This is the <a href="http://docs.rubygems.org/read/chapter/16#page74">pessimistic operator</a> which
|
||||
|
@ -278,11 +278,11 @@ gems</a>)</p>
|
|||
|
||||
<h3 id="toc_2">Usage in a Rails project</h3>
|
||||
|
||||
<p>Add the following lines to the Gemfile, to the group <code>:development</code> ideally.</p>
|
||||
<p>Add the following lines to the Gemfile to the <code>:development</code> group ideally.</p>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-ruby'>group :development do
|
||||
gem 'capistrano-rails', '~> 0.0.7'
|
||||
gem 'capistrano-rails', '~> 0.0.7'
|
||||
end</code></pre>
|
||||
</div>
|
||||
|
||||
|
@ -308,9 +308,9 @@ part, to get the best, and most sensible results, simply <code>require</code> th
|
|||
files:</p>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-ruby'>require 'capistrano/rails/assets'
|
||||
require 'capistrano/rails/gem-bundler'
|
||||
require 'capistrano/rails/database-migrations'</code></pre>
|
||||
<pre data-line=''><code class='language-ruby'>require 'capistrano/rails/assets'
|
||||
require 'capistrano/rails/gem-bundler'
|
||||
require 'capistrano/rails/database-migrations'</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="alert alert-info">
|
||||
|
@ -321,7 +321,7 @@ by mistake, then you can lock your Gem version for Capistrano at something
|
|||
like:
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-ruby'>gem 'capistrano', '~> 2.15' # Or whatever patch release you are using</code></pre>
|
||||
<pre data-line=''><code class='language-ruby'>gem 'capistrano', '~> 2.15' # Or whatever patch release you are using</code></pre>
|
||||
</div>
|
||||
|
||||
<p>This is the <a href="http://docs.rubygems.org/read/chapter/16#page74">pessimistic operator</a> which
|
||||
|
|
|
@ -112,13 +112,13 @@
|
|||
|
||||
<h3 id="toc_0">1. Commit your application to some externally available source control hosting provider.</h3>
|
||||
|
||||
<p>If you are not doing already, you should host your code somewhere with a
|
||||
provuder such as Github, BitBucket, Codeplane, or repositoryhosting.com.</p>
|
||||
<p>If you are not doing so already, you should host your code somewhere with a
|
||||
provider such as Github, BitBucket, Codeplane, or repositoryhosting.com.</p>
|
||||
|
||||
<div class="alert-box radius">
|
||||
At present Capistrano v3.0.x only supports Git. It's just a matter of time
|
||||
until we support Subversion, Mecurial, Darcs and friends again. Please
|
||||
contribute if you know these tools well, we don't and don't want to force our
|
||||
contribute if you know these tools well, we do not and don't want to force our
|
||||
miscomprehended notions upon anyone.
|
||||
</div>
|
||||
|
||||
|
@ -206,9 +206,9 @@ role :db, %w{example.com}
|
|||
# ======================
|
||||
# This can be used to drop a more detailed server
|
||||
# definition into the server list. The second argument
|
||||
# something that quacks like a hash can be used to set
|
||||
# extended properties on the server.
|
||||
server 'example.com', roles: %w{web app}, my_property: :my_value
|
||||
# is something that quacks like a hash and can be used
|
||||
# to set extended properties on the server.
|
||||
server 'example.com', roles: %w{web app}, my_property: :my_value
|
||||
|
||||
# set :rails_env, :staging</code></pre>
|
||||
</div>
|
||||
|
@ -233,8 +233,8 @@ server line after the comment:</p>
|
|||
<div>
|
||||
<pre data-line=''><code class='language-ruby'>role :all, %w{hello@world.com example.com:1234}
|
||||
# ...is the same as doing...
|
||||
server 'world.com' roles: [:web], user: 'hello'
|
||||
server 'example.com', roles: [:web], port: 1234</code></pre>
|
||||
server 'world.com' roles: [:web], user: 'hello'
|
||||
server 'example.com', roles: [:web], port: 1234</code></pre>
|
||||
</div>
|
||||
|
||||
<h3 id="toc_4">5. Set the shared information in <code>deploy.rb</code>.</h3>
|
||||
|
@ -248,8 +248,8 @@ self-documenting, commented-out configuration options, feel free to play with
|
|||
them a little:</p>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-ruby'>set :application, 'my app name'
|
||||
set :repo_url, 'git@example.com:me/my_repo.git'
|
||||
<pre data-line=''><code class='language-ruby'>set :application, 'my app name'
|
||||
set :repo_url, 'git@example.com:me/my_repo.git'
|
||||
ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }</code></pre>
|
||||
</div>
|
||||
|
||||
|
@ -266,14 +266,14 @@ Tutorials</a> site; there we'll find maintained a
|
|||
handful of typical Rails apps with typical dependencies.</p>
|
||||
|
||||
<p>The Rails application they host, which uses Devise (for authentication) and
|
||||
Cancan (for authorization) along side Twitter Bootstrap for assets has been
|
||||
Cancan (for authorisation) along side Twitter Bootstrap for assets has been
|
||||
forked to the Capistrano repository, but you can find the (unchanged) original
|
||||
<a href="https://github.com/RailsApps/rails3-bootstrap-devise-cancan">here</a>.</p>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-ruby'>set :application, 'rails3-bootstrap-devise-cancan-demo'
|
||||
set :repo_url, 'https://github.com/capistrano/rails3-bootstrap-devise-cancan'
|
||||
set :branch, 'master'</code></pre>
|
||||
<pre data-line=''><code class='language-ruby'>set :application, 'rails3-bootstrap-devise-cancan-demo'
|
||||
set :repo_url, 'https://github.com/capistrano/rails3-bootstrap-devise-cancan'
|
||||
set :branch, 'master'</code></pre>
|
||||
</div>
|
||||
|
||||
<p>I've simplified the <code>:branch</code> variable to simply be a <code>set</code> variable, not a
|
||||
|
@ -304,13 +304,13 @@ to authorise Capistrano on our servers yet.</p>
|
|||
|
||||
<h3 id="toc_0">1. Commit your application to some externally available source control hosting provider.</h3>
|
||||
|
||||
<p>If you are not doing already, you should host your code somewhere with a
|
||||
provuder such as Github, BitBucket, Codeplane, or repositoryhosting.com.</p>
|
||||
<p>If you are not doing so already, you should host your code somewhere with a
|
||||
provider such as Github, BitBucket, Codeplane, or repositoryhosting.com.</p>
|
||||
|
||||
<div class="alert-box radius">
|
||||
At present Capistrano v3.0.x only supports Git. It's just a matter of time
|
||||
until we support Subversion, Mecurial, Darcs and friends again. Please
|
||||
contribute if you know these tools well, we don't and don't want to force our
|
||||
contribute if you know these tools well, we do not and don't want to force our
|
||||
miscomprehended notions upon anyone.
|
||||
</div>
|
||||
|
||||
|
@ -398,9 +398,9 @@ role :db, %w{example.com}
|
|||
# ======================
|
||||
# This can be used to drop a more detailed server
|
||||
# definition into the server list. The second argument
|
||||
# something that quacks like a hash can be used to set
|
||||
# extended properties on the server.
|
||||
server 'example.com', roles: %w{web app}, my_property: :my_value
|
||||
# is something that quacks like a hash and can be used
|
||||
# to set extended properties on the server.
|
||||
server 'example.com', roles: %w{web app}, my_property: :my_value
|
||||
|
||||
# set :rails_env, :staging</code></pre>
|
||||
</div>
|
||||
|
@ -425,8 +425,8 @@ server line after the comment:</p>
|
|||
<div>
|
||||
<pre data-line=''><code class='language-ruby'>role :all, %w{hello@world.com example.com:1234}
|
||||
# ...is the same as doing...
|
||||
server 'world.com' roles: [:web], user: 'hello'
|
||||
server 'example.com', roles: [:web], port: 1234</code></pre>
|
||||
server 'world.com' roles: [:web], user: 'hello'
|
||||
server 'example.com', roles: [:web], port: 1234</code></pre>
|
||||
</div>
|
||||
|
||||
<h3 id="toc_4">5. Set the shared information in <code>deploy.rb</code>.</h3>
|
||||
|
@ -440,8 +440,8 @@ self-documenting, commented-out configuration options, feel free to play with
|
|||
them a little:</p>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-ruby'>set :application, 'my app name'
|
||||
set :repo_url, 'git@example.com:me/my_repo.git'
|
||||
<pre data-line=''><code class='language-ruby'>set :application, 'my app name'
|
||||
set :repo_url, 'git@example.com:me/my_repo.git'
|
||||
ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }</code></pre>
|
||||
</div>
|
||||
|
||||
|
@ -458,14 +458,14 @@ Tutorials</a> site; there we'll find maintained a
|
|||
handful of typical Rails apps with typical dependencies.</p>
|
||||
|
||||
<p>The Rails application they host, which uses Devise (for authentication) and
|
||||
Cancan (for authorization) along side Twitter Bootstrap for assets has been
|
||||
Cancan (for authorisation) along side Twitter Bootstrap for assets has been
|
||||
forked to the Capistrano repository, but you can find the (unchanged) original
|
||||
<a href="https://github.com/RailsApps/rails3-bootstrap-devise-cancan">here</a>.</p>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-ruby'>set :application, 'rails3-bootstrap-devise-cancan-demo'
|
||||
set :repo_url, 'https://github.com/capistrano/rails3-bootstrap-devise-cancan'
|
||||
set :branch, 'master'</code></pre>
|
||||
<pre data-line=''><code class='language-ruby'>set :application, 'rails3-bootstrap-devise-cancan-demo'
|
||||
set :repo_url, 'https://github.com/capistrano/rails3-bootstrap-devise-cancan'
|
||||
set :branch, 'master'</code></pre>
|
||||
</div>
|
||||
|
||||
<p>I've simplified the <code>:branch</code> variable to simply be a <code>set</code> variable, not a
|
||||
|
|
|
@ -213,7 +213,7 @@ task :ditty do
|
|||
# we can reflect on the `host` object passed to the block
|
||||
# and use the `info` logger method to benefit from the
|
||||
# output formatter that is selected.
|
||||
uptime = capture('uptime')
|
||||
uptime = capture('uptime')
|
||||
if host.roles.include?(:web)
|
||||
info "Your webserver #{host} has uptime: #{uptime}"
|
||||
end
|
||||
|
@ -224,8 +224,8 @@ task :ditty do
|
|||
# and move the process into a directoy, executing arbitrary tasks
|
||||
# such as letting Rails do some heavy lifting.
|
||||
with({:rails_env => :production}) do
|
||||
within('/var/www/my/rails/app') do
|
||||
execute :rails, :runner, 'MyModel.something'
|
||||
within('/var/www/my/rails/app') do
|
||||
execute :rails, :runner, 'MyModel.something'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -234,8 +234,8 @@ task :ditty do
|
|||
# We can even switch users, provided we have support on the remote
|
||||
# server for switching to that user without being prompted for a
|
||||
# passphrase.
|
||||
as 'postgres' do
|
||||
widgets = capture "echo 'SELECT * FROM widgets;' | psql my_database"
|
||||
as 'postgres' do
|
||||
widgets = capture "echo 'SELECT * FROM widgets;' | psql my_database"
|
||||
if widgets.to_i < 50
|
||||
warn "There are fewer than 50 widgets in the database on #{host}!"
|
||||
end
|
||||
|
@ -245,7 +245,7 @@ task :ditty do
|
|||
on roles(:all) do
|
||||
# We can even use `test` the way the Unix gods intended
|
||||
if test("[ -d /some/directory ]")
|
||||
info "Phew, it's ok, the directory exists!"
|
||||
info "Phew, it's ok, the directory exists!"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -268,7 +268,7 @@ end</code></pre>
|
|||
<p>Capistrano can be used to:</p>
|
||||
|
||||
<ul>
|
||||
<li>Reliably deploy web application to any number of machines simultaniously,
|
||||
<li>Reliably deploy web application to any number of machines simultaneously,
|
||||
in sequence or as a rolling set</li>
|
||||
<li>To automate audits of any number of machines (checking login logs,
|
||||
enumerating uptimes, and/or applying security patches)</li>
|
||||
|
@ -369,19 +369,19 @@ task :ditty do
|
|||
# we can reflect on the `host` object passed to the block
|
||||
# and use the `info` logger method to benefit from the
|
||||
# output formatter that is selected.
|
||||
uptime = capture('uptime')
|
||||
uptime = capture('uptime')
|
||||
if host.roles.include?(:web)
|
||||
info "Your webserver #{host} has uptime: #{uptime}"
|
||||
end
|
||||
end
|
||||
|
||||
on roles(:app) do
|
||||
# We can set environmental varaibles for the duration of a block
|
||||
# We can set environmental variables for the duration of a block
|
||||
# and move the process into a directoy, executing arbitrary tasks
|
||||
# such as letting Rails do some heavy lifting.
|
||||
with({:rails_env => :production}) do
|
||||
within('/var/www/my/rails/app') do
|
||||
execute :rails, :runner, 'MyModel.something'
|
||||
within('/var/www/my/rails/app') do
|
||||
execute :rails, :runner, 'MyModel.something'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -390,8 +390,8 @@ task :ditty do
|
|||
# We can even switch users, provided we have support on the remote
|
||||
# server for switching to that user without being prompted for a
|
||||
# passphrase.
|
||||
as 'postgres' do
|
||||
widgets = capture "echo 'SELECT * FROM widgets;' | psql my_database"
|
||||
as 'postgres' do
|
||||
widgets = capture "echo 'SELECT * FROM widgets;' | psql my_database"
|
||||
if widgets.to_i < 50
|
||||
warn "There are fewer than 50 widgets in the database on #{host}!"
|
||||
end
|
||||
|
@ -401,7 +401,7 @@ task :ditty do
|
|||
on roles(:all) do
|
||||
# We can even use `test` the way the Unix gods intended
|
||||
if test("[ -d /some/directory ]")
|
||||
info "Phew, it's ok, the directory exists!"
|
||||
info "Phew, it's ok, the directory exists!"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -175,11 +175,27 @@ CMD</code></pre>
|
|||
<div>
|
||||
<pre data-line=''><code class='language-ruby'>within fetch(:latest_release_directory)
|
||||
with rails_env: fetch(:rails_env) do
|
||||
execute :rake, 'assets:precompile'
|
||||
execute :rake, 'assets:precompile'
|
||||
end
|
||||
end</code></pre>
|
||||
</div>
|
||||
|
||||
<h4 id="toc_2">Refactor roles</h4>
|
||||
|
||||
<p>Instead of:</p>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-ruby'>role :app, %w{example.com}
|
||||
role :web, %w{example.com}
|
||||
role :db, %w{example.com}</code></pre>
|
||||
</div>
|
||||
|
||||
<p>It's better to use:</p>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-ruby'>role :all, %w{example.com}</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -259,9 +275,25 @@ CMD</code></pre>
|
|||
<div>
|
||||
<pre data-line=''><code class='language-ruby'>within fetch(:latest_release_directory)
|
||||
with rails_env: fetch(:rails_env) do
|
||||
execute :rake, 'assets:precompile'
|
||||
execute :rake, 'assets:precompile'
|
||||
end
|
||||
end</code></pre>
|
||||
</div>
|
||||
|
||||
<h4 id="toc_2">Refactor roles</h4>
|
||||
|
||||
<p>Instead of:</p>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-ruby'>role :app, %w{example.com}
|
||||
role :web, %w{example.com}
|
||||
role :db, %w{example.com}</code></pre>
|
||||
</div>
|
||||
|
||||
<p>It's better to use:</p>
|
||||
|
||||
<div>
|
||||
<pre data-line=''><code class='language-ruby'>role :all, %w{example.com}</code></pre>
|
||||
</div>
|
||||
-->
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue