# how to set defaults for ec2\_facts when not in AWS ???

**URL:** <https://forum.ansible.com/t/how-to-set-defaults-for-ec2-facts-when-not-in-aws/15280>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [May 20, 2014, 2:59pm UTC](https://forum.ansible.com/t/how-to-set-defaults-for-ec2-facts-when-not-in-aws/15280 "2014-05-20T14:59:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicolas\_G](https://avatars.discourse-cdn.com/v4/letter/n/a183cd/32.png) [@Nicolas\_G](https://forum.ansible.com/u/Nicolas_G)\
**Post date:** [May 20, 2014, 2:59pm UTC](https://forum.ansible.com/t/how-to-set-defaults-for-ec2-facts-when-not-in-aws/15280/1 "2014-05-20T14:59:33Z")

</div>

Hi,

We have our ansible playbooks working with no problem to deploy our servers in Amazon ec2. One of the ansible modules we use is the ec2\_facts in order to configure some files , as for example we use the {{ ansible\_ec2\_placement\_availability\_zone }} value.

There is a chance we need to deploy some of our servers on a different cloud provider or on bare metal servers, in that case the ec2\_facts module will fail.

I know I could just add an ignore\_errors on the ec2\_facts task but we need to make sure when in AWS environment the ec2\_facts are populated successfully so I’m wondering how can we set default values when we run a playbook in a non AWS environment ?

For example I would like to set the bellow without using “when:” or specifying in advance if the inventory hosts are in ec2 or not :

ansible\_ec2\_placement\_availability\_zone : NA

Any ideas ?

Regards,  
N.

---

<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:** [May 21, 2014, 10:00pm UTC](https://forum.ansible.com/t/how-to-set-defaults-for-ec2-facts-when-not-in-aws/15280/2 "2014-05-21T22:00:39Z")

</div>

“There is a chance we need to deploy some of our servers on a different cloud provider or on bare metal servers, in that case the ec2\_facts module will fail.”

I would consider constraining the ec2 configuration items to a specific role and maybe do:

- hosts: ec2\_webservers  
roles:
