mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Document -u change
This commit is contained in:
parent
1ac07ee677
commit
44e3eef15e
3 changed files with 16 additions and 9 deletions
|
@ -207,12 +207,15 @@ it’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">"/sbin/reboot"</span> -f 10
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>If you want to run commands as a different user than root, it looks like this:</p>
|
||||
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ansible atlanta -a <span class="s2">"/usr/bin/foo"</span> -u yourname
|
||||
<p>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).</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">"/usr/bin/foo"</span> -u username
|
||||
</pre></div>
|
||||
</div>
|
||||
<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">"/usr/bin/foo"</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">"/usr/bin/foo"</span> -u username --sudo <span class="o">[</span>--ask-sudo-pass<span class="o">]</span>
|
||||
</pre></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
|
||||
|
@ -221,7 +224,7 @@ Use of passwordless sudo makes things easier to automate, but it’s not
|
|||
required.</p>
|
||||
<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>
|
||||
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ansible atlanta -a <span class="s2">"/usr/bin/foo"</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">"/usr/bin/foo"</span> -u username -U otheruser <span class="o">[</span>--ask-sudo-pass<span class="o">]</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Ok, so those are basics. If you didn’t read about patterns and groups yet, go back and read <a class="reference internal" href="patterns.html"><em>Inventory & Patterns</em></a>.</p>
|
||||
|
|
|
@ -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
|
||||
|
||||
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::
|
||||
|
||||
$ 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
|
||||
sudo. This will interactively prompt you for the password to use.
|
||||
|
@ -44,7 +48,7 @@ required.
|
|||
It is also possible to sudo to a user other than root using
|
||||
``--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`.
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue