cyberark / ansible-security-automation-collection

CyberArk Ansible Security Automation Collection
MIT License
59 stars 37 forks source link

Add link account when creating account #45

Open AdamPeabody opened 2 years ago

AdamPeabody commented 2 years ago

I was wondering if there is way to link accounts when creating new objects in. For example login accounts.

jon4hz commented 1 year ago

This would be useful indeed.

As a workaround you can use ansibles uri module but I don't particularly like this solution. It's definitely more error prone than a solution built into the module. For example, I encountered some failure when I created a new account using cyberark.pas.cyberark_account with a management_action.

- name: Link logon account
  ansible.builtin.uri:
    method: POST
    url: "{{ cyberark_host }}/PasswordVault/API/Accounts/{{ new_account['result']['result']['id'] }}/LinkAccount"
    body_format: json
    body: "{\"safe\": \"{{ cyberark_logon_safe }}\", \"extraPasswordIndex\": \"{{ cyberark_logon_index }}\", \"name\": \"{{ cyberark_logon_name }}\", \"folder\": \"{{ cyberark_logon_folder }}\"}"
    headers:
      content_type: "application/json"
      Authorization: "{{ cyberark_session['token'] }}"
  when: not ansible_check_mode