ansible AttributeError: 'list' object has no attribute 'startswith'

Viewed 21395

I am running ansible and trying to make this task work, it fails with this error:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'list' object has no attribute 'startswith' fatal: [test-1]: FAILED! => {"failed": true, "msg": "Unexpected failure during module execution.", "stdout": ""} msg: Unexpected failure during module execution.

The code is:

  - name: Register env Type
    shell: facter configured_setup
    register: setup

  - name: foo tasks
    shell: {{some_script}} -t -a {{hosts}} -i {{inventory_hostname}}
    register: test
    when: setup.stdout == "something"

  - name: fetch group_vars
    fetch:
      src:
       - { "{{ item }}", when: setup.stdout == "something" }
      dest: "{{group_vars}}"
      flat: yes
    with_items:
      - "{{ test.stdout_lines[0] }}"
      - "{{ test.stdout_lines[1] }}"

"fetch group_vars" is the task that always fails, any idea how this can work? What I am trying to do is add more source files to fetch from different setvers. So I want to have more lines under "src:", saying - { filename, when setup.stdout =="something else" }

The full error is:

An exception occurred during task execution. The full traceback is: Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 96, in run item_results = self._run_loop(items) File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 252, in _run_loop res = self._execute(variables=task_vars) File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 446, in _execute result = self._handler.run(task_vars=variables) File "/usr/lib/python2.7/site-packages/ansible/plugins/action/fetch.py", line 62, in run source = self._remote_expand_user(source) File "/usr/lib/python2.7/site-packages/ansible/plugins/action/init.py", line 460, in _remote_expand_user if not path.startswith('~'): # FIXME: Windows paths may start with "~ instead of just ~ AttributeError: 'list' object has no attribute 'startswith'

fatal: [test-1]: FAILED! => {"failed": true, "msg": "Unexpected failure during module execution.", "stdout": ""} msg: Unexpected failure during module execution.

2 Answers
Related