mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-25 10:29:09 -07: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
|
<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>
|
</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">"/usr/bin/foo"</span> -u yourname
|
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>
|
</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">"/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>
|
</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’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">"/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>
|
</pre></div>
|
||||||
</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>
|
<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
|
$ 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.
|
||||||
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`.
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue