# Ansible 2.2: register with a variable in the name

**URL:** <https://forum.ansible.com/t/ansible-2-2-register-with-a-variable-in-the-name/23111>\
**Category:** Ansible Project\
**Created:** [November 27, 2016, 9:23am UTC](https://forum.ansible.com/t/ansible-2-2-register-with-a-variable-in-the-name/23111 "2016-11-27T09:23:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andreas\_Olsson](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@Andreas\_Olsson](https://forum.ansible.com/u/Andreas_Olsson)\
**Post date:** [November 27, 2016, 9:23am UTC](https://forum.ansible.com/t/ansible-2-2-register-with-a-variable-in-the-name/23111/1 "2016-11-27T09:23:44Z")

</div>

Greetings

Since moving from Ansible 2.1.3 to Ansible 2.2.0 I have run into an  
issue with register, and when it's variable name is built up using a  
variable. I have no idea if this is due to a regression in Ansible 2.2,  
or if I have been doing something wrong/unsupported which I finally got  
bitten by.

Anyway, this being what breaks between 2.1.3 and 2.2.0. Context wise  
it's part of a parameterize role.

&nbsp;&nbsp;- name: Add {{ repo\_name }} sources  
template:  
src={{ repo\_name }}.list.j2  
dest=/etc/apt/sources.list.d/{{ repo\_name }}.list  
owner=root  
group=root  
mode=0444  
register: reg\_{{ repo\_name }}\_sources  
&nbsp;&nbsp;  
&nbsp;&nbsp;- name: debug reg\_{{ repo\_name }}\_sources  
debug: var=reg\_{{ repo\_name }}\_sources

Running Ansible 2.1.3 I get the following expected output.

&nbsp;&nbsp;TASK [repo : Add gitppa sources] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
&nbsp;&nbsp;ok: [vagmast]  
&nbsp;&nbsp;  
&nbsp;&nbsp;TASK [repo : debug reg\_gitppa\_sources] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
&nbsp;&nbsp;ok: [vagmast] =\> {  
"reg\_gitppa\_sources": {  
"changed": false,  
"diff": {  
"after": {  
"path": "/etc/apt/sources.list.d/gitppa.list"  
},  
"before": {  
"path": "/etc/apt/sources.list.d/gitppa.list"  
}  
},  
&nbsp;&nbsp; "gid": 0,  
"group": "root",  
"mode": "0444",  
"owner": "root",  
"path": "/etc/apt/sources.list.d/gitppa.list",  
"size": 61,  
"state": "file",  
"uid": 0  
}  
&nbsp;&nbsp;}

While with Ansible 2.2 that register never appear to happen.

&nbsp;&nbsp;TASK [repo : Add gitppa sources] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
&nbsp;&nbsp;ok: [vagmast]  
&nbsp;&nbsp;  
&nbsp;&nbsp;TASK [repo : debug reg\_gitppa\_sources] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
&nbsp;&nbsp;ok: [vagmast] =\> {  
&nbsp;&nbsp; "reg\_gitppa\_sources": "VARIABLE IS NOT DEFINED!"  
&nbsp;&nbsp;}

Any idea what I'm doing wrong, or what I should try?

// Andreas

---

<div class="post-metadata">

**Author:** ![Andreas\_Olsson](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@Andreas\_Olsson](https://forum.ansible.com/u/Andreas_Olsson)\
**Post date:** [December 3, 2016, 4:52am UTC](https://forum.ansible.com/t/ansible-2-2-register-with-a-variable-in-the-name/23111/2 "2016-12-03T04:52:18Z")

</div>

Ok, here is a minimal playbook showing my particular issue.
