title: Puppet hiera equivalent in Ansible
body: <p>hiera.yaml</p>
  
  <pre><code>---
  :hierarchy:
  - node/%{host_fqdn}
    - site_config/%{host_site_name}
    - site_config/perf_%{host_performance_class}
    - site_config/%{host_type}_v%{host_type_version}
    - site/%{host_site_name}
    - environments/%{site_environment}
    - types/%{host_type}_v%{host_type_version}
    - hosts
    - sites
    - users
    - common
  # options are native, deep, deeper
  :merge_behavior: deeper
  </code></pre>
  
  <p>We currently have this hiera config. So the config gets merged in the following sequence common.yaml > users.yaml > sites.yaml > hosts.yaml > types/xxx_vxxx.yaml > etc. For the variable top hierarchies, it gets overwritten only if that file exists.</p>
  
  <p>eg:
  common.yaml</p>
  
  <pre><code>server:
    instance_type: m3.medium
  </code></pre>
  
  <p>site_config/mysite.yaml</p>
  
  <pre><code>server:
    instance_type: m4.large
  </code></pre>
  
  <p>So for all other sites, the instance type will be m3.medium, but only for mysite it will be m4.large.</p>
  
  <p>How can I achieve the same in Ansible?</p>