---- name: test through bastion-host, show version hosts: ios gather_facts: false connection: network_cli tasks: - name: show version ios_command: commands: - show version register: version_out
- debug: var: version_out[ios]xxx.xxx.1.xxx
[ios:vars]ansible_user=ciscoansible_password=ciscoansible_become_pass=cisco[defaults]host_key_checking = Falsescp_if_ssh = True
[paramiko_connection]host_key_auto_add = Truelook_for_keys = Falsehost_key_checking = False
[ssh_connection]ssh_args = -F /home/<MY_USER>/projects/ansible/development/ssh.cfg -o ControlMaster=auto -o ControlPersist=15m -o StrictHostKeyChecking=no -o USerKnownHostsFile=/dev/nullcontrol_path = /tmp/ansible-%%r@%%h:%%p
Host xxx.xxx.xxx.55* Hostname xxx.xxx.xxx.55 Port 10015 User <BASTION_HOST_USERNAME> TCPKeepAlive yes ControlMaster auto ControlPath ~/.ssh/ansible-%r%h:%p ControlPersist 15m StrictHostKeyChecking no ProxyCommand none LogLevel Error
Host xxx.xxx.1.* User cisco StrictHostKeyChecking no ProxyCommand ssh -p 10015 -q -A -W %h:%p <BASTION_HOST_USERNAME>@xxx.xxx.xxx.55 -v
Host *
ProxyCommand none
Port 22
StrictHostKeyChecking noansible_become: yesansible_become_method: enableansible_connection: network_cliansible_python_interpreter: "/home/<MY_USER>/projects/ansible/python-3.6-ansible/bin/python"
ansible_network_os: ios
(python-3.6-ansible) [<USER>@<DEVICE> development]$ ansible-playbook test-bacchus.yml -i hosts.virl -vvvvvvvansible-playbook 2.9.7 config file = /home/<USERNAME>/projects/ansible/development/ansible.cfg configured module search path = ['/home/<USERNAME>/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /home/<USERNAME>/projects/ansible/python-3.6-ansible/lib/python3.6/site-packages/ansible executable location = /home/<USERNAME>/projects/ansible/python-3.6-ansible/bin/ansible-playbook python version = 3.6.8 (default, Nov 27 2019, 14:21:59) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39.0.1)]Using /home/<USERNAME>/projects/ansible/development/ansible.cfg as config filesetting up inventory pluginshost_list declined parsing /home/<USERNAME>/projects/ansible/development/hosts.virl as it did not pass its verify_file() methodscript declined parsing /home/<USERNAME>/projects/ansible/development/hosts.virl as it did not pass its verify_file() methodauto declined parsing /home/<USERNAME>/projects/ansible/development/hosts.virl as it did not pass its verify_file() methodyaml declined parsing /home/<USERNAME>/projects/ansible/development/hosts.virl as it did not pass its verify_file() methodParsed /home/<USERNAME>/projects/ansible/development/hosts.virl inventory source with ini pluginLoading callback plugin default of type stdout, v2.0 from /home/<USERNAME>/projects/ansible/python-3.6-ansible/lib/python3.6/site-packages/ansible/plugins/callback/default.py
PLAYBOOK: test-bacchus.yml ********************************************************************************************************************************************************************************Positional arguments: test-bacchus.ymlverbosity: 7connection: smarttimeout: 10become_method: sudotags: ('all',)inventory: ('/home/<USERNAME>/projects/ansible/development/hosts.virl',)forks: 51 plays in test-bacchus.yml
PLAY [test bacchus show version] **************************************************************************************************************************************************************************META: ran handlers
TASK [show version] ***************************************************************************************************************************************************************************************task path: /home/<USERNAME>/projects/ansible/development/test-bacchus.yml:7<xxx.xxx.1.xxx> attempting to start connection<xxx.xxx.1.xxx> using connection plugin network_cli<xxx.xxx.1.xxx> local domain socket does not exist, starting it<xxx.xxx.1.xxx> control socket path is /home/<USERNAME>/.ansible/pc/c0bb744b49<xxx.xxx.1.xxx> local domain socket listeners started successfully<xxx.xxx.1.xxx> loaded cliconf plugin ios from path /home/<USERNAME>/projects/ansible/python-3.6-ansible/lib/python3.6/site-packages/ansible/plugins/cliconf/ios.py for network_os ios<xxx.xxx.1.xxx> <xxx.xxx.1.xxx> local domain socket path is /home/<USERNAME>/.ansible/pc/c0bb744b49fatal: [xxx.xxx.1.xxx]: FAILED! => { "changed": false, "msg": "timed out"}
PLAY RECAP ************************************************************************************************************************************************************************************************xxx.xxx.1.xxx : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0 [ios]
10.*.*.1
10.*.*.2
[ios:vars]
ansible_user=<username>
ansible_password=<password>
ansible_become_pass=<password>
ansible_network_os=ios
network_os=ios
ansible_ssh_common_args=" -o ProxyCommand=\"sshpass -p '<password_to_bastion>' ssh -q -W %h:%p <bastion_username>@<bastion_ip_or_dns\""