Hey Rob,
Well you definitely need a dynamic inventory which in case of AWS is provided by the ec2.py script. I guess you have already read on how to setup this, some helpful links below:
http://docs.ansible.com/ansible/intro_dynamic_inventory.html#example-aws-ec2-external-inventory-script
https://aws.amazon.com/blogs/apn/getting-started-with-ansible-and-dynamic-amazon-ec2-inventory-management/
So basically you download the script from https://raw.github.com/ansible/ansible/devel/contrib/inventory/ec2.py, make it executable and set it as /etc/ansible/hosts (please take backup first of your existing file). Then you just drop https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/ec2.ini to /etc/ansible/ec2.ini and you are good to go.
This is the way I have it set up. In this way I don’t even have to provide inventory file when I’m running some default stuff since Ansible by default reads the /etc/ansible/hots file. So instead:
$ ansible-playbook -i /some/inventory/path some-playbook.yml
I just run:
$ ansible-playbook some-playbook.yml
and Ansible understands by default that I want to run against the dynamic inventory.
So, this dynamic inventory will be the one that will provide you with all the groups you want to work with later. So after running your creation playbook for first time, next time you run a playbook it will have the new instances included in the inventory for you and nicely sorted under appropriate groups. There will be groups available for zones, subnets, security groups, tags etc etc etc. If you run the /etc/ansible/hosts file (which is actually the ec2.py script renamed in our case) manually, it will give you a screen output of the whole inventory including the groups you have on your disposal.
To conclude, you do not need inventory for your instance creation playbook but you DO need it for any other playbook you want to run against already created instances, like the config playbook for example.
Now about the variables. True you can set the variables in the group_vars but the problem is you need them to be dynamic, thus you need to modify them in runtime. So you can have some default valuse lets say in your group_vars file like:
var1: 1
and then change that accordingly depending on the env you are running against:
- set-fact:
var1: {%- if my_env|lower == ‘prod’ -%}5{%- endif -%}
OR you can have different set of variables per environment which might become more messy since you will have to maintain different files and possibly directories. That’s my recommendation was to keep it simple to start with and do it all in single playbook using the above logic. The bottom line is you will have to set those variable somewhere and somehow, it is up to you how you want to do it. Then later when you feel more comfortable with Ansible you might start braking it down to roles, dependencies, different inventory dirs per environment, upload it to GitHub etc etc etc.
Just my 2 cents.
Cheers,
Igor