Sidedoor module

33 views
Skip to first unread message

warron.french

unread,
Jun 2, 2016, 10:32:05 PM6/2/16
to puppet...@googlegroups.com

I have created, a Puppet Module using PE-2015.2.

The module is called Sidedoor (as opposed to backdoor) and the intent is to do the following (as I am evolving it):
  1. Create a system-group with GID=300, and ensure it is in place,
  2. Create a user (mine for example) with starting UID=(300 + serial of userID {starting at 1...n})

Here is my current manifests/init.pp (and I am not ready for senior level programming input/best practices yet), sidedoor/manifests/init.pp:
# Class: sidedoor
# ===========================
#
#
#
class sidedoor {

#  Create a Group for the localusers to be added to.

    group { 'sidedoor':
      ensure => 'present',
      system => 'true',
      gid    => '300',
    }
    
    user { 'wsf29221':
      ensure           => 'present',
      forcelocal       => 'true',
      password         => '$6$Bw0KWK673BvjQU/W$WAiTDgk7EN3sD02xUaMngmIB02qQ/G4sRTeP6ySZToWylblcawuekIO4WSUgVMllbjrXP2QOLH96jTfA1xdz1/',
      password_max_age => '180',
      password_min_age => '0',
      gid              => '300',
      uid              => '301',
      comment          => 'Sidedoor_Acct-Warron',
      managehome       => 'true',
      home             => '/home/wsf29221',
      shell            => '/bin/bash',
    }

    file { '/home/wsf29221':
      ensure   => 'directory',
      owner    => '301',
      group    => '300',
      mode     => '0750',
      source   => [ "puppet:///modules/sidedoor/files/wsf29221", ],
    }

}

I believe I am not getting the file resource built correctly (yet).  The code above doesn't properly work on a Solaris 10 x86 VM that I have at all; it doesn't even try for some reason, but more importantly, it doesn't create the homedir for the user's account, even though the managehome attribute is being set.

I have this module written (and tested from) /etc/puppetlabs/code/environments/production/modules, and I purposely created the wsf29221 user account and it's home directory with matching user-attributes to generate a /home/wsf29221 directory; then I copied that subdirectory into /etc/puppetlabs/code/environments/production/modules/sidedoor/files/. 

Can someone please help me get the directory creation/population portion of this module working?

I am trying to learn how to write modules; not necessarily best practices yet.

Thanks,
Warron



--------------------------
Warron French

Warron French

unread,
Jun 4, 2016, 12:55:45 AM6/4/16
to puppet...@googlegroups.com

I have posted this twice and haven't gotten any replies on my questions.  Are my questions confusing?

It's kind of weird that there hasn't been any replies at all on this post.  None!

James Pryor

unread,
Jun 4, 2016, 1:19:24 AM6/4/16
to puppet...@googlegroups.com
Has the solaris 10 VM run a "puppet agent -t" and is has had it's SSL certificate signed by the master?
If so, have you moved beyond a basic Hello World module?
https://docs.puppet.com/pe/2015.2/quick_start_helloworld.html

If so, have you classified that solaris 10VM in the PE Console?
https://docs.puppet.com/pe/2015.2/quick_start_adding_class_nix.html

If so, do you have output of the puppet agent run on the solaris 10 VM where it it is failing?
Perform the following on the solaris 10 VM:
puppet agent -t --verbose

Have you considered running the puppet client agent on the solaris 10 VM locally, as in without speaking to the master server, via a:
puppet apply --noop
A "puppet apply" requires the sidedoor code to be on the solaris 10VM
https://docs.puppet.com/guides/tests_smoke.html#testing-in-brief

Regards,
James

--
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/3838ef60-f94a-5ecb-6df8-62f4417b94cb%40gmail.com.

For more options, visit https://groups.google.com/d/optout.

James Pryor

unread,
Jun 4, 2016, 2:01:52 AM6/4/16
to puppet...@googlegroups.com
I went a tested your code and indeed there is something wrong with the source attribute of the file resource. You have an uncesseary 'files/' in the source path. I removed it and it applies cleanly.  And I tested this on with the puppet agent version that comes with PE 2015.2.3 for RHEL7: puppet-agent-1.2.7-1.el7.x86_64

--- begin shell output ----
[root@testme modules]# pwd
/etc/puppetlabs/code/environments/production/modules
[root@testme modules]# puppet module generate foo-sidedoor --skip-interview

Notice: Generating module at /etc/puppetlabs/code/environments/production/modules/sidedoor...
Notice: Populating templates...
Finished; module generated in sidedoor.
sidedoor/metadata.json
sidedoor/spec
sidedoor/spec/classes
sidedoor/spec/classes/init_spec.rb
sidedoor/spec/spec_helper.rb
sidedoor/manifests
sidedoor/manifests/init.pp
sidedoor/Rakefile
sidedoor/README.md
sidedoor/Gemfile
sidedoor/tests
sidedoor/tests/init.pp

