Hi Olga,

There are two options:

* Using vars_files
http://docs.ansible.com/playbooks_variables.html#variable-file-separation

    - hosts: all
      vars_files:
         - "{{ deployment_env}}.yml"

* You can keep environment specific variables separately
http://docs.ansible.com/intro_inventory.html#splitting-out-host-and-group-specific-data

inventory
├── production
│   ├── group_vars
│   │   ├── all
│   │   │   ├── common.yml     <- variables for all productions servers
│   │   │   └── secret.yml     <- secrets for production
│   │   └── db
│   │       ├── common.yml     <- variables for static-ip group
│   │       └── secret.yml     <- secrets for static-ip group in production env
│   └── hosts                  <- inventory file production
├── staging
│   ├── group_vars
│   │   └── all
│   │       └── common.yml
│   └── hosts                 <- inventory file for staging
└── development
    └── hosts

Please have a look at awesome presentations
https://speakerdeck.com/slok/ansible-all-the-things pages 120-127
specifically


-- Best, Igor



On Thu, Sep 25, 2014 at 10:58 PM, olga <[email protected]> wrote:
> Hi,
>
> I have a play book to deploy the DB scripts. I also have multiple env like
> dev,qa & prod. The deployment has a template with few variables like
> db_user_name and password. I have created the vars file for each env and
> inventory hosts per env. How do I specify the vars file based on the env I'm
> deploying. Do we have option to specify the vars file in command line
> option.
>
> Sorry, if this is a silly question.
>
> Thanks,
> olga
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/4075c459-f2f7-4424-96d8-c53cc66f2489%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAGuansoqG%2B2ew15YtjPGOsfC2-%3DkzcRkYX%2B_Ov%3DYNNeZJg3sBA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to