selivan / ansible-ssh Goto Github PK
View Code? Open in Web Editor NEWScript to connect to managed hosts using Ansible inventory and config.
License: Other
Script to connect to managed hosts using Ansible inventory and config.
License: Other
Just FYI you can greatly simplify this code by using jq features better ;-) Raw mode will drop the quotes, and you can specify an alternative value for a null result. Seems like you want no value, so ...
ansible_ssh_host=$(echo "$inventory" | jq -r '.ansible_ssh_host? // empty')
Using single quotes around the .jq query will prevent metacharacters from being interpreted by the shell
I updated Ansible recently (brew on mac) and noticed that my ssh_executable is now empty and thus it fails;
ansible-ssh prd-jira
ssh_args:
ssh_executable:
ansible_host: 1.2.3.4
ansible_user: root
ansible_port: 22
ansible_ssh_private_key_file:
ansible_ssh_common_args:
ansible_ssh_extra_args:
result command: [email protected] -p 22
/Users/tomextel/git/ansible-supporting-files/ansible-ssh: line 87: exec: [email protected]: not found
This var is retrieved from "ansible-config dump" but it does (no longer) have any ssh settings weirdly enough.
I could change my ansible.cfg in each directory but i'd rather not. Current config;
retry_files_enabled = False
inventory = ./hosts
roles_path=./roles
become_method=sudo
become_user=root
[ssh_connection]
pipelining = True
ssh_args = -o ControlMaster=auto -o ControlPersist=30m -o ConnectionAttempts=100
Ansible version:
ansible --version
ansible [core 2.11.0]
config file = /Users/tomextel/git/ansible-playbooks-deheus/ansible.cfg
configured module search path = ['/Users/tomextel/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/Cellar/ansible/4.0.0/libexec/lib/python3.9/site-packages/ansible
ansible collection location = /Users/tomextel/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible
python version = 3.9.5 (default, May 4 2021, 03:36:27) [Clang 12.0.0 (clang-1200.0.32.29)]
jinja version = 3.0.1
libyaml = True
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.
Before #2 This one works, but it's ugly.
subj
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.