COA Automation & Scripting 3 — Questions and Answers
Question 1: In openstacksdk, which method is used to establish a connection to an OpenStack cloud using clouds.yaml?
- openstack.connect() (Correct answer)
- openstack.auth()
- openstack.session()
- openstack.client()
Correct answer: openstack.connect()
openstack.connect() reads credentials from clouds.yaml or environment variables and returns a Connection object for interacting with OpenStack services.
Question 2: Which file format does the OpenStack CLI use by default to store cloud credentials for multiple environments?
- clouds.yaml (Correct answer)
- openrc.sh
- keystonerc
- credentials.json
Correct answer: clouds.yaml
clouds.yaml is the preferred multi-cloud configuration file that stores credentials and endpoints for multiple OpenStack environments.
Question 3: In a HOT template, how do you reference the ID of a resource named 'my_server' within the same template?
- {get_resource: my_server} (Correct answer)
- {get_attr: [my_server, id]}
- {Ref: my_server}
- {resource_id: my_server}
Correct answer: {get_resource: my_server}
The 'get_resource' intrinsic function returns the resource ID of another resource defined in the same HOT template.
Question 4: Which Ansible inventory plugin dynamically fetches OpenStack instances as inventory hosts?
- openstack.cloud.inventory (Correct answer)
- os_inventory
- nova_inventory
- openstack_dynamic
Correct answer: openstack.cloud.inventory
The 'openstack.cloud.inventory' plugin queries Nova to build a dynamic inventory of running OpenStack instances.
Question 5: When scripting with the OpenStack CLI, which flag outputs results in a machine-parseable format best suited for shell scripting?
- -f value (Correct answer)
- -f json
- -f table
- -f csv
Correct answer: -f value
The '-f value' format outputs plain values without headers or borders, making it easiest to parse in shell scripts with standard tools like awk or cut.
Question 6: Which Heat resource type provisions a new Nova server instance in a HOT template?
- OS::Nova::Server (Correct answer)
- OS::Compute::Instance
- OS::Nova::Instance
- OS::Server::Compute
Correct answer: OS::Nova::Server
'OS::Nova::Server' is the Heat resource type used to define and launch a Nova compute instance within a stack.
Question 7: Which environment variable must be exported before running OpenStack CLI commands when using openrc authentication?
- OS_AUTH_URL (Correct answer)
- OPENSTACK_URL
- OS_ENDPOINT
- KEYSTONE_URL
Correct answer: OS_AUTH_URL
OS_AUTH_URL points the CLI to the Keystone identity endpoint and is required for authentication with all OpenStack services.
In openstacksdk, which method is used to establish a connection to an OpenStack cloud using clouds.yaml?