Ask Your Question

Learning VM Resource Ordering Quest - Task 6/6

asked 2015-06-02 06:54:06 -0600

landerson61 gravatar image

updated 2015-06-03 11:12:50 -0600


I'm stuck with the final task number 6 on the 'Resource Ordering' quest of the Learning VM. The task requires the following to be completed:

"The sshd/manifests/init.pp manifest should should define the sshd class"

I have created my 'sshd/manifests/init.pp' manifest which looks like this;

class sshd {

  package {'openssh-server':
    ensure => present,
    before => File['/etc/ssh/sshd_config'],

  file {'/etc/ssh/sshd_config':
    ensure    =>    file,
    mode      =>    600,
    source    =>    'puppet:///modules/sshd/sshd_config',

  service {'sshd':
    ensure    =>    running,
    enable    =>    true,
    subscribe =>    File['/etc/ssh/sshd_config'],


My 'sshd/tests/init.pp' manifest looks like this:

include 'sshd'

Puppet parser tool returns no errors with syntax on either of my manifests, however when applying the manifest with either 'puppet apply' or 'puppet agent -t' nothing seems to happen and the task does not complete:

[root@learning /etc/puppetlabs/puppet/environments/production/modules]# puppet apply sshd/tests/init.pp
Notice: Compiled catalog for learning.puppetlabs.vm in environment production in 0.83 seconds
Warning: The package type's allow_virtual parameter will be changing its default value from false to true in a future release. If you do not want to allow virtual packages, please explicitly set allow_virtual to false.
   (at /opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/type/package.rb:430:in `block (3 levels) in <module:Puppet>')
Notice: Finished catalog run in 0.63 seconds
[root@learning /etc/puppetlabs/puppet/environments/production/modules]#

Can anyone please help or point me in the right direction? As far as I can see, my manifest clearly defines my sshd class as required by the task.


Output of 'puppet apply sshd/tests/ini.pp --debug' is below:

Debug: Runtime environment: puppet_version=3.7.3 (Puppet Enterprise 3.7.1), ruby_version=1.9.3, run_mode=user, default_encoding=UTF-8
Debug: Loading external facts from /var/opt/lib/pe-puppet/facts.d
Info: Loading facts
Debug: Loading facts from /etc/puppetlabs/puppet/environments/production/modules/concat/lib/facter/concat_basedir.rb
Info: Loading facts
Debug: Loading facts from /etc/puppetlabs/puppet/environments/production/modules/staging/lib/facter/staging_windir.rb
Debug: Loading facts from /etc/puppetlabs/puppet/environments/production/modules/staging/lib/facter/staging_http_get.rb
Info: Loading facts
Debug: Loading facts from /etc/puppetlabs/puppet/environments/production/modules/stdlib/lib/facter/pe_version.rb
Debug: Loading facts from /etc/puppetlabs/puppet/environments/production/modules/stdlib/lib/facter/puppet_vardir.rb
Debug: Loading facts from /etc/puppetlabs/puppet/environments/production/modules/stdlib/lib/facter/root_home.rb
Debug: Loading facts from /etc/puppetlabs/puppet/environments/production/modules/stdlib/lib/facter/facter_dot_d.rb
Info: Loading facts
Debug: Loading facts from /etc/puppetlabs/puppet/environments/production/modules/mysql/lib/facter/mysql_version.rb
Debug: Loading facts from /etc/puppetlabs/puppet/environments/production/modules/mysql/lib/facter/mysql_server_id.rb
Info: Loading facts
Debug: Loading facts from /opt/puppet/share/puppet/modules/pe_staging ...
edit retag flag offensive close merge delete


Could you provide the output of puppet apply sshd/tests/init.pp --debug ? Thanks

Alex Harvey gravatar imageAlex Harvey ( 2015-06-02 22:49:35 -0600 )edit

Hi, How do I attach it here? It's too long for a comment, and I can only use the Answer box once. Thanks

landerson61 gravatar imagelanderson61 ( 2015-06-03 07:34:19 -0600 )edit

You can edit the original post and add it there.

Alex Harvey gravatar imageAlex Harvey ( 2015-06-03 10:40:12 -0600 )edit

Thanks :) just added it.

landerson61 gravatar imagelanderson61 ( 2015-06-03 11:13:18 -0600 )edit

Can you confirm whether or not there is a file /etc/ssh/sshd_config already on your system?

Alex Harvey gravatar imageAlex Harvey ( 2015-06-03 22:27:08 -0600 )edit

3 Answers

Sort by ยป oldest newest most voted

answered 2015-06-04 10:59:25 -0600

updated 2015-06-04 11:01:49 -0600

I've tried the code here and it seems to work. Is something broken on your system?

From your output:

$ grep /etc/ssh/sshd_config output.txt
Debug: /Stage[main]/Sshd/Package[openssh-server]/before: requires File[/etc/ssh/sshd_config]
Debug: /Stage[main]/Sshd/Service[sshd]/subscribe: subscribes to File[/etc/ssh/sshd_config]

So there's apparently no file resource in your catalog.

When I run it on my system (puppet v3.3.1 on a Mac):

$ puppet apply file.pp --noop
Notice: Compiled catalog for alexs-macbook-pro-2.local in environment production in 0.89 seconds
Notice: /Stage[main]/Sshd/Package[openssh-server]/ensure: current_value absent, should be present (noop)
Error: /Stage[main]/Sshd/File[/etc/ssh/sshd_config]: Could not evaluate: Could not retrieve information from environment production source(s) puppet:///modules/sshd/sshd_config
Notice: /Stage[main]/Sshd/Service[sshd]: Dependency File[/etc/ssh/sshd_config] has failures: true
Warning: /Stage[main]/Sshd/Service[sshd]: Skipping because of failed dependencies
Notice: Class[Sshd]: Would have triggered 'refresh' from 1 events
Notice: Stage[main]: Would have triggered 'refresh' from 1 events

That's failing only because I don't have the sshd_config in the files directory, as I'd expect to see.

edit flag offensive delete link more

answered 2015-06-05 04:01:47 -0600

landerson61 gravatar image

Ok. To test again I uninstalled openssh-server and ensured that /etc/ssh/sshd_config file was removed, then ran puppet again. All worked as expected, package was installed, /etc/ssh/sshd file created and service running, however the quest tasks was not marked as completed, still stays at 5/6.

Unless this is a bug in the learning VM... as it is the very last quest & task.

As all is working as expected, and you have kindly validated my puppet code, I'm happy with what I have learned.

Thank you for taking the time to help me.


edit flag offensive delete link more


No worries!

Alex Harvey gravatar imageAlex Harvey ( 2015-06-05 04:22:51 -0600 )edit

answered 2016-04-17 09:28:15 -0600

Hannah Shalev gravatar image

Facing the same issue. I think I found the bug that's preventing us from completing the quest. Check this out:

Line 12:

file("#{MODULE_PATH}sshd/manifests/init.pp").content.should match /class sshd \{/

The last curly bracket is escaped. However, on lines 13 and 14, they don't seem to have the same syntax. Curly brackets are not escaped. Stabbing in the dark here, but I'm guessing that only one of those two formats is the correct one, and the other is breaking quest completion. Correct me if I'm wrong though.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2015-06-02 06:54:06 -0600

Seen: 1,130 times

Last updated: Apr 17 '16