2

I am looking to specify which compute node to reside on when creating an instance with Openstack ansible module openstack.cloud.server, Actually I want to ansiblealize the following command:

$ openstack server create --flavor g2 --image Ubuntu-20.04 --network public2 --security-group default --hypervisor-hostname compute3 --os-compute-api-version 2.74 test
# OR
$ openstack server create --flavor g2 --image Ubuntu-20.04 --network public2 --security-group default --host compute3 --os-compute-api-version 2.74 test

How I can pass --host or --hypervisor-hostname similar to Openstack CLI to openstack.cloud.server module in ansible???

YosSaL
  • 667
  • 6
  • 15

1 Answers1

1

Try to use meta.hostname define you hypervisor:

- name: Create a new instance and attaches to a network and passes metadata to the instance
  openstack.cloud.server:
      ......
      meta:
        hostname: test1

meta:

A list of key value pairs that should be provided as a metadata to the new instance

Another way, it could use availability_zone parameter to select hosts:

- name: launch an instance in specific host
  openstack.cloud.server:
    ......
    availability_zone: nova:compute3001

See also this example.

Victor Lee
  • 2,467
  • 3
  • 19
  • 37
  • I have also found another solution, setting `openstack.cloud.server: availability_zone: nova:compute3001` will solve the issue, can you add this to your answer too so I can accept it? – YosSaL Nov 20 '22 at 10:35