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.

30 lines
1.1 KiB

  1. ---
  2. - name: shared/gen_userpass | Create the Username/Password combo for the role
  3. uri:
  4. url: "{{ hostvars[groups.vault|first]['vault_leader_url'] }}/v1/auth/userpass/users/{{ gen_userpass_username }}"
  5. headers: "{{ hostvars[groups.vault|first]['vault_headers'] }}"
  6. method: POST
  7. body_format: json
  8. body:
  9. username: "{{ gen_userpass_username }}"
  10. password: "{{ gen_userpass_password }}"
  11. policies: "{{ gen_userpass_role }}"
  12. status_code: 204
  13. when: inventory_hostname == groups[gen_userpass_group]|first
  14. - name: shared/gen_userpass | Ensure destination directory exists
  15. file:
  16. path: "{{ vault_roles_dir }}/{{ gen_userpass_role }}"
  17. state: directory
  18. when: inventory_hostname in groups[gen_userpass_group]
  19. - name: shared/gen_userpass | Copy credentials to all hosts in the group
  20. copy:
  21. content: >
  22. {{
  23. {'username': gen_userpass_username,
  24. 'password': gen_userpass_password} | to_nice_json(indent=4)
  25. }}
  26. dest: "{{ vault_roles_dir }}/{{ gen_userpass_role }}/userpass"
  27. when: inventory_hostname in groups[gen_userpass_group]