different config per environnement

Hi,

I’m very new to ansible, my question seems
I’ve created a task that simply deploy phpmyadmin on a given webserver. The selected webserver was targeted by an inventory file. I’ve an inventory per environment, dev, stage, prod.
my directory layout follow the best practices (http://docs.ansible.com/playbooks_best_practices.html)

prod inventory

[phpmyadmin]
admin.myproject.com

and

dev inventory

[phpmyadmin]
localhost

That works well !

Now I want to configure phpmyadmin differently according to the environment, trought j2 templates, for example to disable login form on dev environment. But actually the task run the same on both.

  • name: Web | Configuration for Dev Environment
    action: template src=config.inc.php.j2 dest=/etc/phpmyadmin/config.inc.php

So, how to differentiate this task for each of my two environment ?

Regards,
David

i would do this in the template,either using groups or a group var

this is using a group named dev:
{% if ‘dev’ in group_names %}
stuff that disables login
{% endif %}
… rest of config

it’s works well, thanks

For others users that answers the same question :
I’ve just added a “dev” group to my inventory, containing my localhost. so with Brian’s tip, you can test if “dev” group exists during the play.

dev inventory

[phpmyadmin]
localhost

[dev]
localhost