Skip to content

Instantly share code, notes, and snippets.

@infamousjoeg
Last active October 17, 2023 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save infamousjoeg/870cbdb8c3ff16c2ad75704114bfd090 to your computer and use it in GitHub Desktop.
Save infamousjoeg/870cbdb8c3ff16c2ad75704114bfd090 to your computer and use it in GitHub Desktop.
Ansible Playbook using cyberark.conjur.conjur_variable to retrieve secrets from CyberArk Conjur
extra_vars:
CONJUR_ACCOUNT: '{{ conjur_account }}'
CONJUR_APPLIANCE_URL: '{{ conjur_appliance_url }}'
CONJUR_AUTHN_LOGIN: '{{ conjur_authn_login }}'
CONJUR_AUTHN_API_KEY: '{{ conjur_authn_api_key }}'
fields:
- id: conjur_authn_login
type: string
label: Workload Identity
help_text: Conjur Workload ID (e.g. host/...)
- id: conjur_authn_api_key
type: string
label: API Key
secret: true
help_text: The API key that corresponds to the Conjur host username
- id: conjur_account
type: string
label: Conjur Account
help_text: The Conjur account name (For Conjur Cloud it is conjur)
- id: conjur_appliance_url
type: string
label: Conjur Appliance URL
help_text: URL of the running Conjur service
required:
- conjur_authn_login
- conjur_authn_api_key
- conjur_account
- conjur_appliance_url
---
- hosts: all
tasks:
- set_fact:
ansible_ssh_private_key_file: "{{ lookup('cyberark.conjur.conjur_variable', 'SyncVault/LOB_CD/D-Nix-AWS-EC2-Keypairs/Operating System-UnixSSHKeys-' + inventory_hostname + '-ec2-user/password', as_file=True) }}"
#ansible_ssh_pass: "{{ lookup('cyberark.conjur.conjur_variable', 'SyncVault/LOB_CD/D-Nix-Root/Operating System-UnixSSH-' + inventory_hostname + '-root/password') }}"
delegate_to: localhost
no_log: yes
- ansible.builtin.shell: hostname
---
- hosts: localhost
tasks:
- name: Fetch secret from CyberArk Conjur and print to stdout
debug:
msg: "The secret is: {{ lookup('cyberark.conjur.conjur_variable', 'data/vault/ConjurCloudTestSafe/conjurtestaccount/password') }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment