我正在尝试在Ansible中重现此Openstack命令:
neutron port-create --fixed-ip ip_address=10.180.157.136 --allowed-address-pair ip_address=10.180.157.128/27 --name port1 --security-group sg_default nw1
我已经尝试过创建Openstack命令的任务:
- name: Create Neutron port
os_port:
state: present
fixed_ips: 10.180.157.136
allowed_address_pairs: 10.180.157.128/27
name: port1
security_groups: sg_default
network: nw1
tags: ports
如果我正在运行Openstack命令,则效果很好。如果我尝试运行此特定任务,它将失败并显示以下错误:
致命:[localhost]:失败! => {“已更改”:false,“ msg”:“错误 更新端口7ab0ebdc-e28b-4eae-bbc9-0c00ca4cb1fd“}
并且在详细模式下:
The full traceback is:
File "/tmp/ansible_TnJOrd/ansible_module_os_port.py", line 344, in main
port = cloud.create_port(network_id, **port_kwargs)
File "<string>", line 2, in create_port
File "/usr/lib/python2.7/site-packages/openstack/cloud/_utils.py", line 374, in func_wrapper
return func(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/openstack/cloud/openstackcloud.py", line 7964, in create_port
network_id))
File "/usr/lib/python2.7/site-packages/keystoneauth1/adapter.py", line 310, in post
return self.request(url, 'POST', **kwargs)
File "/usr/lib/python2.7/site-packages/openstack/_adapter.py", line 164, in request
return _json_response(response, error_message=error_message)
File "/usr/lib/python2.7/site-packages/openstack/_adapter.py", line 95, in _json_response
exceptions.raise_from_response(response, error_message=error_message)
File "/usr/lib/python2.7/site-packages/openstack/exceptions.py", line 205, in raise_from_response
http_status=http_status, request_id=request_id
fatal: [localhost]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"admin_state_up": null,
"allowed_address_pairs": [
{
"ip_address": "10.180.157.128/27"
}
],
"api_timeout": null,
"auth": null,
"auth_type": null,
"availability_zone": null,
"cacert": null,
"cert": null,
"device_id": null,
"device_owner": null,
"extra_dhcp_opts": null,
"fixed_ips": [
"10.180.157.136"
],
"interface": "public",
"key": null,
"mac_address": null,
"name": "port1",
"network": "nw1",
"no_security_groups": false,
"region_name": null,
"security_groups": [
"36e7eb86-a2ae-48d5-8255-a4da0cdea11e"
],
"state": "present",
"timeout": 180,
"verify": null,
"wait": true
}
},
"msg": "Error creating port for network c26503e9-b978-4f27-8153-89adee68b743"
}
to retry, use: --limit @/home/dante/Openstack/roles/avi.retry
编辑:
我之前有2个任务,创建一个安全组并为其分配一个规则,因此不会出现与身份相关的问题。
ansible 2.6.1配置文件= /etc/ansible/ansible.cfg已配置 模块搜索路径= [u'/ home / dante / .ansible / plugins / modules', u'/ usr / share / ansible / plugins / modules'] ansible python module 位置= /usr/lib/python2.7/site-packages/ansible可执行文件 location = / bin / ansible python版本= 2.7.5(默认值,7月13日 2018,13:06:57)[GCC 4.8.5 20150623(Red Hat 4.8.5-28)]
有什么主意吗?
非常感谢, 罗曼(Romain)
答案 0 :(得分:1)
解决方案是将openstacksdk升级到0.17.0并根据SDK更新代码:
sudo pip install openstacksdk == 0.17.0
- name: Create the Neutron ports
os_port:
state: present
fixed_ips:
- ip_address: 10.180.157.136
allowed_address_pairs:
- ip_address: 10.180.157.128/27
name: port1
security_groups: sg_default
network: nw1
tags: ports