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/nullWritten by Yves Dorfsman
Related protips
Have a fresh tip? Share with Coderwall community!
Post
 Post a tip
    Best  #Ansible  Authors 
   Misha Behersky 
    79.81K 
  tartansandal 
    73.69K 
   Related Tags 
  #ansible
  Sponsored by #native_company# — Learn More
    #native_title# #native_desc#