mirror of
https://opendev.org/openstack/ansible-collections-openstack.git
synced 2026-03-26 21:43:02 +00:00
When creating a new object from file, a AttributeError is raised. This is caused because the sdk does not return anything when creating an object from a file. With this change, the `_create` function will always return an object. Closes-Bug: #2061604 Change-Id: I34cefd1bb10c6eef784e37d26122e5ed2c72488d
77 lines
2.0 KiB
YAML
77 lines
2.0 KiB
YAML
---
|
|
- name: Create container
|
|
openstack.cloud.object_container:
|
|
cloud: "{{ cloud }}"
|
|
state: present
|
|
name: ansible_container
|
|
|
|
- name: Create object from data
|
|
openstack.cloud.object:
|
|
cloud: "{{ cloud }}"
|
|
state: present
|
|
name: ansible_object
|
|
data: "this is a test"
|
|
container: ansible_container
|
|
register: object
|
|
|
|
- name: Assert return values of object module
|
|
assert:
|
|
that:
|
|
- object.object.id == "ansible_object"
|
|
# allow new fields to be introduced but prevent fields from being removed
|
|
- expected_fields|difference(object.object.keys())|length == 0
|
|
|
|
- name: Delete object
|
|
openstack.cloud.object:
|
|
cloud: "{{ cloud }}"
|
|
state: absent
|
|
name: ansible_object
|
|
container: ansible_container
|
|
|
|
- name: Create object from file
|
|
block:
|
|
- name: Create temporary data file
|
|
ansible.builtin.tempfile:
|
|
register: tmp_file
|
|
|
|
- name: Populate data file
|
|
ansible.builtin.copy:
|
|
content: "this is a test"
|
|
dest: "{{ tmp_file.path }}"
|
|
|
|
- name: Create object from data file
|
|
openstack.cloud.object:
|
|
cloud: "{{ cloud }}"
|
|
state: present
|
|
name: ansible_object
|
|
filename: "{{ tmp_file.path }}"
|
|
container: ansible_container
|
|
register: object
|
|
|
|
always:
|
|
- name: Remove temporary data file
|
|
ansible.builtin.file:
|
|
path: "{{ tmp_file.path }}"
|
|
state: absent
|
|
when: tmp_file is defined and 'path' in tmp_file
|
|
|
|
- name: Assert return values of object module
|
|
assert:
|
|
that:
|
|
- object.object.id == "ansible_object"
|
|
# allow new fields to be introduced but prevent fields from being removed
|
|
- expected_fields|difference(object.object.keys())|length == 0
|
|
|
|
- name: Delete object
|
|
openstack.cloud.object:
|
|
cloud: "{{ cloud }}"
|
|
state: absent
|
|
name: ansible_object
|
|
container: ansible_container
|
|
|
|
- name: Delete container
|
|
openstack.cloud.object_container:
|
|
cloud: "{{ cloud }}"
|
|
state: absent
|
|
name: ansible_container
|