Add some tests for take 2
This time testing the actual change.
Also added a missing update:true to earlier tests.
name_folder: '{{namespace}}stalks/bean'
name_dict: '{{namespace}}_dict'
name_array: '{{namespace}}_array'
+ name_array_of_dicts: '{{namespace}}_array_of_dicts'
name_ttls: '{{namespace}}_ttls'
dict_value:
foo: 'bar'
- 'one'
- 'two'
- 'three'
+ array_of_dicts_value:
+ - name: item-one
+ - name: item-two
+ - name: item-three
+
tasks:
- hashivault_delete:
secret: '{{name_root}}'
- name: Update new value in dictionary and detect change
hashivault_write:
+ update: True
secret: '{{name_dict}}'
data:
foo: 'bar'
data:
value: "{{array_value}}"
+ - name: Write array of dicts secret
+ hashivault_write:
+ update: True
+ secret: '{{name_array_of_dicts}}'
+ data:
+ value: "{{ array_of_dicts_value }}"
+ register: vault_write
+ - assert: { that: "{{vault_write.changed}} == True" }
+ - assert: { that: "{{vault_write.rc}} == 0" }
+
+ - name: Update again array of dicts secret and verify no change
+ hashivault_write:
+ update: True
+ secret: '{{name_array_of_dicts}}'
+ data:
+ value: "{{ array_of_dicts_value }}"
+ register: vault_write
+ - assert: { that: "{{vault_write.changed}} == False" }
+ - assert: { that: "{{vault_write.rc}} == 0" }
+
+ - name: Update new value in array of dicts and detect change
+ hashivault_write:
+ update: True
+ secret: '{{name_array_of_dicts}}'
+ data:
+ value:
+ - name: item-one
+ - name: item-two
+ - name: item-new
+ register: vault_write
+ - assert: { that: "{{vault_write.changed}} == True" }
+ - assert: { that: "'{{vault_write.msg}}' == 'Secret secret/{{name_array_of_dicts}} written'" }
+ - assert: { that: "{{vault_write.rc}} == 0" }
+
- name: Initial ttl values
hashivault_write:
update: True
