我们在ubuntu 14.04中安装了ansible 2.1.0版。
使用os_network模块时,我们收到此错误。
root@ubuntu:/home/admin-nfv/Nuage_Automation/nuage_vm_creation/playbooks# ansible-playbook create_or_delete_network.yml
[WARNING]: provided hosts list is empty, only localhost is available
PLAY [Create Network] **********************************************************
TASK [setup] *******************************************************************
ok: [localhost]
TASK [create_network : create or delete network] *******************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: create_network() takes at most 4 arguments (7 given)
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):\n File \"/tmp/ansible_crfy0P/ansible_module_os_network.py\", line 247, in <module>\n main()\n File \"/tmp/ansible_crfy0P/ansible_module_os_network.py\", line 226, in main\n external, provider, project_id)\nTypeError: create_network() takes at most 4 arguments (7 given)\n", "module_stdout": "", "msg": "MODULE FAILURE", "parsed": false}
NO MORE HOSTS LEFT *************************************************************
to retry, use: --limit @create_or_delete_network.retry
PLAY RECAP *********************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=1
-vvv输出的错误是
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_9jY3t3/ansible_module_os_network.py", line 247, in <module>
main()
File "/tmp/ansible_9jY3t3/ansible_module_os_network.py", line 226, in main
external, provider, project_id)
TypeError: create_network() takes at most 4 arguments (7 given)
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_name": "os_network"}, "module_stderr": "Traceback (most recent call last):\n File \"/tmp/ansible_9jY3t3/ansible_module_os_network.py\", line 247, in <module>\n main()\n File \"/tmp/ansible_9jY3t3/ansible_module_os_network.py\", line 226, in main\n external, provider, project_id)\nTypeError: create_network() takes at most 4 arguments (7 given)\n", "module_stdout": "", "msg": "MODULE FAILURE", "parsed": false}
我们用于创建网络的剧本是
- name: create or delete network
os_network:
auth:
auth_url: "http://1.2.3.4:35357/v2.0"
username: "admin"
password: "xxxxxxx"
project_name: "admin"
state: "present"
name: "Test"
external: true
在另一台机器中,相同的代码正在运行,没有任何错误。但不确定环境是否有问题。
答案 0 :(得分:1)
Ansible使用shade
模块中的os_network
pip包。该包中的接口,尤其是create_network
方法的接口在最近的版本中已经改变,而现在更新版的ansible依赖于新功能。
您应确保在ansible主机上使用最新版本,目前版本为1.9.0
pip install shade==1.9.0