{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/46096","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/46096/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/46096/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/46096/events","html_url":"https://github.com/ansible/ansible/issues/46096","id":363318319,"node_id":"MDU6SXNzdWUzNjMzMTgzMTk=","number":46096,"title":"variables in group_vars and host_vars do not load when using inventory directory","user":{"login":"programingnotes","id":38335185,"node_id":"MDQ6VXNlcjM4MzM1MTg1","avatar_url":"https://avatars2.githubusercontent.com/u/38335185?v=4","gravatar_id":"","url":"https://api.github.com/users/programingnotes","html_url":"https://github.com/programingnotes","followers_url":"https://api.github.com/users/programingnotes/followers","following_url":"https://api.github.com/users/programingnotes/following{/other_user}","gists_url":"https://api.github.com/users/programingnotes/gists{/gist_id}","starred_url":"https://api.github.com/users/programingnotes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/programingnotes/subscriptions","organizations_url":"https://api.github.com/users/programingnotes/orgs","repos_url":"https://api.github.com/users/programingnotes/repos","events_url":"https://api.github.com/users/programingnotes/events{/privacy}","received_events_url":"https://api.github.com/users/programingnotes/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-09-24T20:59:14Z","updated_at":"2018-09-24T21:08:12Z","closed_at":null,"author_association":"NONE","body":"##### SUMMARY\r\nWhen following a directory structure that [mimics the one in docs](https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html#alternative-directory-layout), variables in `group_vars` and `host-vars` are not loaded. \r\n\r\n##### ISSUE TYPE\r\n- Bug Report\r\n\r\n##### COMPONENT NAME\r\n`user` module\r\n\r\n##### ANSIBLE VERSION\r\n<!--- Paste verbatim output from \"ansible --version\" between quotes -->\r\n```paste below\r\nansible 2.6.3\r\n  config file = /Users/pnotes/.ansible.cfg\r\n  configured module search path = ['/Users/pnotes/.ansible/plugins/modules, /usr/share/ansible/plugins/modules, /Users/pnotes/Code/Ansible']\r\n  ansible python module location = /Users/pnotes/.pyenv/versions/3.6.4/lib/python3.6/site-packages/ansible\r\n  executable location = /Users/pnotes/.pyenv/versions/3.6.4/bin/ansible\r\n  python version = 3.6.4 (default, Feb 26 2018, 21:07:35) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)]\r\n```\r\n\r\n##### CONFIGURATION\r\n<!--- Paste verbatim output from \"ansible-config dump --only-changed\" between quotes -->\r\n```paste below\r\nDEFAULT_MODULE_PATH(/Users/pnotes/.ansible.cfg) = ['/Users/pnotes/.ansible/plugins/modules, /usr/share/ansible/plugin\r\n```\r\n\r\n##### OS / ENVIRONMENT\r\n<!--- Provide all relevant information below, e.g. target OS versions, network device firmware, etc. -->\r\ntarget OS version: Ubuntu 16.04\r\n\r\n##### STEPS TO REPRODUCE\r\n<!--- Describe exactly how to reproduce the problem, using a minimal test-case -->\r\nGiven this directory structure:\r\n```\r\n├── ansible.cfg\r\n├── inventories\r\n│   └── test\r\n│       ├── group_vars\r\n│       │   └── all.yml\r\n│       ├── host_vars\r\n│       │   └── all.yml\r\n│       └── hosts.ini\r\n├── provision.yml\r\n└── roles\r\n    └── create-admin-user\r\n        ├── handlers\r\n        │   └── main.yml\r\n        └── tasks\r\n            └── main.yml\r\n```\r\n\r\n> Note that is directory layout follows that given in the [docs](https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html#alternative-directory-layout)\r\n\r\n\r\nAnd a task defined like so:  \r\n```\r\n- name: Create the non-root user account \r\n  user:\r\n    name: \"{{ admin_user.name }}\"\r\n    password: \"{{ admin_user.password | password_hash('sha512') }}\"\r\n    update_password: on_create\r\n    group: sudo\r\n    groups: sudo\r\n    append: yes\r\n    create_home: yes\r\n    shell: /bin/bash\r\n```\r\n\r\n\r\nI expect the task, **create-admin-user**, defined above to pick variables defined in `inventories/test/group_vars/all.yml`  and `inventories/test/host_vars/all.yml`  but the error message which is returned when I run `ansible-playbook -i inventories/test/hosts.ini provision.yml` indicates that it does not: \r\n```\r\nTASK [create-admin-user : Create the non-root user account] ********************\r\nfatal: [415.791.30.131]: FAILED! => {\"msg\": \"The task includes an option with an \r\nundefined variable. \r\nThe error was: 'admin_user' is undefined\\n\\nThe error appears to have been in '/Users/pnotes/Code/terraform/pj1/ansi/roles/create-admin-user/tasks/main.yml':\r\n line 2, column 3, but may\\nbe elsewhere in the file depending on the exact syntax \r\nproblem.\\n\\nThe offending line appears to be:\\n\\n---\\n- name: Task 1\\n  ^ here\\n\"}\r\n```\r\n\r\n##### EXPECTED RESULTS\r\nI expect admin_user.name to be picked up and evaluated correctly. \r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/424125550","html_url":"https://github.com/ansible/ansible/issues/46096#issuecomment-424125550","issue_url":"https://api.github.com/repos/ansible/ansible/issues/46096","id":424125550,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNDEyNTU1MA==","user":{"login":"ansibot","id":6585283,"node_id":"MDQ6VXNlcjY1ODUyODM=","avatar_url":"https://avatars0.githubusercontent.com/u/6585283?v=4","gravatar_id":"","url":"https://api.github.com/users/ansibot","html_url":"https://github.com/ansibot","followers_url":"https://api.github.com/users/ansibot/followers","following_url":"https://api.github.com/users/ansibot/following{/other_user}","gists_url":"https://api.github.com/users/ansibot/gists{/gist_id}","starred_url":"https://api.github.com/users/ansibot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansibot/subscriptions","organizations_url":"https://api.github.com/users/ansibot/orgs","repos_url":"https://api.github.com/users/ansibot/repos","events_url":"https://api.github.com/users/ansibot/events{/privacy}","received_events_url":"https://api.github.com/users/ansibot/received_events","type":"User","site_admin":false},"created_at":"2018-09-24T21:08:12Z","updated_at":"2018-09-24T21:08:12Z","author_association":"CONTRIBUTOR","body":"Files identified in the description:\n* [lib/ansible/modules/system/user.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/system/user.py)\n\nIf these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.\n\n[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)\n<!--- boilerplate: components_banner --->"}}
{"actor":{"display_login":"ansibot"}}