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:
This is the output I’m getting:
TASK: [known_hosts | keyscan] *************************************************
changed: [default] => (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!