# Issues with using a variable from another role

**URL:** <https://forum.ansible.com/t/issues-with-using-a-variable-from-another-role/24756>\
**Category:** Ansible Developer\
**Created:** [June 19, 2017, 12:08am UTC](https://forum.ansible.com/t/issues-with-using-a-variable-from-another-role/24756 "2017-06-19T00:08:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rahul\_Mohandas](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@Rahul\_Mohandas](https://forum.ansible.com/u/Rahul_Mohandas)\
**Post date:** [June 19, 2017, 12:08am UTC](https://forum.ansible.com/t/issues-with-using-a-variable-from-another-role/24756/1 "2017-06-19T00:08:23Z")

</div>

I have 2 roles, ansible-certbot and ansible-rutorrent.

ansible-rutorrent depends on ansible-certbot:

`

dependencies:

- role: “rahul0705.rtorrent”
- role: “rahul0705.apache”
- role: “rahul0705.ansible-certbot”  
certbot\_cert\_domain: “{{ rutorrent\_server\_name }}”  
certbot\_cert\_email: “{{ rutorrent\_server\_admin }}”  
when: rutorrent\_ssl\_set

`

As can be seen, I am overriding variable in the certbot role.

Within the ansible-rutorrent role, we use the variables in ansible-certbot in our defaults:

`

rutorrent\_ssl\_certificate\_name: fullchain.pem  
rutorrent\_ssl\_certificate\_key\_name: privkey.pem  
rutorrent\_ssl\_certificate\_file: “{{ certbot\_cert\_directory }}/{{ rutorrent\_ssl\_certificate\_name }}”  
rutorrent\_ssl\_certificate\_key\_file: “{{ certbot\_cert\_directory }}/{{ rutorrent\_ssl\_certificate\_key\_name }}”

`

The expected result of running this should be that when the ansible-certbot role is run (because of the dependency) the domain being used is defined from the variable of rutorrent. This DOES happen. The next expected result would be that the variable in ansible-rutorrent that reference ansible-certbot should use those new variables. This DOES NOT happen.

For completion I will show you the variables in ansible-certbot:

`

certbot\_cert\_domain: [www.example.com](http://www.example.com)  
certbot\_cert\_email: [admin@example.com](mailto:admin@example.com)

certbot\_directory: /etc/letsencrypt  
certbot\_cert\_directory: “{{ certbot\_directory }}/live/{{ certbot\_cert\_domain }}”

`

What we see is when certbot runs it uses the correct variables, when rutorrent runs it uses [www.example.com](http://www.example.com):

`

TASK [rahul0705.ansible-certbot : list variable data] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [test] =\> {  
“certbot\_cert\_directory”: “/etc/letsencrypt/live/rutorrent.test.com”  
}

…  
…  
…

TASK [rahul0705.rutorrent : list var info] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [test] =\> (item=certbot\_cert\_directory) =\> {  
“certbot\_cert\_directory”: “/etc/letsencrypt/live/www.example.com”,  
“item”: “certbot\_cert\_directory”  
}  
ok: [test] =\> (item=certbot\_cert\_domain) =\> {  
“certbot\_cert\_domain”: “[www.example.com](http://www.example.com)”,  
“item”: “certbot\_cert\_domain”  
}  
ok: [test] =\> (item=certbot\_cert\_email) =\> {  
“certbot\_cert\_email”: “[admin@example.com](mailto:admin@example.com)”,  
“item”: “certbot\_cert\_email”  
}

`

Any help here would be greatly appreciated.
