multiple variables

Is there a way to register two or more variables echoed from shell script?
I want to do something like this:

script.sh
A=“hello”
B=“world”
echo $A
echo $B

ROLE
shell: "{{ script }} "
register: result
ignore_errors: False

  • name: debug
    debug: var={{ result1 }} -->of echo 1 → hello
    debug: var={{ result2 }} -->of echo 2 → world

Is there some other way to do what I’m trying to do there?

thx

Your code would not run since it has some errors.

But you can get the first line from a output like this:
   - debug: var=result.stdout_lines.0

and the second line like this:
   - debug: var=result.stdout_lines.1