Hiya.

In my playbook, I have two plays: the first is to be run on the control 
host, the second is run on a set of remote app hosts. What I want to do is 
have a variable determined by a task in the first play be used as a shell 
script argument for a task in the second play. I don't know how to do this. 
Can anyone help? Is this possible?

Here's a simplification of how these are called in my ansible deployment 
orchestration playbook. The json determined by a tool on the control host 
in common/test_prep.yml needs to be used as the input parameter to a tool 
which is called inside of common/test_client_check.yml on each client 
'myhosts'.


$ cat testplaybook.yml
---
- hosts: 127.0.0.1
  connection: local
  gather_facts: False
  tasks:

- include: "{{ playbook_dir }}/pb_test.yml myhosts=app_set1"

$ cat pb_test.yml
---
- include: common/test_prep.yml
- include: common/test_client_check.yml

$ cat common/test_prep.yml
---
- hosts: 127.0.0.1
  connection: local
  gather_facts: false
  tasks:

  - name: Check authoritative DNS for app datasources
    local_action: shell ../bin/dns_check
    ignore_errors: true
    register: check_results

  - debug: var=check_results.stdout_lines[0]
  - set_fact: json_as_input_for_next_play={{ check_results.stdout_lines[0] 
}}
  - debug: var=json_as_input_for_next_play

$ cat common/test_client_check.yml
---
- hosts: '{{ myhosts }}'
  gather_facts: false
  tasks:
    # this ruby script returns a Boolean
  - name: Check DNS for app datasources on the clients
    shell: /usr/local/bin/client-side-lookup json_as_input_for_next_play
    sudo: yes

# When running it by hand, the json needs to be surrounded by single quotes:
#client#  /usr/local/bin/client-side-lookup 
'{"db1.example.com":"10.4.4.113","db2.example.com":"10.4.4.114"}'



How do I make this happen? Thank you!

kallen

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/26e5de97-6947-433f-9a5c-1c34784ff39f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to