首页 文章

使用Ansible和Openstack Packstack创建Neutron端口

提问于
浏览
0

我试图在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

EDIT:

我有2个先前的任务,创建一个安全组并为其分配一个规则,因此不应该预期与身份相关的问题 .

ansible 2.6.1 config file = /etc/ansible/ansible.cfg配置模块搜索路径= [u'/ home / dante / .ansible / plugins / modules',u'/ usr / share / ansible / plugins / modules' ] ansible python module location = /usr/lib/python2.7/site-packages/ansible executable location = / bin / ansible python version = 2.7.5(默认,2018年7月13日,13:06:57)[GCC 4.8 . 5 20150623(红帽4.8.5-28)]

知道可能是什么?

非常感谢,罗曼

1 回答

  • 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
    

相关问题