def oo_merge_hostvars(hostvars, variables, inventory_hostname):
 if (not isinstance(hostvars, Mapping)):
  raise errors.AnsibleFilterError('|failed expects hostvars is dictionary or object')
 if (not isinstance(variables, dict)):
  raise errors.AnsibleFilterError('|failed expects variables is a dictionary')
 if (not isinstance(inventory_hostname, string_types)):
  raise errors.AnsibleFilterError('|failed expects inventory_hostname is a string')
 ansible_version = pkg_resources.get_distribution('ansible').version
 merged_hostvars = {}
 if (LooseVersion(ansible_version) >= LooseVersion('2.0.0')):
  merged_hostvars = oo_merge_dicts(hostvars[inventory_hostname], variables)
 else:
  merged_hostvars = oo_merge_dicts(hostvars[inventory_hostname], hostvars)
 return merged_hostvars

def oo_merge_hostvars ( hostvars , variables , inventory_hostname ) : if ( not isinstance ( hostvars , Mapping ) ) : raise errors . AnsibleFilterError ( '|failed expects hostvars is dictionary or object' ) if ( not isinstance ( variables , dict ) ) : raise errors . AnsibleFilterError ( '|failed expects variables is a dictionary' ) if ( not isinstance ( inventory_hostname , string_types ) ) : raise errors . AnsibleFilterError ( '|failed expects inventory_hostname is a string' ) ansible_version = pkg_resources . get_distribution ( 'ansible' ) . version merged_hostvars = { } if ( LooseVersion ( ansible_version ) >= LooseVersion ( '2.0.0' ) ) : merged_hostvars = oo_merge_dicts ( hostvars [ inventory_hostname ] , variables ) else : merged_hostvars = oo_merge_dicts ( hostvars [ inventory_hostname ] , hostvars ) return merged_hostvars
merge host and play variables .