I have a custom SSH config file that I typically use as follows
ssh -F ~/.ssh/client_1_config amazon-server-01
Is it possible to assign Ansible to use this config for certain groups? It already has the keys and ports and users all set up. I have this sort of config for multiple clients, and would like to keep the config separate if possible.
Ansible will use your SSH config when using the ssh (not paramiko) transport, perhaps it's not finding it for some reason. paramiko would be the default if you were running from RHEL/CentOS 6 or before, where OpenSSH is not new enough to support ControlMaster, and paramiko is therefore still faster.
e.g. - name: change ssh ports tasks: - name: edit sshd_config lineinfile .. notify: restart ssh handlers: - name: restart ssh service: sshd state=restarted - name: continue setup vars: - ansible_ssh_port : 5422 tasks: ...
Not fully possible. You can set ssh arguments in the ansible.cfg
:
[ssh_connection] ssh_args = -F ~/.ssh/client_1_config amazon-server-01
Unfortunately it is not possible to define this per group, inventory or anything else specific.
With Ansible 2, you can set a ProxyCommand in the ansible_ssh_common_args inventory variable. Any arguments specified in this variable are added to the sftp/scp/ssh command line when connecting to the relevant host(s). Consider the following inventory group:
[gatewayed] foo ansible_host=192.0.2.1 bar ansible_host=192.0.2.2
You can create group_vars/gatewayed.yml with the following contents:
ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q [email protected]"'
and do the trick...
You can find further information in: http://docs.ansible.com/ansible/faq.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With