We are the AWX team and are working on integrating SSH key management with CyberArk. Our goal is to extract an SSH private key and a CA-signed certificate from CyberArk, and use them as credentials in AWX to connect to Linux AWS servers.
The problem:
When we extract the SSH private key from CyberArk, the key comes as a string with \n characters (escaped newlines), which causes issues when using it as a credential in AWX/Ansible.
We need a reliable way to extract the private key and certificate from CyberArk, convert them to the correct format, and use them in AWX as SSH credentials.
Questions:
What is the best way to process the CyberArk API response so that the SSH private key and certificate are in the correct format for use with AWX/Ansible?
Are there any recommended Ansible modules or filters to handle this conversion automatically?
Has anyone automated this workflow and can share best practices or example playbooks/script
Not sure if it helps or even applies to your situation, as I don’t use Cyberark, but when extracting SSH keys from the AWS Secrets Manager I have the same issue.
Could you describe exactly how you’re doing it ?
Do you create a Machine Credential for your SSH Key and use the External Secret Management System functionality ?
Or do you use a lookup to pass the value to ansible_ssh_private_key_file ?
Are you using CyberArk CCP or Conjur ?
On our side, we created a custom credential to feed the EE with the necessary variable to reach Conjur, and then used the conjur_variable lookup to pass the value to ansible_ssh_private_key (using the as_file parameter). There are a few other things around that, but that’s the idea.
You could directly pass the result in blockinfile or in a template for example. (but I think that it’s a bit off-topic, the post was specifically about AWX).
I do so in many scenarios, but the fact that lookups run on the host instead of the target was complicating things as I tried to build out a solution.
IIRC I needed to be able to specify the profile when I was running it from my computer, but then when running the script locally on the target (initial build of an auto scaling group replacement) the profile was breaking things.
I might circle back around to see if I can conditionally use the profile, but the complexity of that while trying to learn how to do everything else was too much for me to tackle all at once.
And I just realized that I need a better threaded view of the conversation because you were probably not responding to my post but the initial request.