<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://tech.uvoo.io/index.php?action=history&amp;feed=atom&amp;title=Ansible_cmd_function</id>
	<title>Ansible cmd function - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://tech.uvoo.io/index.php?action=history&amp;feed=atom&amp;title=Ansible_cmd_function"/>
	<link rel="alternate" type="text/html" href="https://tech.uvoo.io/index.php?title=Ansible_cmd_function&amp;action=history"/>
	<updated>2026-04-24T20:45:17Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.2</generator>
	<entry>
		<id>https://tech.uvoo.io/index.php?title=Ansible_cmd_function&amp;diff=3187&amp;oldid=prev</id>
		<title>Busk: Created page with &quot; ## Bash function wrapper ``` run_cmd(){   host=$1   cmd=$2   conn=${3:-linux}   port=${4:-22}   if  $conn == &quot;winrm&quot; ; then     ansible all --inventory $host, --module-na...&quot;</title>
		<link rel="alternate" type="text/html" href="https://tech.uvoo.io/index.php?title=Ansible_cmd_function&amp;diff=3187&amp;oldid=prev"/>
		<updated>2022-06-11T18:32:46Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot; ## Bash function wrapper ``` run_cmd(){   host=$1   cmd=$2   conn=${3:-linux}   port=${4:-22}   if &lt;a href=&quot;/index.php?title=$conn_%3D%3D_%22winrm%22&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;$conn == &amp;quot;winrm&amp;quot; (page does not exist)&quot;&gt;$conn == &amp;quot;winrm&amp;quot; &lt;/a&gt;; then     ansible all --inventory $host, --module-na...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
## Bash function wrapper&lt;br /&gt;
```&lt;br /&gt;
run_cmd(){&lt;br /&gt;
  host=$1&lt;br /&gt;
  cmd=$2&lt;br /&gt;
  conn=${3:-linux}&lt;br /&gt;
  port=${4:-22}&lt;br /&gt;
  if [[ $conn == &amp;quot;winrm&amp;quot; ]]; then&lt;br /&gt;
    ansible all --inventory $host, --module-name=win_shell --args=&amp;quot;$cmd&amp;quot; -e ansible_password=$ANSIBLE_PASSWORD -e ansible_user=$ANSIBLE_USER -e ansible_winrm_transport=ntlm -e ansible_connection=winrm -e ansible_port=$port&lt;br /&gt;
  elif [[ $conn == &amp;quot;ssh&amp;quot; ]]; then&lt;br /&gt;
    ansible all --inventory $host, --module-name=shell --args=&amp;quot;$cmd&amp;quot; -e ansible_password=$ANSIBLE_PASSWORD -e ansible_user=$ANSIBLE_USER  --become -e ansible_become_password=$ANSIBLE_PASSWORD -e ansible_port=$port&lt;br /&gt;
  else&lt;br /&gt;
    echo &amp;quot;Connection type $conn not supported.&amp;quot;&lt;br /&gt;
  fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
run_cmd host.example.com &amp;quot;whoami&amp;quot; winrm 5986&lt;br /&gt;
```&lt;/div&gt;</summary>
		<author><name>Busk</name></author>
	</entry>
</feed>