selivan / ansible-ssh

Script to connect to managed hosts using Ansible inventory and config.
Other
61 stars 13 forks source link

Support inventory scripts #4

Closed obilodeau closed 4 years ago

obilodeau commented 4 years ago

Very nice script btw! I like it very much.

It would be nice if ansible-ssh supported ansible inventory scripts. I did the following hack in my locally installed ansible-ssh:

--- /home/olivier/bin/ansible-ssh.orig  2020-10-01 15:50:55.782872483 -0400
+++ /home/olivier/bin/ansible-ssh   2020-10-01 15:50:29.619670838 -0400
@@ -27,7 +27,7 @@
 # All other arguments are ssh arguments
 shift

-inventory=$(ansible-inventory --host "$host")
+inventory=$(ansible-inventory -i ansible/terraform.py --host "$host")
 if [ $? -ne 0 ]; then
     echo "ERROR: ansible inventory failed to gather info on $host"
     exit 1

However, adding a -i flag before the hostname to pass in the ansible inventory script (in my case ansible/terraform.py) would make it more properly supported. I'm willing to submit a PR but would like to know if you are interested in such a change first.

selivan commented 4 years ago

Thank you for interest in this script, I would welcome that PR.

obilodeau commented 4 years ago

Submitted #6