85fa2bb2b6
Change-Id: Ief843310ce57a2d1062d86c54cd7ad6e0f705b68
108 lines
2.6 KiB
YAML
108 lines
2.6 KiB
YAML
---
|
|
- name: List all images
|
|
openstack.cloud.image_info:
|
|
cloud: "{{ cloud }}"
|
|
register: images
|
|
|
|
- name: Identify CirrOS image name
|
|
set_fact:
|
|
image_name: "{{ images.images|community.general.json_query(query)|first }}"
|
|
vars:
|
|
query: "[?starts_with(name, 'cirros')].name"
|
|
|
|
- name: Create test server
|
|
openstack.cloud.server:
|
|
cloud: "{{ cloud }}"
|
|
state: present
|
|
name: ansible_server
|
|
image: "{{ image_name }}"
|
|
flavor: m1.tiny
|
|
network: private
|
|
auto_ip: false
|
|
wait: true
|
|
register: server
|
|
|
|
- name: Set server metadata by id
|
|
openstack.cloud.server_metadata:
|
|
cloud: "{{ cloud }}"
|
|
name: "{{ server.server.id }}"
|
|
meta:
|
|
test_key: test_value
|
|
second_key: second_value
|
|
register: server_metadata
|
|
|
|
- name: Assert updated metadata
|
|
assert:
|
|
that:
|
|
- server_metadata is changed
|
|
- "server_metadata.server.metadata == {'test_key': 'test_value', 'second_key':
|
|
'second_value'}"
|
|
|
|
- name: Set server metadata by name
|
|
openstack.cloud.server_metadata:
|
|
cloud: "{{ cloud }}"
|
|
name: "{{ server.server.name }}"
|
|
meta:
|
|
test_key: test_value_2
|
|
register: server_metadata
|
|
|
|
- name: Assert updated metadata
|
|
assert:
|
|
that:
|
|
- server_metadata is changed
|
|
- "server_metadata.server.metadata == {'test_key': 'test_value_2', 'second_key':
|
|
'second_value'}"
|
|
|
|
- name: Update metadata again
|
|
openstack.cloud.server_metadata:
|
|
cloud: "{{ cloud }}"
|
|
name: "{{ server.server.id }}"
|
|
meta:
|
|
test_key: test_value_2
|
|
register: server_metadata
|
|
|
|
- name: Assert not changed
|
|
assert:
|
|
that:
|
|
- server_metadata is not changed
|
|
- "server_metadata.server.metadata == {'test_key': 'test_value_2', 'second_key':
|
|
'second_value'}"
|
|
|
|
- name: Delete server metadata
|
|
openstack.cloud.server_metadata:
|
|
cloud: "{{ cloud }}"
|
|
name: "{{ server.server.id }}"
|
|
state: absent
|
|
meta:
|
|
test_key:
|
|
register: server_metadata
|
|
|
|
- name: Assert updated metadata
|
|
assert:
|
|
that:
|
|
- server_metadata is changed
|
|
- "server_metadata.server.metadata == {'second_key': 'second_value'}"
|
|
|
|
- name: Delete server metadata again
|
|
openstack.cloud.server_metadata:
|
|
cloud: "{{ cloud }}"
|
|
name: "{{ server.server.id }}"
|
|
state: absent
|
|
meta:
|
|
test_key:
|
|
register: server_metadata
|
|
|
|
- name: Assert not changed
|
|
assert:
|
|
that:
|
|
- server_metadata is not changed
|
|
- "server_metadata.server.metadata == {'second_key': 'second_value'}"
|
|
|
|
- name: Delete test server
|
|
openstack.cloud.server:
|
|
cloud: "{{ cloud }}"
|
|
name: "{{ server.server.id }}"
|
|
state: absent
|
|
wait: true
|
|
register: server
|