2017-02-08 21:41:36 +00:00
|
|
|
---
|
|
|
|
# The JSON inside JSON here is intentional (Vault API wants it)
|
|
|
|
- name: create_role | Create a policy for the new role allowing issuing
|
|
|
|
uri:
|
|
|
|
url: "{{ hostvars[groups.vault|first]['vault_leader_url'] }}/v1/sys/policy/{{ create_role_name }}"
|
|
|
|
headers: "{{ hostvars[groups.vault|first]['vault_headers'] }}"
|
|
|
|
method: PUT
|
|
|
|
body_format: json
|
|
|
|
body:
|
|
|
|
rules: >-
|
|
|
|
{%- if create_role_policy_rules|d("default") == "default" -%}
|
|
|
|
{{
|
|
|
|
{ 'path': {
|
2017-08-30 13:03:22 +00:00
|
|
|
create_role_mount_path + '/issue/' + create_role_name: {'policy': 'write'},
|
|
|
|
create_role_mount_path + '/roles/' + create_role_name: {'policy': 'read'}
|
2017-02-08 21:41:36 +00:00
|
|
|
}} | to_json + '\n'
|
|
|
|
}}
|
|
|
|
{%- else -%}
|
|
|
|
{{ create_role_policy_rules | to_json + '\n' }}
|
|
|
|
{%- endif -%}
|
|
|
|
status_code: 204
|
2017-09-05 08:05:06 +00:00
|
|
|
delegate_to: "{{ groups.vault|first }}"
|
|
|
|
run_once: true
|
2017-02-08 21:41:36 +00:00
|
|
|
|
2017-09-01 19:51:37 +00:00
|
|
|
- name: create_role | Create {{ create_role_name }} role in the {{ create_role_mount_path }} pki mount
|
2017-02-08 21:41:36 +00:00
|
|
|
uri:
|
2017-08-30 13:03:22 +00:00
|
|
|
url: "{{ hostvars[groups.vault|first]['vault_leader_url'] }}/v1/{{ create_role_mount_path }}/roles/{{ create_role_name }}"
|
2017-02-08 21:41:36 +00:00
|
|
|
headers: "{{ hostvars[groups.vault|first]['vault_headers'] }}"
|
|
|
|
method: POST
|
|
|
|
body_format: json
|
|
|
|
body: >-
|
|
|
|
{%- if create_role_options|d("default") == "default" -%}
|
|
|
|
{'allow_any_name': true}
|
|
|
|
{%- else -%}
|
|
|
|
{{ create_role_options }}
|
|
|
|
{%- endif -%}
|
|
|
|
status_code: 204
|
2017-09-05 08:05:06 +00:00
|
|
|
delegate_to: "{{ groups.vault|first }}"
|
|
|
|
run_once: true
|
2017-02-08 21:41:36 +00:00
|
|
|
|
|
|
|
## Userpass based auth method
|
|
|
|
|
|
|
|
- include: gen_userpass.yml
|
|
|
|
vars:
|
2017-09-01 19:51:37 +00:00
|
|
|
gen_userpass_password: "{{ create_role_password }}"
|
2017-02-08 21:41:36 +00:00
|
|
|
gen_userpass_policies: "{{ create_role_name }}"
|
|
|
|
gen_userpass_role: "{{ create_role_name }}"
|
|
|
|
gen_userpass_username: "{{ create_role_name }}"
|