W3cubDocs

/Ansible

nova_compute - Create/Delete VMs from OpenStack

DEPRECATED

Deprecated in 2.0. Use os_server instead

Synopsis

Create or Remove virtual machines from Openstack.

Requirements (on host that executes module)

  • python >= 2.6
  • python-novaclient

Options

parameter required default choices comments
auth_url
no http://127.0.0.1:35357/v2.0/
The keystone url for authentication
auto_floating_ip
(added in 1.8)
no no
Should a floating ip be auto created and assigned
availability_zone
(added in 1.8)
no None
Name of the availability zone
config_drive
(added in 1.8)
no no
Whether to boot the server with config drive enabled
flavor_id
no 1
The id of the flavor in which the new VM has to be created. Mutually exclusive with flavor_ram
flavor_include
(added in 1.8)
no
Text to use to filter flavor names, for the case, such as Rackspace, where there are multiple flavors that have the same ram count. flavor_include is a positive match filter - it must exist in the flavor name.
flavor_ram
(added in 1.8)
no 1
The minimum amount of ram in MB that the flavor in which the new VM has to be created must have. Mutually exclusive with flavor_id
floating_ip_pools
(added in 1.8)
no None
list of floating IP pools from which to choose a floating IP
floating_ips
(added in 1.8)
no None
list of valid floating IPs that pre-exist to assign to this node
image_exclude
(added in 1.8)
no
Text to use to filter image names, for the case, such as HP, where there are multiple image names matching the common identifying portions. image_exclude is a negative match filter - it is text that may not exist in the image name. Defaults to "(deprecated)"
image_id
yes None
The id of the base image to boot. Mutually exclusive with image_name
image_name
(added in 1.8)
yes None
The name of the base image to boot. Mutually exclusive with image_id
key_name
no None
The key pair name to be used when creating a VM
login_password
yes yes
Password of login user
login_tenant_name
yes yes
The tenant name of the login user
login_username
yes admin
login username to authenticate to keystone
meta
no None
A list of key value pairs that should be provided as a metadata to the new VM
name
yes None
Name that has to be given to the instance
nics
no None
A list of network id's to which the VM's interface should be attached
region_name
no None
Name of the region
scheduler_hints
(added in 1.9)
no None
Arbitrary key/value pairs to the scheduler for custom use
security_groups
no None
The name of the security group to which the VM should be added
state
no present
  • present
  • absent
Indicate desired state of the resource
user_data
(added in 1.6)
no None
Opaque blob of data which is made available to the instance
wait
no yes
If the module should wait for the VM to be created.
wait_for
no 180
The amount of time the module should wait for the VM to get into active state

Examples

# Creates a new VM and attaches to a network and passes metadata to the instance
- nova_compute:
       state: present
       login_username: admin
       login_password: admin
       login_tenant_name: admin
       name: vm1
       image_id: 4f905f38-e52a-43d2-b6ec-754a13ffb529
       key_name: ansible_key
       wait_for: 200
       flavor_id: 4
       nics:
         - net-id: 34605f38-e52a-25d2-b6ec-754a13ffb723
       meta:
         hostname: test1
         group: uge_master

# Creates a new VM in HP Cloud AE1 region availability zone az2 and automatically assigns a floating IP
- name: launch a nova instance
  hosts: localhost
  tasks:
  - name: launch an instance
    nova_compute:
      state: present
      login_username: username
      login_password: Equality7-2521
      login_tenant_name: username-project1
      name: vm1
      auth_url: https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/
      region_name: region-b.geo-1
      availability_zone: az2
      image_id: 9302692b-b787-4b52-a3a6-daebb79cb498
      key_name: test
      wait_for: 200
      flavor_id: 101
      security_groups: default
      auto_floating_ip: yes

# Creates a new VM in HP Cloud AE1 region availability zone az2 and assigns a pre-known floating IP
- name: launch a nova instance
  hosts: localhost
  tasks:
  - name: launch an instance
    nova_compute:
      state: present
      login_username: username
      login_password: Equality7-2521
      login_tenant_name: username-project1
      name: vm1
      auth_url: https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/
      region_name: region-b.geo-1
      availability_zone: az2
      image_id: 9302692b-b787-4b52-a3a6-daebb79cb498
      key_name: test
      wait_for: 200
      flavor_id: 101
      floating_ips:
        - 12.34.56.79

# Creates a new VM with 4G of RAM on Ubuntu Trusty, ignoring deprecated images
- name: launch a nova instance
  hosts: localhost
  tasks:
  - name: launch an instance
    nova_compute:
      name: vm1
      state: present
      login_username: username
      login_password: Equality7-2521
      login_tenant_name: username-project1
      auth_url: https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/
      region_name: region-b.geo-1
      image_name: Ubuntu Server 14.04
      image_exclude: deprecated
      flavor_ram: 4096

# Creates a new VM with 4G of RAM on Ubuntu Trusty on a Rackspace Performance node in DFW
- name: launch a nova instance
  hosts: localhost
  tasks:
  - name: launch an instance
    nova_compute:
      name: vm1
      state: present
      login_username: username
      login_password: Equality7-2521
      login_tenant_name: username-project1
      auth_url: https://identity.api.rackspacecloud.com/v2.0/
      region_name: DFW
      image_name: Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)
      flavor_ram: 4096
      flavor_include: Performance

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, developing_test_pr and Developing Modules.

© 2012–2016 Michael DeHaan
© 2016 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/nova_compute_module.html