# Append to array

**URL:** <https://forum.ansible.com/t/append-to-array/22328>\
**Category:** Ansible Project\
**Created:** [August 19, 2016, 2:50pm UTC](https://forum.ansible.com/t/append-to-array/22328 "2016-08-19T14:50:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![elie\_merhej](https://avatars.discourse-cdn.com/v4/letter/e/58f4c7/32.png) [@elie\_merhej](https://forum.ansible.com/u/elie_merhej)\
**Post date:** [August 19, 2016, 2:50pm UTC](https://forum.ansible.com/t/append-to-array/22328/1 "2016-08-19T14:50:26Z")

</div>

Hi guys,

This might be a duplicate topic but I wasn’t able to find the answer to my question.  
if I define a variable array in a role like:

postgresql\_pg\_hba\_default:

- { type: local, database: all, user: all, address: ‘’, method: md5 }

- { type: host, database: all, user: all, address: ‘127.0.0.1’, method: md5 }

I have a task in the role that will make sure that the items in the previous array are placed in pg\_hba.conf

what I would like to achieve is appending to this array and having the same task in the role to add the extra item:

- { type: host, database: all, user: test, address: ‘1.2.3.4’, method: md5 }

the end result that I would like to achieve is to have all 3 items in the file without having any extra tasks to add them, this means just updating the list/array at any level (in other roles or playbooks)

Thank you,

Elie.
