I will try to explain all problems you mentioned.
Class vs define. The main difference is that classes are singletons in puppet.
If you want to create an instance of elasticsearch::instance
just add to your puppet manifest:
elasticsearch::instance { 'some_name': }
exactly the same as in examples.
The purpose of using hiera with puppet is to provide proper values to puppet manifests depend on deployment environment. You cannot create a resource just by defining it in hiera. If you define some resource in hiera, use create_resource function to create an instance.
Please read the following article. As in example, the equivalent of making an instance in puppet manifest:
users { 'gary':
ensure => present,
uid => '5001',
gid => 'gary',
shell => 'zsh',
password => $password,
}
is, the following definition in hiera
#some.yaml
users:
gary:
ensure: 'present'
uid: '5001'
gid: 'gary'
shell: 'zsh'
password: 'biglongpasswordhash'
with instantiation in puppet manifest:
$users = hiera('users')
create_resources('users')