{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/13514","labels_url":"https://api.github.com/repos/ansible/ansible/issues/13514/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/13514/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/13514/events","html_url":"https://github.com/ansible/ansible/issues/13514","id":121662118,"number":13514,"title":"task entry environment: is not autotemplated","user":{"login":"nileshbits","id":14416783,"avatar_url":"https://avatars.githubusercontent.com/u/14416783?v=3","gravatar_id":"","url":"https://api.github.com/users/nileshbits","html_url":"https://github.com/nileshbits","followers_url":"https://api.github.com/users/nileshbits/followers","following_url":"https://api.github.com/users/nileshbits/following{/other_user}","gists_url":"https://api.github.com/users/nileshbits/gists{/gist_id}","starred_url":"https://api.github.com/users/nileshbits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nileshbits/subscriptions","organizations_url":"https://api.github.com/users/nileshbits/orgs","repos_url":"https://api.github.com/users/nileshbits/repos","events_url":"https://api.github.com/users/nileshbits/events{/privacy}","received_events_url":"https://api.github.com/users/nileshbits/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ansible/ansible/labels/bug_report","name":"bug_report","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/ansible/ansible/milestones/5","html_url":"https://github.com/ansible/ansible/milestones/v2","labels_url":"https://api.github.com/repos/ansible/ansible/milestones/5/labels","id":975800,"number":5,"title":"v2","description":null,"creator":{"login":"bcoca","id":836171,"avatar_url":"https://avatars.githubusercontent.com/u/836171?v=3","gravatar_id":"","url":"https://api.github.com/users/bcoca","html_url":"https://github.com/bcoca","followers_url":"https://api.github.com/users/bcoca/followers","following_url":"https://api.github.com/users/bcoca/following{/other_user}","gists_url":"https://api.github.com/users/bcoca/gists{/gist_id}","starred_url":"https://api.github.com/users/bcoca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcoca/subscriptions","organizations_url":"https://api.github.com/users/bcoca/orgs","repos_url":"https://api.github.com/users/bcoca/repos","events_url":"https://api.github.com/users/bcoca/events{/privacy}","received_events_url":"https://api.github.com/users/bcoca/received_events","type":"User","site_admin":false},"open_issues":28,"closed_issues":600,"state":"open","created_at":"2015-02-11T19:43:06Z","updated_at":"2015-12-12T05:11:32Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2015-12-11T08:33:32Z","updated_at":"2015-12-12T17:33:30Z","closed_at":null,"body":"The issue remarked here: https://github.com/ansible/ansible/issues/11912 seems to be back. I'm trying to use a variable in environment: field as follows:\r\n\r\n```\r\n- name: Run Django database migrations\r\n  django_manage:\r\n    command: migrate\r\n    app_path: \"{{ project_path }}\"\r\n    virtualenv: \"{{ virtualenv_path }}\"\r\n    settings: \"{{ django_settings_file }}\"\r\n  environment: django_environment\r\n  when: run_django_db_migrations is defined and run_django_db_migrations\r\n  tags: django.migrate\r\n```\r\nThe variable is defined in vars/main.yml as follows:\r\n```\r\ndjango_environment:\r\n  DJANGO_SETTINGS_MODULE: \"{{ django_settings_file }}\"\r\n  DJANGO_SECRET_KEY: \"{{ django_secret_key }}\"\r\n  STATIC_ROOT: \"{{ nginx_static_dir }}\"\r\n  DATABASE_USER: \"{{ db_user }}\"\r\n  DATABASE_PASSWORD: \"{{ db_password }}\"\r\n  EMAIL_HOST: \"{{ email_host|default(omit) }}\"\r\n  EMAIL_HOST_USER: \"{{ email_host_user|default(omit) }}\"\r\n  EMAIL_HOST_PASSWORD: \"{{ email_host_password|default(omit) }}\"\r\n  BROKER_URL: \"{{ broker_url|default(omit) }}\"\r\n```\r\nOn reaching this task, I get the following error:\r\n```\r\nfatal: [52.27.20.139]: FAILED! => {\"failed\": true, \"msg\": \"ERROR! environment must be a dictionary, received django_environment (<class 'ansible.parsing.yaml.objects.AnsibleUnicode'>)\"}\r\n```\r\nEven the documentation says this should work: http://docs.ansible.com/ansible/playbooks_environment.html\r\nLook at the code titled \"The environment can also be stored in a variable, and accessed like so:\"\r\n\r\nMy ansible version is as follows: (I just did an install from the git repo)\r\n```\r\nansible 2.1.0 (devel bd0f9a4afc) last updated 2015/12/11 05:46:08 (GMT +000)\r\n  lib/ansible/modules/core: (detached HEAD 0d23b3df52) last updated 2015/12/11 05:46:21 (GMT +000)\r\n  lib/ansible/modules/extras: (detached HEAD 51813e0033) last updated 2015/12/11 05:46:30 (GMT +000)\r\n  config file = /vagrant/ansible/ansible.cfg\r\n  configured module search path = Default w/o overrides\r\n```\r\nCould you please suggest me a workaround for the time being? Thank you! It's great to use Ansible, has saved me so much time I can't imagine. A few hours for a repeatable stack configuration is just beautiful!."},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/164170447","html_url":"https://github.com/ansible/ansible/issues/13514#issuecomment-164170447","issue_url":"https://api.github.com/repos/ansible/ansible/issues/13514","id":164170447,"user":{"login":"bcoca","id":836171,"avatar_url":"https://avatars.githubusercontent.com/u/836171?v=3","gravatar_id":"","url":"https://api.github.com/users/bcoca","html_url":"https://github.com/bcoca","followers_url":"https://api.github.com/users/bcoca/followers","following_url":"https://api.github.com/users/bcoca/following{/other_user}","gists_url":"https://api.github.com/users/bcoca/gists{/gist_id}","starred_url":"https://api.github.com/users/bcoca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcoca/subscriptions","organizations_url":"https://api.github.com/users/bcoca/orgs","repos_url":"https://api.github.com/users/bcoca/repos","events_url":"https://api.github.com/users/bcoca/events{/privacy}","received_events_url":"https://api.github.com/users/bcoca/received_events","type":"User","site_admin":false},"created_at":"2015-12-12T17:33:30Z","updated_at":"2015-12-12T17:33:30Z","body":"Use this:\r\n\r\n```environment: \"{{django_environment}}\"``` < it needs to be quoted\r\n\r\n`${django_environment}` is invalid in Ansible, `$django_environment` might have worked in older versions but they did not have the `environment` directive.\r\n\r\n`{django_environment}` is not an Ansible variable\r\n\r\nI've updated the docs to use the proper form, the bare variable should still work so I'm keeping the ticket open to figure out exactly what the issue is."}}