Search code examples
ansiblevirtual-machineopenstack

Deploying a new VM using Packstack and Ansible


I have installed Packstack and Ansible 2.7.5 and I would like to make a test and deploy a VM using Ansible. I am using the following code:

--- #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

When I am running it, I am getting the following error:

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   

I have tried to install also the Openstacksdk 0.12.0, but I am getting some other errors related to dependencies:

[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.

Is any way to correct this? Or, if this module is to new and has too many bugs, is any other way to create a VM in Openstack using Ansible? I have checked also the version of nova_compute module, but it says that this Ansible module is deprecated after Ansible 2.0.

Best regards, Romain


Solution

  • It was solved by installing the openstacksdk with all its dependencies in the end. Here is also the code:

    --- #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