Getting register value

How do I get the results from register?

  • name: check permission
    shell: find {{gPath}} -printf “%m\n”
    register: results

  • name: Print results
    action: debug msg=“{{results.stdout_lines}}”

What i got from results.stdout_lines is [u’755’]. How do i get just the value 755? I wish to pass this value to another task later on. Maybe to set permission using this value for another file.

Thank you.

Can you try:

action: debug msg= {{results.stdout}}

It works. Thank you :slight_smile:

The long story is the debug module likes to print strings, it is not really a datastructure printer or anything. result.stdout_lines is of course a list in this case.

The best way to see what data is available remains to be “-v” on the ansible playbook run, and passing it to another task is then pretty straightforward.

You would most likely iterate across it with “with_items”.

  • debug: msg=Hi I’ve got an {{ item }}
    with_items: results.stdout_lines.

etc

Using that with debug will print it nicely.