<linkrel="prev"title="community.routeros.api_modify module – Modify data at paths with API"href="api_modify_module.html"/><!-- extra head elements for Ansible beyond RTD Sphinx Theme -->
</head>
<bodyclass="wy-body-for-nav"><!-- extra body elements for Ansible beyond RTD Sphinx Theme -->
<liclass="toctree-l1"><aclass="reference internal"href="docsite/api-guide.html">How to connect to RouterOS devices with the RouterOS API</a></li>
<liclass="toctree-l1"><aclass="reference internal"href="docsite/ssh-guide.html">How to connect to RouterOS devices with SSH</a></li>
<liclass="toctree-l1"><aclass="reference internal"href="docsite/quoting.html">How to quote and unquote commands and arguments</a></li>
</ul>
<ulclass="current">
<liclass="toctree-l1"><aclass="reference internal"href="api_module.html">community.routeros.api module – Ansible module for RouterOS API</a></li>
<liclass="toctree-l1"><aclass="reference internal"href="api_facts_module.html">community.routeros.api_facts module – Collect facts from remote devices running MikroTik RouterOS using the API</a></li>
<liclass="toctree-l1"><aclass="reference internal"href="api_find_and_modify_module.html">community.routeros.api_find_and_modify module – Find and modify information using the API</a></li>
<liclass="toctree-l1"><aclass="reference internal"href="api_info_module.html">community.routeros.api_info module – Retrieve information from API</a></li>
<liclass="toctree-l1"><aclass="reference internal"href="api_modify_module.html">community.routeros.api_modify module – Modify data at paths with API</a></li>
<liclass="toctree-l1 current"><aclass="current reference internal"href="#">community.routeros.command module – Run commands on remote devices running MikroTik RouterOS</a><ul>
<liclass="toctree-l1"><aclass="reference internal"href="routeros_cliconf.html">community.routeros.routeros cliconf – Use routeros cliconf to run command on MikroTik RouterOS platform</a></li>
</ul>
<ul>
<liclass="toctree-l1"><aclass="reference internal"href="join_filter.html">community.routeros.join filter – Join a list of arguments to a command</a></li>
<liclass="toctree-l1"><aclass="reference internal"href="list_to_dict_filter.html">community.routeros.list_to_dict filter – Convert a list of arguments to a dictionary</a></li>
<liclass="toctree-l1"><aclass="reference internal"href="quote_argument_filter.html">community.routeros.quote_argument filter – Quote an argument</a></li>
<liclass="toctree-l1"><aclass="reference internal"href="quote_argument_value_filter.html">community.routeros.quote_argument_value filter – Quote an argument value</a></li>
<liclass="toctree-l1"><aclass="reference internal"href="split_filter.html">community.routeros.split filter – Split a command into arguments</a></li>
<liclass="breadcrumb-item active">community.routeros.command module – Run commands on remote devices running MikroTik RouterOS</li>
<liclass="wy-breadcrumbs-aside">
<!-- User defined GitHub URL -->
<ahref="https://github.com/ansible-collections/community.routeros/edit/main/plugins/modules/command.py?description=%23%23%23%23%23%20SUMMARY%0A%3C!—%20Your%20description%20here%20–%3E%0A%0A%0A%23%23%23%23%23%20ISSUE%20TYPE%0A-%20Docs%20Pull%20Request%0A%0A%2Blabel:%20docsite_pr"class="fa fa-github"> Edit on GitHub</a>
<h1>community.routeros.command module – Run commands on remote devices running MikroTik RouterOS<aclass="headerlink"href="#community-routeros-command-module-run-commands-on-remote-devices-running-mikrotik-routeros"title="Link to this heading"></a></h1>
<p>This module is part of the <aclass="reference external"href="https://galaxy.ansible.com/ui/repo/published/community/routeros/">community.routeros collection</a> (version 2.11.0).</p>
<p>It is not included in <codeclass="docutils literal notranslate"><spanclass="pre">ansible-core</span></code>.
To check whether it is installed, run <codeclass="code docutils literal notranslate"><spanclass="pre">ansible-galaxy</span><spanclass="pre">collection</span><spanclass="pre">list</span></code>.</p>
<li><p>Sends arbitrary commands to an RouterOS node and returns the results read from the device. This module includes an argument that will cause the module to wait for a specific condition before returning or timing out if the condition is not met.</p></li>
<li><p>The module always indicates a (changed) status. You can use <aclass="reference external"href="https://docs.ansible.com/ansible/devel/playbook_guide/playbooks_error_handling.html#override-the-changed-result"title="(in Ansible vdevel)"><spanclass="xref std std-ref">the changed_when task property</span></a> to determine whether a command task actually resulted in a change or not.</p></li>
<aclass="ansibleOptionLink"href="#parameter-commands"title="Permalink to this option"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">list</span> / <spanclass="ansible-option-elements">elements=string</span> / <spanclass="ansible-option-required">required</span></p>
<td><divclass="ansible-option-cell"><p>List of commands to send to the remote RouterOS device over the configured provider. The resulting output from the command is returned. If the <codeclass="ansible-option docutils literal notranslate"><strong><aclass="reference internal"href="#ansible-collections-community-routeros-command-module-parameter-wait-for"><spanclass="std std-ref"><spanclass="pre">wait_for</span></span></a></strong></code> argument is provided, the module is not returned until the condition is satisfied or the number of retries has expired.</p>
<aclass="ansibleOptionLink"href="#parameter-interval"title="Permalink to this option"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">integer</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>Configures the interval in seconds to wait between retries of the command. If the command does not pass the specified conditions, the interval indicates how long to wait before trying the command again.</p>
<aclass="ansibleOptionLink"href="#parameter-match"title="Permalink to this option"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">string</span></p>
<td><divclass="ansible-option-cell"><p>The <codeclass="ansible-option docutils literal notranslate"><strong><aclass="reference internal"href="#ansible-collections-community-routeros-command-module-parameter-match"><spanclass="std std-ref"><spanclass="pre">match</span></span></a></strong></code> argument is used in conjunction with the <codeclass="ansible-option docutils literal notranslate"><strong><aclass="reference internal"href="#ansible-collections-community-routeros-command-module-parameter-wait-for"><spanclass="std std-ref"><spanclass="pre">wait_for</span></span></a></strong></code> argument to specify the match policy. Valid values are <codeclass="ansible-value docutils literal notranslate"><spanclass="pre">all</span></code> or <codeclass="ansible-value docutils literal notranslate"><spanclass="pre">any</span></code>. If the value is set to <codeclass="ansible-value docutils literal notranslate"><spanclass="pre">all</span></code> then all conditionals in the wait_for must be satisfied. If the value is set to <codeclass="ansible-value docutils literal notranslate"><spanclass="pre">any</span></code> then only one of the values must be satisfied.</p>
<aclass="ansibleOptionLink"href="#parameter-retries"title="Permalink to this option"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">integer</span></p>
<td><divclass="ansible-option-cell"><p>Specifies the number of retries a command should by tried before it is considered failed. The command is run on the target device every retry and evaluated against the <codeclass="ansible-option docutils literal notranslate"><strong><aclass="reference internal"href="#ansible-collections-community-routeros-command-module-parameter-wait-for"><spanclass="std std-ref"><spanclass="pre">wait_for</span></span></a></strong></code> conditions.</p>
<aclass="ansibleOptionLink"href="#parameter-wait_for"title="Permalink to this option"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">list</span> / <spanclass="ansible-option-elements">elements=string</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>List of conditions to evaluate against the output of the command. The task will wait for each condition to be true before moving forward. If the conditional is not true within the configured number of retries, the task fails. See examples.</p>
<p>The module claims to support check mode, but it simply always executes the command.</p>
</div></td>
<td><divclass="ansible-option-cell"><p>Can run in <codeclass="docutils literal notranslate"><spanclass="pre">check_mode</span></code> and return changed status prediction without modifying target.</p>
<td><divclass="ansible-option-cell"><p>Will return details on what has changed (or possibly needs changing in <codeclass="docutils literal notranslate"><spanclass="pre">check_mode</span></code>), when in diff mode.</p>
<dt><aclass="reference internal"href="docsite/ssh-guide.html#ansible-collections-community-routeros-docsite-ssh-guide"><spanclass="std std-ref">How to connect to RouterOS devices with SSH</span></a></dt><dd><p>How to connect to RouterOS devices with SSH</p>
</dd>
<dt><aclass="reference internal"href="docsite/quoting.html#ansible-collections-community-routeros-docsite-quoting"><spanclass="std std-ref">How to quote and unquote commands and arguments</span></a></dt><dd><p>How to quote and unquote commands and arguments</p>
<spanclass="p p-Indicator">-</span><spanclass="w"></span><spanclass="nt">name</span><spanclass="p">:</span><spanclass="w"></span><spanclass="l l-Scalar l-Scalar-Plain">Run command and check to see if output contains routeros</span>
<spanclass="p p-Indicator">-</span><spanclass="w"></span><spanclass="nt">name</span><spanclass="p">:</span><spanclass="w"></span><spanclass="l l-Scalar l-Scalar-Plain">Run multiple commands and evaluate the output</span>
<h2><aclass="toc-backref"href="#id7"role="doc-backlink">Return Values</a><aclass="headerlink"href="#return-values"title="Link to this heading"></a></h2>
<p>Common return values are documented <aclass="reference external"href="https://docs.ansible.com/ansible/devel/reference_appendices/common_return_values.html#common-return-values"title="(in Ansible vdevel)"><spanclass="xref std std-ref">here</span></a>, the following are the fields unique to this module:</p>
<aclass="ansibleOptionLink"href="#return-failed_conditions"title="Permalink to this return value"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">list</span> / <spanclass="ansible-option-elements">elements=string</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>The list of conditionals that have failed</p>
<aclass="ansibleOptionLink"href="#return-stdout"title="Permalink to this return value"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">list</span> / <spanclass="ansible-option-elements">elements=string</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>The set of responses from the commands</p>
<aclass="ansibleOptionLink"href="#return-stdout_lines"title="Permalink to this return value"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">list</span> / <spanclass="ansible-option-elements">elements=string</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>The value of stdout split into a list</p>
<ahref="api_modify_module.html"class="btn btn-neutral float-left"title="community.routeros.api_modify module – Modify data at paths with API"accesskey="p"rel="prev"><spanclass="fa fa-arrow-circle-left"aria-hidden="true"></span> Previous</a>