无法在网络设备上运行命令-Ansible

时间:2019-01-28 19:47:45

标签: ansible

我试图在防火墙中运行单个命令,以使我知道我也可以运行其他命令,但是我不确定如何解释错误消息。据我所知,防火墙没有安装python

这是库存文件

[firewall]

192.168.10.2:4118 ansible_user="my firewall user here" ansible_ssh_pass="the firewall's user's password here" ansible_connection=network_cli 

和我的测试剧本:

- name: "Disable HTTPS rule for Xcelerator Update"
  hosts: firewall
  gather_facts: False
  tasks:
  - name: Log in to Firebox
    raw: who

错误消息是这样的:

TASK [Log in to Firebox] **************************************************************************************************************************
task path: /ansible/watchguard/disableHTTPS.yml:6
The full traceback is:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 130, in run
    res = self._execute()
  File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 528, in _execute
    result = self._handler.run(task_vars=variables)
  File "/usr/lib/python2.7/site-packages/ansible/plugins/action/raw.py", line 41, in run
    result.update(self._low_level_execute_command(self._task.args.get('_raw_params'), executable=executable))
  File "/usr/lib/python2.7/site-packages/ansible/plugins/action/__init__.py", line 889, in _low_level_execute_command
    rc, stdout, stderr = self._connection.exec_command(cmd, in_data=in_data, sudoable=sudoable)
TypeError: exec_command() got an unexpected keyword argument 'in_data'

fatal: [192.168.10.2]: FAILED! => {
    "msg": "Unexpected failure during module execution.",
    "stdout": ""
}

有人知道如何开始调试吗?我要在其上运行该剧本的设备是Watchguard Firebox防火墙。

1 个答案:

答案 0 :(得分:1)

请勿将ansible_connection=network_cliraw模块一起使用。

如果network_cli支持您的防火墙,请至少使用ansible_network_os ...

对其进行正确配置。

https://github.com/ansible/ansible/blob/devel/docs/docsite/rst/network/user_guide/platform_index.rst#settings-by-platform