- Passwords, not keys are used for ssh
- The target is accessed via the bastion host (ssh -> bastion -> target)
- The password is kept in an encrypted file that is accessed based on the
ansible_user
name - When decrypted, the password is
bastion
$ ansible -i ./inventory/debug -m debug -a 'var=foo' -kKu ansible all
target | FAILED! => {
"msg": "The field 'ssh_common_args' has an invalid value, which includes an undefined variable. The error was: 'ansible_user' is undefined"
}
bastion | SUCCESS => {
"foo": "-o ProxyCommand=\"sshpass -p bastion ssh -o StrictHostKeyChecking=no -W %h:%p -q [email protected].\""
}
- The password is correctly accessed and resolved for
foo
forbastion
, butfoo
cannot be resolved for the target host.
all:
vars:
env: 3.21.247.xxx
password: "{{lookup('file', inventory_dir + '/../users/' + ansible_user + '.yml')}}"
foo: "-o ProxyCommand=\"sshpass -p {{password}} ssh -o StrictHostKeyChecking=no -W %h:%p -q ansible@{{env}}.\""
children:
bastions:
hosts:
bastion:
ansible_host: "{{ env }}"
nv:
children:
targets:
hosts:
target:
ansible_host: 10.0.3.209
vars:
ansible_ssh_common_args: "{{ foo }}"