How to get variables from python to Ansible?

I know that

register: var

Allows to reference var.stdout, but…

Say I call a python script that prints to stdout more than one argument as in a tuple : (arg1, arg2, arg3)

How can I get that into individual variables in Ansible?

Thanks

Easiest would be to write a fact module, and return a JSON response that contains the dictionary “ansible_facts”. Register does not need to be used with these modules.

Take a look at any module in the tree ending in “_facts” for an example, the setup module is a special case of those, that is called automatically.

–Michael

I used the code of the ‘user’ module to try, and it works, unfortunately I wanted to prompt the user for the args and the custom module can’t seem to do an interactive session.

The var_prompt module is not really suitable, for what I see. I have to get 4 answers and a lot of work to validate them in between, that’s why I think it’s best to do that in Python, then pass to Ansible the arguments to use in the deployment and fire it off. Looks like I’ll have to use --extra_vars to pass the args to Ansible. Pity, a custom module sounded neat.

Thanks

This seems to be a different question.

Since this is about writing modules, would you mind asking on ansible-devel?

Apologies on being the list cop but this is a very active list, and I also want to encourage the devel list a bit.

Thanks!