@@ -207,12 +207,15 @@ it’s much better to just use ssh-agent.</p>
<divclass="highlight-bash"><divclass="highlight"><pre><spanclass="nv">$ </span>ansible atlanta -a <spanclass="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>
<divclass="highlight-bash"><divclass="highlight"><pre><spanclass="nv">$ </span>ansible atlanta -a <spanclass="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>
<divclass="highlight-bash"><divclass="highlight"><pre><spanclass="nv">$ </span>ansible atlanta -a <spanclass="s2">"/usr/bin/foo"</span> -u username
</pre></div>
</div>
<p>If you want to run commands through sudo:</p>
<divclass="highlight-bash"><divclass="highlight"><pre><spanclass="nv">$ </span>ansible atlanta -a <spanclass="s2">"/usr/bin/foo"</span> -u yourname --sudo <spanclass="o">[</span>--ask-sudo-pass<spanclass="o">]</span>
<divclass="highlight-bash"><divclass="highlight"><pre><spanclass="nv">$ </span>ansible atlanta -a <spanclass="s2">"/usr/bin/foo"</span> -u username --sudo <spanclass="o">[</span>--ask-sudo-pass<spanclass="o">]</span>
</pre></div>
</div>
<p>Use <ttclass="docutils literal"><spanclass="pre">--ask-sudo-pass</span></tt> (<ttclass="docutils literal"><spanclass="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
<divclass="highlight-bash"><divclass="highlight"><pre><spanclass="nv">$ </span>ansible atlanta -a <spanclass="s2">"/usr/bin/foo"</span> -u yourname -U otheruser <spanclass="o">[</span>--ask-sudo-pass<spanclass="o">]</span>
<divclass="highlight-bash"><divclass="highlight"><pre><spanclass="nv">$ </span>ansible atlanta -a <spanclass="s2">"/usr/bin/foo"</span> -u username -U otheruser <spanclass="o">[</span>--ask-sudo-pass<spanclass="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 <aclass="reference internal"href="patterns.html"><em>Inventory & Patterns</em></a>.</p>