Commit 44e3eef1 by Michael DeHaan

Document -u change

parent 1ac07ee6
...@@ -207,12 +207,15 @@ it&#8217;s much better to just use ssh-agent.</p> ...@@ -207,12 +207,15 @@ it&#8217;s much better to just use ssh-agent.</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ansible atlanta -a <span class="s2">&quot;/sbin/reboot&quot;</span> -f 10 <div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ansible atlanta -a <span class="s2">&quot;/sbin/reboot&quot;</span> -f 10
</pre></div> </pre></div>
</div> </div>
<p>If you want to run commands as a different user than root, it looks like this:</p> <p>In 0.7 and later, this will default to running from your user account. If you do not like this
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ansible atlanta -a <span class="s2">&quot;/usr/bin/foo&quot;</span> -u yourname behavior, pass in &#8220;-u username&#8221;. (In 0.6 and before, it defaulted to root. Most folks prefered
defaulting to the current user, so we changed it).</p>
<p>If you want to run commands as a different user, it looks like this:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ansible atlanta -a <span class="s2">&quot;/usr/bin/foo&quot;</span> -u username
</pre></div> </pre></div>
</div> </div>
<p>If you want to run commands through sudo:</p> <p>If you want to run commands through sudo:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ansible atlanta -a <span class="s2">&quot;/usr/bin/foo&quot;</span> -u yourname --sudo <span class="o">[</span>--ask-sudo-pass<span class="o">]</span> <div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ansible atlanta -a <span class="s2">&quot;/usr/bin/foo&quot;</span> -u username --sudo <span class="o">[</span>--ask-sudo-pass<span class="o">]</span>
</pre></div> </pre></div>
</div> </div>
<p>Use <tt class="docutils literal"><span class="pre">--ask-sudo-pass</span></tt> (<tt class="docutils literal"><span class="pre">-K</span></tt>) if you are not using passwordless <p>Use <tt class="docutils literal"><span class="pre">--ask-sudo-pass</span></tt> (<tt class="docutils literal"><span class="pre">-K</span></tt>) if you are not using passwordless
...@@ -221,7 +224,7 @@ Use of passwordless sudo makes things easier to automate, but it&#8217;s not ...@@ -221,7 +224,7 @@ Use of passwordless sudo makes things easier to automate, but it&#8217;s not
required.</p> required.</p>
<p>It is also possible to sudo to a user other than root using <p>It is also possible to sudo to a user other than root using
<tt class="docutils literal"><span class="pre">--sudo-user</span></tt> (<tt class="docutils literal"><span class="pre">-U</span></tt>):</p> <tt class="docutils literal"><span class="pre">--sudo-user</span></tt> (<tt class="docutils literal"><span class="pre">-U</span></tt>):</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ansible atlanta -a <span class="s2">&quot;/usr/bin/foo&quot;</span> -u yourname -U otheruser <span class="o">[</span>--ask-sudo-pass<span class="o">]</span> <div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ansible atlanta -a <span class="s2">&quot;/usr/bin/foo&quot;</span> -u username -U otheruser <span class="o">[</span>--ask-sudo-pass<span class="o">]</span>
</pre></div> </pre></div>
</div> </div>
<p>Ok, so those are basics. If you didn&#8217;t read about patterns and groups yet, go back and read <a class="reference internal" href="patterns.html"><em>Inventory &amp; Patterns</em></a>.</p> <p>Ok, so those are basics. If you didn&#8217;t read about patterns and groups yet, go back and read <a class="reference internal" href="patterns.html"><em>Inventory &amp; Patterns</em></a>.</p>
......
...@@ -28,13 +28,17 @@ Now to run the command on all servers in a group, in this case, ...@@ -28,13 +28,17 @@ Now to run the command on all servers in a group, in this case,
$ ansible atlanta -a "/sbin/reboot" -f 10 $ ansible atlanta -a "/sbin/reboot" -f 10
If you want to run commands as a different user than root, it looks like this:: In 0.7 and later, this will default to running from your user account. If you do not like this
behavior, pass in "-u username". (In 0.6 and before, it defaulted to root. Most folks prefered
defaulting to the current user, so we changed it).
$ ansible atlanta -a "/usr/bin/foo" -u yourname If you want to run commands as a different user, it looks like this::
$ ansible atlanta -a "/usr/bin/foo" -u username
If you want to run commands through sudo:: If you want to run commands through sudo::
$ ansible atlanta -a "/usr/bin/foo" -u yourname --sudo [--ask-sudo-pass] $ ansible atlanta -a "/usr/bin/foo" -u username --sudo [--ask-sudo-pass]
Use ``--ask-sudo-pass`` (``-K``) if you are not using passwordless Use ``--ask-sudo-pass`` (``-K``) if you are not using passwordless
sudo. This will interactively prompt you for the password to use. sudo. This will interactively prompt you for the password to use.
...@@ -44,7 +48,7 @@ required. ...@@ -44,7 +48,7 @@ required.
It is also possible to sudo to a user other than root using It is also possible to sudo to a user other than root using
``--sudo-user`` (``-U``):: ``--sudo-user`` (``-U``)::
$ ansible atlanta -a "/usr/bin/foo" -u yourname -U otheruser [--ask-sudo-pass] $ ansible atlanta -a "/usr/bin/foo" -u username -U otheruser [--ask-sudo-pass]
Ok, so those are basics. If you didn't read about patterns and groups yet, go back and read :doc:`patterns`. Ok, so those are basics. If you didn't read about patterns and groups yet, go back and read :doc:`patterns`.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment