Done use reserved word name for var
- hosts: localhost
gather_facts: no
vars:
- name: 'terry'
+ namespace: 'terry'
rules: >
- path "secret/{{name}}/*" {
+ path "secret/{{namespace}}/*" {
capabilities = ["create", "read", "update", "delete", "list"]
}
- path "secret/{{name}}" {
+ path "secret/{{namespace}}" {
capabilities = ["list"]
}
expected: "{{rules | regex_replace('\n', '')}}"
tasks:
- hashivault_policy_set:
- name: "{{name}}"
+ name: "{{namespace}}"
rules: "{{rules}}"
register: 'vault_policy_set'
- assert: { that: "{{vault_policy_set.changed}} == True" }
- assert: { that: "{{vault_policy_set.rc}} == 0" }
- hashivault_policy_get:
- name: '{{name}}'
+ name: '{{namespace}}'
register: 'vault_policy_get'
- assert: { that: "{{vault_policy_get.changed}} == False" }
- set_fact:
- hashivault_policy_list:
register: 'vault_policy_list'
- assert: { that: "{{vault_policy_list.changed}} == False" }
- - fail: msg="policy {{name}} not in list"
- when: name not in vault_policy_list.policies
+ - fail: msg="policy {{namespace}} not in list"
+ when: namespace not in vault_policy_list.policies
- assert: { that: "{{vault_policy_list.rc}} == 0" }
- hashivault_policy_delete:
- name: '{{name}}'
+ name: '{{namespace}}'
register: 'vault_policy_delete'
- assert: { that: "{{vault_policy_delete.changed}} == True" }
- assert: { that: "{{vault_policy_delete.rc}} == 0" }
- hashivault_policy_list:
register: 'vault_policy_list'
- assert: { that: "{{vault_policy_list.changed}} == False" }
- - fail: msg="policy {{name}} in list"
- when: name in vault_policy_list.policies
+ - fail: msg="policy {{namespace}} in list"
+ when: namespace in vault_policy_list.policies
- assert: { that: "{{vault_policy_list.rc}} == 0" }
