I have a playbook that use the S3 module to list items:

{code}
- name: List s3 bucket
  local_action:
    module: s3
    bucket: "{{ S3_BUCKET_NAME }}"
    mode: list
  register: S3_LIST_ITEM
{code}

The result I output to a file using lineinfile:

{code}
 name: Output to folder
  local_action:
    module: lineinfile
    create: yes 
    line: "{{ S3_LIST_ITEM.s3_keys }}"
    dest: "{{ S3_BUCKET_FILE }}"
    state: present
{code}

However this results in a JSON format:

['HelloWorld.sh', 'bucket1/', 'test1']

I tried using jinja2 filter (from_json), 

e.g. line: "{{ S3_LIST_ITEM.s3_keys }}"| from_json

But that didn't work as it gave me:

fatal: [localhost]: FAILED! => {"failed": true, "msg": "Unexpected 
templating type error occurred on ({{  S3_LIST_ITEM.s3_keys|from_json }}): 
expected string or buffer"}

There is also no stdout_lines equivalent so how can I put this in a text 
format that separate each value in a new line?

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a4a208ea-e8b3-4898-ae2d-7d99bfcbf751%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to