使用Ansible和Openstack Packstack创建中子端口
我试图在Ansible中复制此Openstack命令:使用Ansible和Openstack Packstack创建中子端口,ansible,openstack,ports,openstack-neutron,Ansible,Openstack,Ports,Openstack 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:
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
完整的回溯是:
文件“/tmp/ansible\u TnJOrd/ansible\u module\u os\u port.py”,第344行,在main中
端口=云。创建端口(网络id,**端口号)
文件“”,第2行,在创建_端口中
func_包装中的文件“/usr/lib/python2.7/site packages/openstack/cloud/_utils.py”,第374行
返回函数(*args,**kwargs)
文件“/usr/lib/python2.7/site packages/openstack/cloud/openstackcloud.py”,第7964行,位于create\u端口中
网络id)
文件“/usr/lib/python2.7/site packages/keysteauth1/adapter.py”,第310行,在post中
返回self.request(url,'POST',**kwargs)
请求中的文件“/usr/lib/python2.7/site packages/openstack/_adapter.py”,第164行
返回json响应(响应,错误消息=错误消息)
文件“/usr/lib/python2.7/site packages/openstack/_adapter.py”,第95行,在_json_响应中
异常。从\u响应引发\u(响应,错误消息=错误消息)
文件“/usr/lib/python2.7/site packages/openstack/exceptions.py”,第205行,在raise\u from\u响应中
http\u status=http\u status,request\u id=request\u id
致命:[localhost]:失败!=>{
“更改”:错误,
“调用”:{
“模块参数”:{
“管理状态”为空,
“允许的\u地址\u对”:[
{
“ip_地址”:“10.180.157.128/27”
}
],
“api_超时”:空,
“auth”:空,
“身份验证类型”:空,
“可用性区域”:空,
“cacert”:空,
“证书”:空,
“设备id”:空,
“设备所有者”:空,
“额外dhcp选项”:null,
“固定IP”:[
"10.180.157.136"
],
“接口”:“公共”,
“键”:空,
“mac_地址”:空,
“名称”:“端口1”,
“网络”:“nw1”,
“无安全组”:false,
“区域名称”:空,
“安全组”:[
“36e7eb86-a2ae-48d5-8255-a4da0cdea11e”
],
“国家”:“目前”,
“超时”:180,
“验证”:空,
“等待”:对
}
},
“msg”:“为网络c26503e9-b978-4f27-8153-89adee68b743创建端口时出错”
}
要重试,请使用:--limit@/home/dante/Openstack/roles/avi.retry
编辑:
我之前有两个任务,创建一个安全组并为其分配一个规则,因此不应该出现与标识相关的问题
ansible 2.6.1配置文件=/etc/ansible/ansible.cfg已配置
模块搜索路径=[u'/home/dante/.ansible/plugins/modules',
u'/usr/share/ansible/plugins/modules']ansible python模块
location=/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解决方案是将openstacksdk升级到0.17.0,并根据SDK更新代码: sudopip安装openstacksdk==0.17.0
您确定该任务是以授权用户身份运行的,并使用文档中指定的环境变量(如
OS\u USERNAME
)吗?@Baptistem:上一个任务是创建安全组并为其分配规则,它进行得非常顺利;因此,从身份的角度来看,一切都应该很好。好吧,编辑你的问题,并在问题中添加这些信息,以帮助人们。这也可能是ansible的版本。感谢您需要在详细模式下发布错误输出,这会有所帮助。把它写在首字母里question@baptistemm:完成
- 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