Last Updated: February 25, 2016
·
561
· dorfsmay

Using the name of the target host in a task

There is a magic variable which contains the name of the target host while ansible is looping over all the hosts: $inventory_hosts:

- name: add ssh public keys to local known hosts file
  local_action: shell ssh-keyscan $inventory_hostname >>~/.ss/known_hosts 2>/dev/null