Running playbook ios_command through bastion host

294 views
Skip to first unread message

Bharath Bharadwaj

unread,
Aug 18, 2016, 12:41:38 PM8/18/16
to Ansible Project
Hi All,

I have followed instructions on setting up bastion host from this article "https://gagor.pl/2016/04/use-bastion-host-with-ansible/" while I'm able to connect to my cisco switch through bastion host from a command line by executing "ssh -F ssh_config bastion" from the playbook I can't make it go through the bastion host, it still continues to connect directly to the switch, attached below is my playbook.

---

 - hosts: gatewayed
   remote_user: root
   become: yes
   connection: local
   gather_facts: false

   tasks:
    - name: Get show version on ios device
      vars:
        cli:
          transport: cli
      ios_command:
        commands: show version
        host: "{{ inventory_hostname }}"
        provider: "{{ cli }}"
        username: test
        password: test@123

Bharath Bharadwaj

unread,
Aug 23, 2016, 2:06:00 AM8/23/16
to Ansible Project
Hi, can anyone give a help on this?

Kai Stian Olstad

unread,
Aug 23, 2016, 4:11:42 AM8/23/16
to ansible...@googlegroups.com
On 17. aug. 2016 12:21, Bharath Bharadwaj wrote:
> Hi All,
>
> I have followed instructions on setting up bastion host from this article
> "https://gagor.pl/2016/04/use-bastion-host-with-ansible/" while I'm able to
> connect to my cisco switch through bastion host from a command line by
> executing "ssh -F ssh_config bastion" from the playbook I can't make it go
> through the bastion host, it still continues to connect directly to the
> switch, attached below is my playbook.
>
> ---
>
> - hosts: gatewayed
> remote_user: root
> become: yes
> connection: local

connection: local means, run everything on local machine, I guess that's
not what you want.

I dont't think IOS has sudo/su, so become: yes might not work either.


--
Kai Stian Olstad

Bharath Bharadwaj

unread,
Aug 23, 2016, 8:15:13 AM8/23/16
to Ansible Project, ansible-pr...@olstad.com
Thanks,

what should i set the connection as to make sure it goes through the bastion host? I have already setup the ssh config and ansible.cfg with the ssh args, since you mentioned connection= local it won't go from bastion, i want to change this to go through bastion host.

Thank you.

Kai Stian Olstad

unread,
Aug 23, 2016, 8:50:30 AM8/23/16
to ansible...@googlegroups.com
On 23. aug. 2016 14:15, Bharath Bharadwaj wrote:
> Thanks,
>
> what should i set the connection as to make sure it goes through the
> bastion host? I have already setup the ssh config and ansible.cfg with the
> ssh args, since you mentioned connection= local it won't go from bastion, i
> want to change this to go through bastion host.

ssh which is the default so just remove or comment out the line.

--
Kai Stian Olstad

Bharath Bharadwaj

unread,
Aug 23, 2016, 10:08:33 AM8/23/16
to Ansible Project, ansible-pr...@olstad.com
Thank you!

It was ssh by default, it is just I did not have paramiko installed on my jump host, once that was done the connectivity was successful.

Regards,
Reply all
Reply to author
Forward
0 new messages