Hi,
How to set a variable inside role A and use it inside role B ? Role B is 
listed in dependencies sections in meta/main.yml of role A and I see its 
output then call role A. 
I have tried to use *set_fact* module or *register* variable, but no luck.

*role A:*


- name: Print test var from another role
  debug: msg="{{ test_var }}"


*role B:*


- name: Save some vars in register
  shell: echo "BLAH"
  register: test_var


- name: Save some vars in facts
  set_fact:

    test_var: BLAH


*ansible-playbook's Output:*

fatal: [localhost] => One or more undefined variables: 'test_var' is 
> undefined
> FATAL: all hosts have already failed -- aborting


If I set test_var via role's parameter in site.yml, all works fine:

*site.yml*









*---- hosts: all  roles:    - { role: ntpd, test_var: "BLAH" }*

*ansible-playbook's Output:*

> TASK: [runit | Print test var from another role] 
> **********************************************
> ok: [localhost] => {
>     "msg": "BLAH"
> }
>   


I want to write wrapper for runit service supervisor, so I need from 
service roles (ntpd, sshd, etc) some variables (service_name, run_script, 
log_script, service_status, etc).




-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/8cace308-b24e-4f01-88c6-8665cbb36991%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to