You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.4 KiB

  1. ---
  2. - name: create_role | Create a policy for the new role
  3. hashivault_policy_set:
  4. url: "{{ vault_leader_url }}"
  5. token: "{{ vault_root_token }}"
  6. ca_cert: "{{ vault_cert_dir }}/ca.pem"
  7. name: "{{ create_role_name }}"
  8. rules: >-
  9. {%- if create_role_policy_rules|d("default") == "default" -%}
  10. {{
  11. { 'path': {
  12. create_role_mount_path + '/issue/' + create_role_name: {'policy': 'write'},
  13. create_role_mount_path + '/roles/' + create_role_name: {'policy': 'read'}
  14. }} | to_json + '\n'
  15. }}
  16. {%- else -%}
  17. {{ create_role_policy_rules | to_json + '\n' }}
  18. {%- endif -%}
  19. - name: create_role | Create {{ create_role_name }} role in the {{ create_role_mount_path }} pki mount
  20. hashivault_write:
  21. url: "{{ vault_leader_url }}"
  22. token: "{{ vault_root_token }}"
  23. ca_cert: "{{ vault_cert_dir }}/ca.pem"
  24. secret: "{{ create_role_mount_path }}/roles/{{ create_role_name }}"
  25. data: |
  26. {%- if create_role_options|d("default") == "default" -%}
  27. {
  28. allow_any_name: true
  29. }
  30. {%- else -%}
  31. {{ create_role_options | to_json }}
  32. {%- endif -%}
  33. ## Userpass based auth method
  34. - include_tasks: gen_userpass.yml
  35. vars:
  36. gen_userpass_password: "{{ create_role_password }}"
  37. gen_userpass_policies: "{{ create_role_name }}"
  38. gen_userpass_role: "{{ create_role_name }}"
  39. gen_userpass_username: "{{ create_role_name }}"