[root@testme modules]# cd sidedoor
[root@testme sidedoor]# mkdir -p files/wsf29221
[root@testme sidedoor]# touch files/wsf29221/examplefile

[root@testme sidedoor]# pwd
/etc/puppetlabs/code/environments/production/modules/sidedoor

[root@testme sidedoor]# tree
.
├── files
│   └── wsf29221
│       └── examplefile
├── Gemfile
├── manifests
│   └── init.pp
├── metadata.json
├── orig
│   └── orig.pp
├── Rakefile
├── README.md
├── spec
│   ├── classes
│   │   └── init_spec.rb
│   └── spec_helper.rb
└── tests
    └── init.pp

7 directories, 10 files
[root@testme sidedoor]# mkdir orig
[root@testme sidedoor]# vim orig/orig.pp
# I COPY PASTED YOUR CODE IN ORIG.PP
[root@testme sidedoor]# cp orig/orig.pp manifests/init.pp
[root@testme sidedoor]# vim manifests/init.p
[root@testme sidedoor]# diff orig/orig.pp manifests/init.pp
35c35

<       source   => [ "puppet:///modules/sidedoor/files/wsf29221", ],
---
>       source   => [ "puppet:///modules/sidedoor/wsf29221", ],
[root@testme sidedoor]# puppet apply tests/init.pp --noop
Notice: Compiled catalog for testme.localdomain.local in environment production in 0.26 seconds
Notice: /Stage[main]/Sidedoor/Group[sidedoor]/ensure: current_value absent, should be present (noop)
Notice: /Stage[main]/Sidedoor/User[wsf29221]/ensure: current_value absent, should be present (noop)
Notice: /Stage[main]/Sidedoor/File[/home/wsf29221]/ensure: current_value absent, should be directory (noop)
Notice: Class[Sidedoor]: Would have triggered 'refresh' from 3 events
Notice: Stage[main]: Would have triggered 'refresh' from 1 events
Notice: Applied catalog in 0.04 seconds
--- end shell output ----

Warron French

unread,
Jun 4, 2016, 3:21:12 AM6/4/16
to puppet...@googlegroups.com

Hello James, my answers are the following:

Has the solaris 10 VM run a "puppet agent -t" and is has had it's SSL certificate signed by the master?  Yes, the VM actually employed part of the module that I wrote already, it just has not created the /home/wsf29221 homedir.

If so, have you moved beyond a basic Hello World module?  I don't know how to answer this question other than ask if my prior response answers your questions.

If so, have you classified that solaris 10VM in the PE Console?  Yes, I have classified the solaris 10VM in the PE Console.

If so, do you have output of the puppet agent run on the solaris 10 VM where it it is failing?
Perform the following on the solaris 10 VM:  puppet agent -t --verbose
I ran the command, puppet agent -t (forgot the --verbose switch) and it took a very long time to do anything; and it technically didn't complete after 5 minutes.  Here are the results...
Warning: Unable to fetch my node definition, but the agent run will continue:
Warning: Connection refused - connect(2) for "puppet" port 8140
Info: Retrieving pluginfacts
Error: /File[/opt/puppetlabs/puppet/cache/facts.d]: Failed to generate additional resources using 'eval_generate': Connection refused - connect(2) for "puppet" port 8140
Error: /File[/opt/puppetlabs/puppet/cache/facts.d]: Could not evaluate: Could not retrieve file metadata for puppet:///pluginfacts: execution expired
Info: Retrieving plugin
Error: /File[/opt/puppetlabs/puppet/cache/lib]: Failed to generate additional resources using 'eval_generate': execution expired
Error: /File[/opt/puppetlabs/puppet/cache/lib]: Could not evaluate: Could not retrieve file metadata for puppet:///plugins: execution expired
Info: Loading facts
Error: Could not retrieve catalog from remote server: execution expired
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
Error: Could not send report: execution expired


Have you considered running the puppet client agent on the solaris 10 VM locally, as in without speaking to the master server, via a:   puppet apply --noop
A "puppet apply" requires the sidedoor code to be on the solaris 10VM 
https://docs.puppet.com/guides/tests_smoke.html#testing-in-brief
I did perform a smoke-test, but only on the Puppet Master; and I couldn't remember how to fake the OS during the smoke-test.  Can I copy the directory structure from my CentOS Puppetmaster over to some directory in my Solaris10 client and run the smoke test there?  Is that what you are saying?

I ran the following, after copying the module directory structure over to the Solaris10 VM:
root@puppet-solaris10:/tmp> puppet apply --noop /tmp/sidedoor/tests/init.pp
Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::sidedoor for puppet-solaris10.home at /tmp/sidedoor/tests/init.pp:12:1 on node puppet-solaris10.home

Thanks for the help James,
Warron
Reply all
Reply to author
Forward
0 new messages