ansible - 使用 Ansible 和 Openstack Packstack 创建 Neutron 端口
问题描述
我试图在 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 命令,则可以完美运行。如果我尝试运行此特定任务,则会失败并出现以下错误:
致命的:[本地主机]:失败!=> {"changed": 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 模块位置 = /usr/lib/python2.7/site-packages/ansible 可执行位置 = /bin/ansible python 版本 = 2.7.5(默认,2018 年 7 月 13 日,13:06:57)[GCC 4.8.5 20150623(红帽 4.8.5-28)]
知道会是什么吗?
非常感谢,罗曼
解决方案
解决方法是将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
推荐阅读
- amazon-web-services - AWS lambda 缺少一些 SQS 事件未命中导致消息在传输中
- javascript - FireBase + React:TypeError:user.getToken 不是函数
- apache-kafka - 为什么 KSQL 查询从流-流连接创建的流中返回空值?
- list - 如何列出 azure 存储帐户中的所有容器(在 C# 中,azure 版本 12.x)
- asp.net - 用户和编辑器之间的 SignalR Chat asp.net
- java - 处理无效的http请求参数API Restful
- php - PHP 联系表格
- php - Laravel 使用关系列检查列
- vaex - Vaex 列不评估
- python - 在不使用 Pandas 的情况下使用 Python 处理来自 CSV 的数据