get value from command line in playbook

Hi

is there anyway i can get value from command line arguments

for eg., my command line is

ansible-playbook -i inv/sit1 playbooks/sit1/test.yml

in test.yml i want to capture the value from inv/sit1 as sit1,

There probably is a way to hack it

(e.g. inventory_file minus inventory_dir , see

    http://stackoverflow.com/questions/18839509/where-can-i-get-a-list-of-ansible-pre-defined-variables

)

but I've done this myself by just setting a common variable in
inv/*/group_vars/all
and referencing that.

Add a variable in your group vars for the environment you are targeting, e.g. Have a structure like

group_vars/
    prd.yml - variables for your production environment
    uat.yml - variables for your uat environment
    sit.yml - variables for your sit environment
    app.yml - application variables that cover your application valid across all environments
inventory.ini - your static inventory file that groups the hosts together

Use your inventory to define the group the host sits under so in the example above it will be a member of the app and one environment group (sit). This way you can access any variables that are set in that environment that you have defined which in your case would contain the environment name.