i have to playbook for tower-cli command, which will create credentials with custom credentials type.
- name: Create a valid SCM credential from a private_key file
shell:
cmd: tower-cli credential create --organization "Default" --name "DevOps User" --credential-type "csa-test2" --inputs "{'user':'devops','stg01_ssh_key':"$( sed -z 's/
/\n/g' test.pem )"}"
no_log: false
This code is working prefectly, ssh file is aligned in the correct format.
As my code is quite messy, i added the sed command as variable, and passed that variable to cmd module like below.
---
- name: Trigger an Atower API
hosts: localhost
connection: local
vars:
keyy: $( sed -z 's/^//' test.pem )
tasks:
- name: Create a valid SCM credential from a private_key file
shell:
cmd: tower-cli credential create --organization "Default" --name "DevOps User" --credential-type "csa-test2" --inputs "{'user':'devops','stg01_ssh_key':'{{ keyy }}'}"
no_log: false
SSH file is not aligned like before input. To do this alignment i have used the sed command. What I am doing wrong here?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…