# Configuring Ansible to run play books through a bastion host on aws/ec2

**URL:** <https://forum.ansible.com/t/configuring-ansible-to-run-play-books-through-a-bastion-host-on-aws-ec2/14496>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [February 5, 2014, 6:59pm UTC](https://forum.ansible.com/t/configuring-ansible-to-run-play-books-through-a-bastion-host-on-aws-ec2/14496 "2014-02-05T18:59:17Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [October 30, 2014, 7:31pm UTC](https://forum.ansible.com/t/configuring-ansible-to-run-play-books-through-a-bastion-host-on-aws-ec2/14496/21 "2014-10-30T19:31:15Z")

</div>

I submitted a PR a month or so ago as a possible solution to specifying bastion hosts via an inventory variable:

[https://github.com/ansible/ansible/pull/9122](https://github.com/ansible/ansible/pull/9122)

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [October 30, 2014, 8:59pm UTC](https://forum.ansible.com/t/configuring-ansible-to-run-play-books-through-a-bastion-host-on-aws-ec2/14496/22 "2014-10-30T20:59:47Z")

</div>

Commented on Matt’s PR, but I think this is a good start.

I have also mentioned recently (today) that adding ansible\_ssh\_args as an inventory variable is also fine with me, to override what might be set in ansible.cfg.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [October 30, 2014, 8:59pm UTC](https://forum.ansible.com/t/configuring-ansible-to-run-play-books-through-a-bastion-host-on-aws-ec2/14496/23 "2014-10-30T20:59:55Z")

</div>

i.e. let’s have both, if we want.

---

<div class="post-metadata">

**Author:** ![Matt\_Davis1](https://avatars.discourse-cdn.com/v4/letter/m/ebca7d/32.png) [@Matt\_Davis1](https://forum.ansible.com/u/Matt_Davis1)\
**Post date:** [November 4, 2014, 12:15am UTC](https://forum.ansible.com/t/configuring-ansible-to-run-play-books-through-a-bastion-host-on-aws-ec2/14496/24 "2014-11-04T00:15:36Z")

</div>

OK, [PR 9477](https://github.com/ansible/ansible/pull/9477) implements bastion host/port/user/key and ssh\_args as inventory vars…

---

<div class="post-metadata">

**Author:** ![Tennis\_Smith](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@Tennis\_Smith](https://forum.ansible.com/u/Tennis_Smith)\
**Post date:** [November 6, 2014, 9:06pm UTC](https://forum.ansible.com/t/configuring-ansible-to-run-play-books-through-a-bastion-host-on-aws-ec2/14496/25 "2014-11-06T21:06:45Z")

</div>

Damn. I just thought of something.

How will “ansible -m ping \<somewhere\_behind\_a\_bastion\_host\>” work?

Hope I’ve overlooked something, but that could be a snag.

-T

---

<div class="post-metadata">

**Author:** ![Matt\_Davis3](https://avatars.discourse-cdn.com/v4/letter/m/ad7895/32.png) [@Matt\_Davis3](https://forum.ansible.com/u/Matt_Davis3)\
**Post date:** [November 24, 2014, 8:05pm UTC](https://forum.ansible.com/t/configuring-ansible-to-run-play-books-through-a-bastion-host-on-aws-ec2/14496/26 "2014-11-24T20:05:15Z")

</div>

Sorry for going dark on this thread- I had my notification settings for both GG and Github pointing at a dead work email.

I’m sure ping wouldn’t work on a private host out of the box, though I suspect you can probably get it working with delegate\_to (or easily enhance it to work).

---

<div class="post-metadata">

**Author:** ![Tennis\_Smith](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@Tennis\_Smith](https://forum.ansible.com/u/Tennis_Smith)\
**Post date:** [November 25, 2014, 6:08pm UTC](https://forum.ansible.com/t/configuring-ansible-to-run-play-books-through-a-bastion-host-on-aws-ec2/14496/27 "2014-11-25T18:08:20Z")

</div>

Np, Matt,

Ok. That makes sense.

Thanks,  
-T

---

<div class="post-metadata">

**Author:** ![igorc](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/igorc/32/5491_2.png) [@igorc](https://forum.ansible.com/u/igorc)\
**Post date:** [December 26, 2014, 1:45am UTC](https://forum.ansible.com/t/configuring-ansible-to-run-play-books-through-a-bastion-host-on-aws-ec2/14496/28 "2014-12-26T01:45:44Z")

</div>

Matt, doesn’t this prevent you from using ec2 dynamic inventory? For me being unable to dynamically discover instances as they come and go in the VPC is huge limitation.

[Previous page](https://forum.ansible.com/t/configuring-ansible-to-run-play-books-through-a-bastion-host-on-aws-ec2/14496.md?page=1)
