# access to the variable

**URL:** <https://forum.ansible.com/t/access-to-the-variable/15115>\
**Category:** Ansible Project\
**Created:** [April 30, 2014, 12:05pm UTC](https://forum.ansible.com/t/access-to-the-variable/15115 "2014-04-30T12:05:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexey\_Lesovsky](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@Alexey\_Lesovsky](https://forum.ansible.com/u/Alexey_Lesovsky)\
**Post date:** [April 30, 2014, 12:05pm UTC](https://forum.ansible.com/t/access-to-the-variable/15115/1 "2014-04-30T12:05:47Z")

</div>

Hi all!

Have some trouble in the access to the part of variable.  
I have following configuration:

`  
service\_user:

- { name: “service”, pass: “blablabla”, flags: “ADMIN” }

`

and later:

`

- name: “Stage 3: start service”  
command: “start-service.sh -u {{ service\_user.name }}”  
`

when playbook playing, at this place I got error “One or more undefined variables: ‘list object’ has no attribute ‘name’”

Also service\_user variable is used in the jinja template and work properly.  
How to do it right, and don’t break variable usage in template?

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [April 30, 2014, 1:10pm UTC](https://forum.ansible.com/t/access-to-the-variable/15115/2 "2014-04-30T13:10:55Z")

</div>

What you want is actually:

service\_user:  
name: “service”  
pass: “blablabla”  
flags: “ADMIN”

The ‘-’ at the beginning of the line is defining a list/array element, as opposed to a dict/hash

In your current configuration, you would need to use ‘service\_user[0].name’

---

<div class="post-metadata">

**Author:** ![Alexey\_Lesovsky](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@Alexey\_Lesovsky](https://forum.ansible.com/u/Alexey_Lesovsky)\
**Post date:** [April 30, 2014, 1:44pm UTC](https://forum.ansible.com/t/access-to-the-variable/15115/3 "2014-04-30T13:44:19Z")

</div>

Thanks!  
Now works fine.
