使用Packstack和Ansible部署新VM

问题描述 投票:0回答:2

我已经安装了Packstack和Ansible 2.7.5,我想使用Ansible进行测试并部署VM。我使用以下代码:

--- #Deploy an instance
- name: Deploy an instance
  hosts: localhost
  gather_facts: false
  tasks: 
  - name: Deploy an instance
    os_server: 
       state: present
       auth: 
         auth_url: http://127.0.0.1:5000/v2.0/
         username: admin
         password: 712e207207aa4083 
         project_name: admin 
       name: webserver
       image: cirros
       key_name: root
       timeout: 200  
       flavor: 1
       nics:
        - net-id: fa6af4e6-c44e-439c-a91c-03bcae55e587
       meta:
        hostname: webserver.localdomain

当我运行它时,我收到以下错误:

TASK [Deploy an instance] *****************************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "To utilize this module, the installed version ofthe openstacksdk library MUST be >=0.12.0"}
    to retry, use: --limit @/home/dante/Openstack/deployment.retry

PLAY RECAP ********************************************************************************************************************************************************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=1   

我已经尝试安装Openstacksdk 0.12.0,但我得到一些与依赖关系相关的其他错误:

[dante@localhost Openstack]$ sudo pip install openstacksdk==0.12.0
...
Installing collected packages: ipaddress, os-service-types, PyYAML, openstacksdk
  Found existing installation: ipaddress 1.0.16
Cannot uninstall 'ipaddress'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

有什么办法可以纠正这个吗?或者,如果此模块是新的并且有太多错误,是否可以使用Ansible在Openstack中创建VM?我还检查了nova_compute模块的版本,但它说Ansible 2.0之后不推荐使用这个Ansible模块。

最好的问候,罗曼

ansible virtual-machine openstack
2个回答
0
投票

虽然在你的主机中:是localhost,你仍然需要告诉它连接类型https://docs.ansible.com/ansible/latest/user_guide/playbooks_delegation.html,这样你就可以使用delegate_to:localhost或connection:localhost。对于与API通信或不需要ssh连接来执行任务的任何模块都需要这样做。例如,aws,gitlab,github,nios模块。


0
投票

它是通过安装openstacksdk及其所有依赖项来解决的。这里也是代码:

--- #Deploy an instance
- name: Deploy an instance
  hosts: localhost
  gather_facts: false
  tasks: 
  - name: Deploy an instance
    os_server: 
       state: present
       auth: 
         auth_url: http://<URL TAKEN FROM SOURCE FILE> 
         username: <USERNAME>
         password: <PASSWORD> 
       name: webserver
       image: <ID OF THE IMAGE>
       timeout: 700  
       flavor: 1
       auto_floating_ip: yes
    register: webserver
© www.soinside.com 2019 - 2024. All rights reserved.