ansible/ansible — pull request #6488 by antlegrand (2014-03-14 10:37:17+00:00)
Title: add register_append keyword

Hello,

register_append is exactly the same as register but instead of overwrite previous 'key' it will append result to it:
```python
hash[register] = result
hash[register_append].append(result)
```
We needed this feature to allow DRY/shared handlers:

Use case
Each time a new template is generated, backup the old one to a third server:
The backup task is done/write only once in the handler.
Without register_append, the 'new_tpl' variable would contains the last result only.

```yaml
tasks:
- name: template
template: src=mytpl.conf.j2 dest=/root/mytpl.conf backup=yes
register_append: new_tpl
notify:
- backup conf
tags:
- backup

- name: template 2
template: src=mytpl2.conf.j2 dest=/root/mytpl2.conf backup=yes
register_append: new_tpl
notify:
- backup conf
tags:
- backup

handlers:
- name: backup conf
synchronize: mode=pull src={{item.backup_file}} dest=/archive/{{inventory_hostname}}/{{item.backup_file | basename}}
delegate_to: backup-server-1
when: '{{item.backup_file is defined}}'
with_items: new_tpl
register: backup
```
Thank you