# \`register\` with \`with\_items\` not working as expected

**URL:** <https://forum.ansible.com/t/register-with-with-items-not-working-as-expected/13833>\
**Category:** Ansible Project\
**Created:** [November 3, 2013, 6:58pm UTC](https://forum.ansible.com/t/register-with-with-items-not-working-as-expected/13833 "2013-11-03T18:58:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fabio\_Kreusch](https://avatars.discourse-cdn.com/v4/letter/f/3e96dc/32.png) [@Fabio\_Kreusch](https://forum.ansible.com/u/Fabio_Kreusch)\
**Post date:** [November 3, 2013, 6:58pm UTC](https://forum.ansible.com/t/register-with-with-items-not-working-as-expected/13833/1 "2013-11-03T18:58:00Z")

</div>

Hi guys! I’m new to Ansible, and I’m working on my first playbook. I have something like this:

> * * *
> 
> - name: known\_hosts | keyscan
> 
> command: “ssh-keyscan -H {{ item }}”
> 
> with\_items: known\_hosts
> 
> register: known\_hosts\_keys
> 
> - name: known\_hosts | update
> 
> lineinfile: “dest=~/.ssh/known\_hosts regexp=‘{{ item }}’ line=‘{{ item }}’ create=yes”
> 
> with\_items: known\_hosts\_keys

`known_hosts` is a variable defined like this:

> * * *
> 
> known\_hosts:
> 
> - [github.com](http://github.com)

This is the output I’m getting:

> TASK: [known\_hosts | keyscan] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> changed: [default] =\> ([item=github.com](http://item=github.com))

> 

> TASK: [known\_hosts | update] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> fatal: [default] =\> with\_items expects a list
> 
> FATAL: all hosts have already failed – aborting

It seems that the $known\_hosts\_keys variable is not being registered properly. Am I missing something?

Thanks!

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [November 4, 2013, 11:19pm UTC](https://forum.ansible.com/t/register-with-with-items-not-working-as-expected/13833/2 "2013-11-04T23:19:57Z")

</div>

A register when used with a “with\_items” will reproduce a datastructure differently than you would expect

known\_host\_keys.results is the list of all responses

{  
failed: True, # is failed  
changed: True/False,  
results: [result1, result2]  
}

etc
