{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/14369","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/14369/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/14369/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/14369/events","html_url":"https://github.com/ansible/ansible/issues/14369","id":132150571,"number":14369,"title":"2.0.0.2 Loop Error AttributeError: 'list' object has no attribute 'startswith'","user":{"login":"diarworld","id":3768824,"avatar_url":"https://avatars.githubusercontent.com/u/3768824?v=3","gravatar_id":"","url":"https://api.github.com/users/diarworld","html_url":"https://github.com/diarworld","followers_url":"https://api.github.com/users/diarworld/followers","following_url":"https://api.github.com/users/diarworld/following{/other_user}","gists_url":"https://api.github.com/users/diarworld/gists{/gist_id}","starred_url":"https://api.github.com/users/diarworld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diarworld/subscriptions","organizations_url":"https://api.github.com/users/diarworld/orgs","repos_url":"https://api.github.com/users/diarworld/repos","events_url":"https://api.github.com/users/diarworld/events{/privacy}","received_events_url":"https://api.github.com/users/diarworld/received_events","type":"User","site_admin":false},"labels":[{"id":437720458,"url":"https://api.github.com/repos/ansible/ansible/labels/affects_2.0","name":"affects_2.0","color":"5319e7","default":false},{"id":48276055,"url":"https://api.github.com/repos/ansible/ansible/labels/bug_report","name":"bug_report","color":"fbca04","default":false},{"id":437714870,"url":"https://api.github.com/repos/ansible/ansible/labels/triage","name":"triage","color":"0e8a16","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-02-08T14:06:34Z","updated_at":"2016-12-08T23:14:11Z","closed_at":null,"body":"**Issue Type**: Bug Report\n**Ansible Version**: 2.0.0.2-1ppa~trusty\n\n**Ansible Configuration**: Default\n\n**Environment**: Ubuntu 14.04, Target systems Ubuntu 14.04\n\n**Summary**:\n\nI have playbook for adding and modifying user at remote Ubuntu hosts. Playbook worked correctly till I upgrade ansible to 2.0.0.2 version. Following code in my playbook:\n\n```\n- name: Add RSA keys to the remote host for users\n  authorized_key: user=\"{{ item.name }}\"\n                  key=\"{{ lookup('file', item.pubkeys) }}\"\n  when:\n    item.state == \"present\"\n  with_items:\n    users\n```\n\ngroup vars.yml:\n\n```\nusers:\n  - { name: 'diarworld', state: 'present', comment: '\"Dmitry Ibragimov\"', pass: 'EncodedString', pubkeys: ['diarworld_rsa.pub', 'diarworld_prod_rsa.pub'] }\n  - { name: 'test123', state: 'present', comment: '\"Test User\"', pass: 'EncodedString', pubkeys: ['test_rsa.pub'] }\n```\n\nThis code worked correctly with **1.7.2+dfsg-1~ubuntu14.04.1** ansible version. But after upgrade to **2.0.0.2-1ppa~trusty** I got error:\n\n```\nfatal: [test.machine.com]: FAILED! => {\"failed\": true, \"stdout\": \"\"}\nAn exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'list' object has no attribute 'startswith'\n```\n\nFull strace:\n\n```\nfatal: [test.machine.com]: FAILED! => {\"failed\": true, \"stdout\": \"\"}\nAn exception occurred during task execution. The full traceback is:\nTraceback (most recent call last):\n  File \"/usr/lib/pymodules/python2.7/ansible/executor/process/worker.py\", line 114, in run\n    self._shared_loader_obj,\n  File \"/usr/lib/pymodules/python2.7/ansible/executor/task_executor.py\", line 91, in run\n    item_results = self._run_loop(items)\n  File \"/usr/lib/pymodules/python2.7/ansible/executor/task_executor.py\", line 241, in _run_loop\n    res = self._execute(variables=task_vars)\n  File \"/usr/lib/pymodules/python2.7/ansible/executor/task_executor.py\", line 356, in _execute\n    self._task.post_validate(templar=templar)\n  File \"/usr/lib/pymodules/python2.7/ansible/playbook/task.py\", line 238, in post_validate\n    super(Task, self).post_validate(templar)\n  File \"/usr/lib/pymodules/python2.7/ansible/playbook/base.py\", line 307, in post_validate\n    value = templar.template(getattr(self, name))\n  File \"/usr/lib/pymodules/python2.7/ansible/template/__init__.py\", line 350, in template\n    d[k] = self.template(variable[k], preserve_trailing_newlines=preserve_trailing_newlines, fail_on_undefined=fail_on_undefined, overrides=overrides)\n  File \"/usr/lib/pymodules/python2.7/ansible/template/__init__.py\", line 322, in template\n    result = self._do_template(variable, preserve_trailing_newlines=preserve_trailing_newlines, escape_backslashes=escape_backslashes, fail_on_undefined=fail_on_undefined, overrides=overrides)\n  File \"/usr/lib/pymodules/python2.7/ansible/template/__init__.py\", line 474, in _do_template\n    res = j2_concat(rf)\n  File \"<template>\", line 9, in root\n  File \"/usr/lib/python2.7/dist-packages/jinja2/runtime.py\", line 193, in call\n    return __obj(*args, **kwargs)\n  File \"/usr/lib/pymodules/python2.7/ansible/template/__init__.py\", line 401, in _lookup\n    ran = instance.run(loop_terms, variables=self._available_variables, **kwargs)\n  File \"/usr/lib/pymodules/python2.7/ansible/plugins/lookup/file.py\", line 47, in run\n    lookupfile = self._loader.path_dwim_relative(basedir, 'files', term)\n  File \"/usr/lib/pymodules/python2.7/ansible/parsing/dataloader.py\", line 230, in path_dwim_relative\n    if source.startswith('~') or source.startswith('/'):\nAttributeError: 'list' object has no attribute 'startswith'\n```\n\n**Steps To Reproduce**:\n1. Create playbook with following task:\n\n```\n- name: Add RSA keys to the remote host for users\n  authorized_key: user=\"{{ item.name }}\"\n                  key=\"{{ lookup('file', item.pubkeys) }}\"\n  when:\n    item.state == \"present\"\n  with_items:\n    users\n```\n\ngroup vars.yml:\n\n```\nusers:\n  - { name: 'diarworld', state: 'present', comment: '\"Dmitry Ibragimov\"', pass: 'EncodedString', pubkeys: ['diarworld_rsa.pub', 'diarworld_prod_rsa.pub'] }\n  - { name: 'test123', state: 'present', comment: '\"Test User\"', pass: 'EncodedString', pubkeys: ['test_rsa.pub'] }\n```\n\nPut sample key files to playbook directory. Run playbook.\n\n**Expected Results**:\n\nAs worked with 1.7.2 version.\n\n```\nTASK: [add_developers | Add RSA keys to the remote host for users] ************ \nok: [test.machine.com] => (item={'comment': '\"Dmitry Ibragimov\"', 'state': 'present', 'pubkeys': ['diarworld_rsa.pub'], 'name': 'diarworld', 'pass': 'EncodedString'})\nok: [test.machine.com] => (item={'comment': '\"Dmitry Ibragimov\"', 'state': 'present', 'pubkeys': ['diarworld_prod_rsa.pub'], 'name': 'diarworld', 'pass': 'EncodedString'})\n\n```\n\n**Actual Results**:\n\nError :( If this bug unable to fix, please help me modify my playbook to avoid this error.\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/265884443","html_url":"https://github.com/ansible/ansible/issues/14369#issuecomment-265884443","issue_url":"https://api.github.com/repos/ansible/ansible/issues/14369","id":265884443,"user":{"login":"krzysztof-magosa","id":6112411,"avatar_url":"https://avatars.githubusercontent.com/u/6112411?v=3","gravatar_id":"","url":"https://api.github.com/users/krzysztof-magosa","html_url":"https://github.com/krzysztof-magosa","followers_url":"https://api.github.com/users/krzysztof-magosa/followers","following_url":"https://api.github.com/users/krzysztof-magosa/following{/other_user}","gists_url":"https://api.github.com/users/krzysztof-magosa/gists{/gist_id}","starred_url":"https://api.github.com/users/krzysztof-magosa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krzysztof-magosa/subscriptions","organizations_url":"https://api.github.com/users/krzysztof-magosa/orgs","repos_url":"https://api.github.com/users/krzysztof-magosa/repos","events_url":"https://api.github.com/users/krzysztof-magosa/events{/privacy}","received_events_url":"https://api.github.com/users/krzysztof-magosa/received_events","type":"User","site_admin":false},"created_at":"2016-12-08T23:14:11Z","updated_at":"2016-12-08T23:14:11Z","body":"Try:\r\n```\r\n- name: Add RSA keys to the remote host for users\r\n  authorized_key:\r\n    user: \"{{ item.name }}\"\r\n     key: \"{{ lookup('file', item.pubkeys) }}\"\r\n  when: item.state == \"present\"\r\n  with_items: \"{{ users }}\"\r\n```"}}
{"actor":{"display_login":"krzysztof-magosa"}}