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

Apply documentation changes

This commit is contained in:
Lee Hambley 2013-07-29 21:12:57 +02:00
parent 69a3cf8c29
commit 7161de7831
9 changed files with 174 additions and 142 deletions

View file

@ -426,7 +426,7 @@ your application.</p>
<p>An example of it&#39;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 &#39;example.com&#39;
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, &#39;assets:precompile&#39;
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 &#39;sshkit&#39;
desc &quot;Check the uptime of example.com&quot;
task :uptime do |h|
execute :uptime
@ -560,7 +560,7 @@ execute :git, :clone, &quot;........&quot;, &quot;.......&quot;</code></pre>
<div>
<pre data-line=''><code class='language-ruby'># Capistrano 3.0.x
file = '/tmp/somefile'
file = &#39;/tmp/somefile&#39;
unless test(&quot;-e #{file}&quot;)
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 = &#39;/some/file&#39;
if test(&quot;[ -d #{f} ]&quot;)
execute :touch, f
else
@ -1013,7 +1013,7 @@ your application.</p>
<p>An example of it&#39;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 &#39;example.com&#39;
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, &#39;assets:precompile&#39;
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 &#39;sshkit&#39;
desc &quot;Check the uptime of example.com&quot;
task :uptime do |h|
execute :uptime
@ -1147,7 +1147,7 @@ execute :git, :clone, &quot;........&quot;, &quot;.......&quot;</code></pre>
<div>
<pre data-line=''><code class='language-ruby'># Capistrano 3.0.x
file = '/tmp/somefile'
file = &#39;/tmp/somefile&#39;
unless test(&quot;-e #{file}&quot;)
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 = &#39;/some/file&#39;
if test(&quot;[ -d #{f} ]&quot;)
execute :touch, f
else

View file

@ -166,9 +166,9 @@ what happens:</p>
<div>
<pre data-line=''><code class='language-bash'>me@localhost $ ssh me@remote
me@remote $ [[ $- == *i* ]] &amp;&amp; echo 'Interactive' || echo 'Not interactive'
me@remote $ [[ $- == *i* ]] &amp;&amp; echo &#39;Interactive&#39; || echo &#39;Not interactive&#39;
Interactive
me@remote $ shopt -q login_shell &amp;&amp; echo 'Login shell' || echo 'Not login shell'
me@remote $ shopt -q login_shell &amp;&amp; echo &#39;Login shell&#39; || echo &#39;Not login shell&#39;
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 &quot;[[ $- == *i* ]] &amp;&amp; echo 'Interactive' || echo 'Not interactive'&quot;
<pre data-line=''><code class='language-bash'>me@localhost $ ssh me@remote &quot;[[ $- == *i* ]] &amp;&amp; echo &#39;Interactive&#39; || echo &#39;Not interactive&#39;&quot;
Interactive
me@localhost $ ssh me@remote &quot;shopt -q login_shell &amp;&amp; echo 'Login shell' || echo 'Not login shell'&quot;
me@localhost $ ssh me@remote &quot;shopt -q login_shell &amp;&amp; echo &#39;Login shell&#39; || echo &#39;Not login shell&#39;&quot;
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(&quot;[[ $- == *i* ]] &amp;&amp; echo 'Interactive' || echo 'Not interactive'&quot;)
on &#39;me@remote&#39; do
info capture(&quot;[[ $- == *i* ]] &amp;&amp; echo &#39;Interactive&#39; || echo &#39;Not interactive&#39;&quot;)
end
end
task :query_login do
on 'me@remote' do
info capture(&quot;shopt -q login_shell &amp;&amp; echo 'Login shell' || echo 'Not login shell'&quot;)
on &#39;me@remote&#39; do
info capture(&quot;shopt -q login_shell &amp;&amp; echo &#39;Login shell&#39; || echo &#39;Not login shell&#39;&quot;)
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* ]] &amp;&amp; echo 'Interactive' || echo 'Not interactive'
me@remote $ [[ $- == *i* ]] &amp;&amp; echo &#39;Interactive&#39; || echo &#39;Not interactive&#39;
Interactive
me@remote $ shopt -q login_shell &amp;&amp; echo 'Login shell' || echo 'Not login shell'
me@remote $ shopt -q login_shell &amp;&amp; echo &#39;Login shell&#39; || echo &#39;Not login shell&#39;
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 &quot;[[ $- == *i* ]] &amp;&amp; echo 'Interactive' || echo 'Not interactive'&quot;
<pre data-line=''><code class='language-bash'>me@localhost $ ssh me@remote &quot;[[ $- == *i* ]] &amp;&amp; echo &#39;Interactive&#39; || echo &#39;Not interactive&#39;&quot;
Interactive
me@localhost $ ssh me@remote &quot;shopt -q login_shell &amp;&amp; echo 'Login shell' || echo 'Not login shell'&quot;
me@localhost $ ssh me@remote &quot;shopt -q login_shell &amp;&amp; echo &#39;Login shell&#39; || echo &#39;Not login shell&#39;&quot;
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(&quot;[[ $- == *i* ]] &amp;&amp; echo 'Interactive' || echo 'Not interactive'&quot;)
on &#39;me@remote&#39; do
info capture(&quot;[[ $- == *i* ]] &amp;&amp; echo &#39;Interactive&#39; || echo &#39;Not interactive&#39;&quot;)
end
end
task :query_login do
on 'me@remote' do
info capture(&quot;shopt -q login_shell &amp;&amp; echo 'Login shell' || echo 'Not login shell'&quot;)
on &#39;me@remote&#39; do
info capture(&quot;shopt -q login_shell &amp;&amp; echo &#39;Login shell&#39; || echo &#39;Not login shell&#39;&quot;)
end
end</code></pre>
</div>

View file

@ -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&#39;d love it if someone
<p><strong>Note:</strong> If you are on Windows, all bets are off. I&#39;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 &#39;me@my_email_address.com&#39;</code></pre>
</div>
<p>You&#39;ll be prompted for a passphrase, that&#39;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 &#39;hostname; uptime&#39;
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&#39;t have anyway).</p>
prompting you for an SSH password (which the deploy user doesn&#39;t have anyway).</p>
<p>Verify that this works for all of your servers, and put your private key
somewhere safe. If you&#39;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&#39;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&#39;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 &#39;ssh-add -l&#39; didn&#39;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 &#39;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&#39;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&#39;ll be prompted for a username and password:</p>
@ -340,8 +340,8 @@ Github, we&#39;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 &#39;https://github.com&#39;: myownusername
Password for &#39;https://capistrano@github.com&#39;:</code></pre>
</div>
<p>This challenge response prompt doesn&#39;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 &#39;:deploy_to&#39; 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&#39;d love it if someone
<p><strong>Note:</strong> If you are on Windows, all bets are off. I&#39;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 &#39;me@my_email_address.com&#39;</code></pre>
</div>
<p>You&#39;ll be prompted for a passphrase, that&#39;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 &#39;hostname; uptime&#39;
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&#39;t have anyway).</p>
prompting you for an SSH password (which the deploy user doesn&#39;t have anyway).</p>
<p>Verify that this works for all of your servers, and put your private key
somewhere safe. If you&#39;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&#39;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&#39;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 &#39;ssh-add -l&#39; didn&#39;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 &#39;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&#39;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&#39;ll be prompted for a username and password:</p>
@ -700,8 +700,8 @@ Github, we&#39;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 &#39;https://github.com&#39;: myownusername
Password for &#39;https://capistrano@github.com&#39;:</code></pre>
</div>
<p>This challenge response prompt doesn&#39;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 &#39;:deploy_to&#39; variable
root@remote $ deploy_to=/var/www/rails3-bootstrap-devise-cancan-demo
root@remote $ mkdir ${deploy_to}
root@remote $ chown deploy:deploy ${deploy_to}

View file

@ -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 &#39;ls -lR /var/www/my-application&#39;
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&#39;ve done something wrong, that won&#39;t happen and we&#39;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&#39;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 &#39;github.com,204.232.175.90&#39; (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&#39;ll be using SSH agent forwarding, we can check if that&#39;s
@ -291,7 +291,7 @@ DEBUG [f1269276] Finished in 0.453 seconds command successful.
<p>If you don&#39;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 &#39;env | grep SSH_AUTH_SOCK&#39;
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 &#39;ls -lR /var/www/my-application&#39;
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&#39;ve done something wrong, that won&#39;t happen and we&#39;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&#39;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 &#39;github.com,204.232.175.90&#39; (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&#39;ll be using SSH agent forwarding, we can check if that&#39;s
@ -511,7 +511,7 @@ DEBUG [f1269276] Finished in 0.453 seconds command successful.
<p>If you don&#39;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 &#39;env | grep SSH_AUTH_SOCK&#39;
SSH_AUTH_SOCK=/tmp/ssh-Tb6X8V53tm/agent.2934</code></pre>
</div>

View file

@ -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 &#39;capistrano/setup&#39;
require &#39;capistrano/deploy&#39;
require &#39;capistrano/bundler&#39;
require &#39;capistrano/rails/migrations&#39;
require &#39;capistrano/rails/assets&#39;</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 &#39;capistrano/setup&#39;
require &#39;capistrano/deploy&#39;
require &#39;capistrano/bundler&#39;
require &#39;capistrano/rails/migrations&#39;
require &#39;capistrano/rails/assets&#39;</code></pre>
</div>
<p>When you run <code>cap production deploy</code>, it runs these tasks:</p>

View file

@ -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', '~&gt; 0.0.7'
gem &#39;capistrano-rails&#39;, &#39;~&gt; 0.0.7&#39;
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 &#39;capistrano/rails/assets&#39;
require &#39;capistrano/rails/gem-bundler&#39;
require &#39;capistrano/rails/database-migrations&#39;</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', '~&gt; 2.15' # Or whatever patch release you are using</code></pre>
<pre data-line=''><code class='language-ruby'>gem &#39;capistrano&#39;, &#39;~&gt; 2.15&#39; # 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', '~&gt; 0.0.7'
gem &#39;capistrano-rails&#39;, &#39;~&gt; 0.0.7&#39;
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 &#39;capistrano/rails/assets&#39;
require &#39;capistrano/rails/gem-bundler&#39;
require &#39;capistrano/rails/database-migrations&#39;</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', '~&gt; 2.15' # Or whatever patch release you are using</code></pre>
<pre data-line=''><code class='language-ruby'>gem &#39;capistrano&#39;, &#39;~&gt; 2.15&#39; # 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

View file

@ -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 &#39;example.com&#39;, 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 &#39;world.com&#39; roles: [:web], user: &#39;hello&#39;
server &#39;example.com&#39;, 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, &#39;my app name&#39;
set :repo_url, &#39;git@example.com:me/my_repo.git&#39;
ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }</code></pre>
</div>
@ -266,14 +266,14 @@ Tutorials</a> site; there we&#39;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, &#39;rails3-bootstrap-devise-cancan-demo&#39;
set :repo_url, &#39;https://github.com/capistrano/rails3-bootstrap-devise-cancan&#39;
set :branch, &#39;master&#39;</code></pre>
</div>
<p>I&#39;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 &#39;example.com&#39;, 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 &#39;world.com&#39; roles: [:web], user: &#39;hello&#39;
server &#39;example.com&#39;, 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, &#39;my app name&#39;
set :repo_url, &#39;git@example.com:me/my_repo.git&#39;
ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }</code></pre>
</div>
@ -458,14 +458,14 @@ Tutorials</a> site; there we&#39;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, &#39;rails3-bootstrap-devise-cancan-demo&#39;
set :repo_url, &#39;https://github.com/capistrano/rails3-bootstrap-devise-cancan&#39;
set :branch, &#39;master&#39;</code></pre>
</div>
<p>I&#39;ve simplified the <code>:branch</code> variable to simply be a <code>set</code> variable, not a

View file

@ -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(&#39;uptime&#39;)
if host.roles.include?(:web)
info &quot;Your webserver #{host} has uptime: #{uptime}&quot;
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 =&gt; :production}) do
within('/var/www/my/rails/app') do
execute :rails, :runner, 'MyModel.something'
within(&#39;/var/www/my/rails/app&#39;) do
execute :rails, :runner, &#39;MyModel.something&#39;
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 &quot;echo 'SELECT * FROM widgets;' | psql my_database&quot;
as &#39;postgres&#39; do
widgets = capture &quot;echo &#39;SELECT * FROM widgets;&#39; | psql my_database&quot;
if widgets.to_i &lt; 50
warn &quot;There are fewer than 50 widgets in the database on #{host}!&quot;
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(&quot;[ -d /some/directory ]&quot;)
info &quot;Phew, it's ok, the directory exists!&quot;
info &quot;Phew, it&#39;s ok, the directory exists!&quot;
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(&#39;uptime&#39;)
if host.roles.include?(:web)
info &quot;Your webserver #{host} has uptime: #{uptime}&quot;
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 =&gt; :production}) do
within('/var/www/my/rails/app') do
execute :rails, :runner, 'MyModel.something'
within(&#39;/var/www/my/rails/app&#39;) do
execute :rails, :runner, &#39;MyModel.something&#39;
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 &quot;echo 'SELECT * FROM widgets;' | psql my_database&quot;
as &#39;postgres&#39; do
widgets = capture &quot;echo &#39;SELECT * FROM widgets;&#39; | psql my_database&quot;
if widgets.to_i &lt; 50
warn &quot;There are fewer than 50 widgets in the database on #{host}!&quot;
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(&quot;[ -d /some/directory ]&quot;)
info &quot;Phew, it's ok, the directory exists!&quot;
info &quot;Phew, it&#39;s ok, the directory exists!&quot;
end
end

View file

@ -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, &#39;assets:precompile&#39;
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&#39;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, &#39;assets:precompile&#39;
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&#39;s better to use:</p>
<div>
<pre data-line=''><code class='language-ruby'>role :all, %w{example.com}</code></pre>
</div>
-->