How would you represent this in hiera?

47 views
Skip to first unread message

Peter K

unread,
Jun 1, 2017, 5:19:59 PM6/1/17
to Puppet Users
Hi all, I'm using the zleslie-ssh module and trying to configure it with hiera.
I have all the lines working but this one (this is the output I"m seeking):

Subsystem  sftp    /usr/libexec/sftp-server

Here is successfully working code that is non-hiera:

include ssh::service

ssh
::server::subsystem { 'sftp':
system
=> '/usr/libexec/sftp-server'
 
}

Here is my best guest to how it should be defined with hiera (but it doesn't create anything):

ssh::server::subsystem::sftp:
 
- system: '/usr/libexec/sftp-server'

Thoughts?
thx
-peter

Peter Kristolaitis

unread,
Jun 1, 2017, 5:27:45 PM6/1/17
to puppet...@googlegroups.com

If you're trying to use data binding, then it would be:

ssh::server::subsystem::system: '/usr/libexec/sftp-server'

That does, however, have problems if you have multiple instantiations of ssh::server::subsystem on a single node with different values, and you'd need to define your own hierarchy and explicitly use hiera lookups in your manifest in that case.
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/5f4b39eb-bb3b-40d8-91a4-82f16931e53a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Angel L. Mateo

unread,
Jun 2, 2017, 1:59:24 AM6/2/17
to puppet...@googlegroups.com
El 01/06/17 a las 23:19, Peter K escribió:
> Hi all, I'm using the zleslie-ssh <https://forge.puppet.com/zleslie/ssh>
Depend on how you are invoking ssh::server::subsystem define. For
example, if you are using roles&profile, you could define in hiera like:

profile::ssh::server::subsystem::
sftp:
system: '/usr/libexec/sftp-server'

And then:

class profile::ssh::server (
$subsytem = {},
) {
$subsystem.each |$n, $o| {
ssh::server::subsystem {$n:
* => $o,
}
}
}

that invokes all the subsystems defined in hiera.

--
Angel L. Mateo Martínez
Sección de Telemática
Área de Tecnologías de la Información
y las Comunicaciones Aplicadas (ATICA)
http://www.um.es/atica
Tfo: 868889150
Fax: 868888337

Peter K

unread,
Jun 7, 2017, 6:01:35 PM6/7/17
to Puppet Users
Thank you, guys.
Unfortunately it still doesn't produce anything.
I guess I'll have to figure out the author's code.

@Peter Kristolaitis, thank you for bringing to my attention that the "sftp" title will probably not be a key, or class name.
@amateo, I'm not yet familiar with roles/profiles but thank you for reminding me about nesting (indenting without hyphens)

Red Cricket

unread,
Jun 7, 2017, 6:28:51 PM6/7/17
to puppet-users
There is no subsystem resource defined ... just this:

# Define: ssh::server::subsystem
#
# Add an ssh subsystem to sshd_config(5)
#
# Examples:
#
#   ssh::server::subsystem { 'sftp':
#     system => 'internal-sftp'
#   }
#
define ssh::server::subsystem (
  $system,
) {

  include ::ssh
  include ::ssh::server

  concat::fragment { "sshd_config-subsystem-${name}":
    target  => $ssh::sshd_config,
    content => template('ssh/sshd_config-subsystem.erb'),
  }
}


Looks like all you would need to do is this in your hiera:

ssh::server::subsystem::system: '/usr/libexec/sftp-server'

And then just do ...

include ssh::server::subsystem

... in your manifest.


--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.

Red Cricket

unread,
Jun 7, 2017, 6:30:19 PM6/7/17
to puppet-users
oops ... I was wrong about that. It does define a resource. my bad 

Joseph Karns

unread,
Jun 8, 2017, 8:36:03 AM6/8/17
to Puppet Users
Peter K:

What version of the module are you using? On the forge is 1.1.0

If that is the case you will need to include ::ssh::server (You can do this using roles and profiles)
This link to Gary Larizza will help you understand what they are and how to do them - http://garylarizza.com/blog/2014/02/17/puppet-workflow-part-2/

You will then need a way to do a create resource on the define class ssh::server::subsystem

class peters_class (
  $ssh_subsystem
= {}
) {
  create_resource
('ssh::server::subsystem', $ssh_subsytem);
}

Then in Hiera

peters_class::ssh_subsystem:
 
'sftp':
   
'system': '/usr/libexec/sftp-server'

Hope this Helps
Joey
Message has been deleted

Peter K

unread,
Jun 8, 2017, 3:02:44 PM6/8/17
to Puppet Users
Thank you all; I thought I had a solution but realized I'd put code back into site.pp.

@Joseph Karns Thank you for the notes and link. I think I get the gist; I just need to figure out if this is a direction I plan to go.
-peter
Reply all
Reply to author
Forward
0 new messages