How to pass SSH user name and password using the Ansible pack #5432
-
Hi all, For example, I am running the following playbook with Ansible:
...... a long list of interfaces follows. What is the equivalent command in the st2 command line? I tried the following, which is not working properly, because I do not know how to pass the SSH credentials:
The playbook executes, but it is clearly not establishing the SSH connection to my switch. All the fields come empty. That's expected, because I did not provide the SSH credentials in the st2 command. There is a field to provide the user in the StackStorm Web UI, but not one for the SSH password. I tried using extra_vars, and pointing private_key to the location where my host keys are (it's /home/awxuser/.ssh/known_hosts in my setup). Nothing worked. I always get a response with empty fields. Any guidance on how to pass the SSH credentials will be appreciated. Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
Here is some additional information: after a change in the playbook to make it collect all data, now I am seeing a message about paramiko failing to authenticate the host: TASK [debug] ******************************************************************* I already added host_key_checking = False to the [defaults] section in ansible.cfg, and also removed and generated a new host key. The problem persists. I am using the following command line: st2 run ansible.playbook playbook=/home/awxuser/icx_facts.yml inventory_file="/home/awxuser/hosts" user=admin private_key=~/.ssh/known_hosts Thanks again! |
Beta Was this translation helpful? Give feedback.
-
Which ansible.cfg have you altered, is it for the user that StackStorm actions run as? Alternatively you could pass using the env parameter, e.g.
|
Beta Was this translation helpful? Give feedback.
-
Here is how to pass credentials using the command line (assuming they are not inside the playbook): |
Beta Was this translation helpful? Give feedback.
-
Hi, When I ran the workflow it complains a boolean value is not accepted: What is the correct syntax to add the environment variable in the UI? |
Beta Was this translation helpful? Give feedback.
-
easy fix. enclosed false in " " |
Beta Was this translation helpful? Give feedback.
Which ansible.cfg have you altered, is it for the user that StackStorm actions run as?
Alternatively you could pass using the env parameter, e.g.
st2 run ansible.playbook playbook=/home/awxuser/icx_facts.yml inventory_file="/home/awxuser/hosts" user=admin private_key=~/.ssh/known_hosts env='{"ANSIBLE_HOST_KEY_CHECKING":"False"}'