0

Below I have the Ansible YAML file:

- name: "script1"
  command: /home/test/script1.py
  register: output

- name: "script2"
  command: /home/test/script2.py

I need script2.py to see the output of script1.

How would I pass the values from Ansible to script2?

1 Answer 1

1

command's stdin parameter should do the trick:

- name: "script1"
  command: /home/test/script1.py
  register: output


- name: "script2"
  command: /home/test/script2.py
  args:
    stdin: "{{ output.stdout }}"
Sign up to request clarification or add additional context in comments.

4 Comments

thanks how do I call that in python?
@user2214162, regarding "How to read STDIN from Python" are already answers on SO like How do I read from STDIN.
Thanks so the command module does not work with my python script so I am usin the shell module instead which does work but still cannot send a variable
@user2214162, I've updated the code snippet (two last lines)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.