Ask Your Question
0

Unable to get roles/profiles working

asked 2018-03-21 06:57:14 -0500

kmhuntly gravatar image

Hello,

I'm new to roles/profiles. I had been using /etc/puppetlabs/code/environments/<env>/modules, and placecd all of my modules in there. I'm trying to use a role and profile to accomplish this now - so I have /etc/puppetlabs/code/environments/<env>/site/profile/manifests/base.pp, which applies all my base packages and initial configuration. Within base/ I have setup.pp, packages/ and sysconfig/. setup.pp includes packages/manifests/aide.pp (along with a few others).

I have the following snippet in setup.pp:

class profile::base::setup (
) {
    package { 'epel-release':
        ensure              => 'installed',
    }

    include profile::base::packages::aide
    ...
}

When I run puppet agent --test --noop, I get an error saying ::profile::base::packages::aide can't be found. Here's my directory structure:

[root@caspersb-pxesrc01 profile]# tree .
.
└── manifests
    └── base
        ├── packages
        │   ├── examples
        │   │   └── init.pp
        │   ├── files
        │   │   ├── etc
        │   │   │   ├── aide.conf
        │   │   │   ├── at.allow
        │   │   │   ├── at.deny
        │   │   │   ├── audit
        │   │   │   │   ├── auditd.conf
        │   │   │   │   └── rules.d
        │   │   │   │       └── audit.rules
        │   │   │   ├── chrony.conf
        │   │   │   ├── clamd.d
        │   │   │   │   └── scan.conf
        │   │   │   ├── cron.allow
        │   │   │   ├── cron.daily
        │   │   │   │   └── unowned
        │   │   │   ├── cron.deny
        │   │   │   ├── freshclam.conf
        │   │   │   ├── hosts.allow
        │   │   │   ├── hosts.deny
        │   │   │   ├── pam.d
        │   │   │   │   ├── local-auth
        │   │   │   │   ├── password-auth-ac
        │   │   │   │   └── system-auth-ac
        │   │   │   ├── rkhunter.conf
        │   │   │   ├── sudoers.d
        │   │   │   │   └── sudoers
        │   │   │   └── systemd
        │   │   │       └── system
        │   │   │           ├── aide.service
        │   │   │           ├── aide.timer
        │   │   │           ├── freshclam.service
        │   │   │           ├── freshclam.timer
        │   │   │           ├── puppet-agent.service
        │   │   │           ├── puppet-agent.timer
        │   │   │           ├── rkhunter-update.service
        │   │   │           ├── rkhunter-update.timer
        │   │   │           ├── sshd.service
        │   │   │           ├── yum-daily-update.service
        │   │   │           ├── yum-daily-update.timer
        │   │   │           ├── yum-weekly-update.service
        │   │   │           └── yum-weekly-update.timer
        │   │   └── usr
        │   │       └── local
        │   │           └── bin
        │   │               └── make-ssh-keys.sh
        │   ├── manifests
        │   │   ├── aide.pp
        │   │   ├── audit.pp
        │   │   ├── chrony.pp
        │   │   ├── clamav.pp
        │   │   ├── cron.pp
        │   │   ├── networkd.pp
        │   │   ├── pam.pp
        │   │   ├── prelink.pp
        │   │   ├── psacct.pp
        │   │   ├── puppet.pp
        │   │   ├── rkhunter.pp
        │   │   ├── ssh.pp
        │   │   ├── sudo.pp
        │   │   ├── sysstat.pp
        │   │   ├── system.pp
        │   │   ├── tcpwrappers.pp
        │   │   ├── vim.pp
        │   │   └── yum.pp
        │   └── templates
        │       ├── network.erb
        │       └── sshd_config.erb
        ├── setup.pp
        └── sysconfig
            ├── examples
            ├── files
            │   └── etc
            │       ├── audisp
            │       │   └── plugins.d
            │       │       └── syslog.conf
            │       ├── issue
            │       ├── modprobe.d
            │       │   ├── 01-usbstorage.conf
            │       │   ├── 02-ipv6.conf
            │       │   ├── 03-dccp.conf
            │       │   ├── 04-rds.conf
            │       │   ├── 05-sctp.conf
            │       │   ├── 06-tipc.conf
            │       │   ├── 07-cramfs.conf
            │       │   ├── 08-freevxfs.conf
            │       │   ├── 09-jffs2.conf
            │       │   ├── 10-hfs.conf
            │       │   ├── 11-hfsplus.conf
            │       │   ├── 12-squashfs.conf
            │       │   ├── 13-udf.conf
            │       │   ├── 14-bluetooth.conf
            │       │   └── 15-appletalk.conf
            │       ├── netconfig
            │       ├── securetty
            │       ├── security
            │       │   ├── limits.conf
            │       │   └── pwquality.conf
            │       ├── shutdown.allow
            │       ├── shutdown.deny
            │       ├── sysconfig
            │       │   ├── init
            │       │   └── prelink
            │       ├── sysctl.d
            │       │   ├── 01-ipv4.conf
            │       │   ├── 02-ipv6.conf
            │       │   ├── 03-kernel.conf
            │       │   ├── 04-fs.conf
            │       │   └── 05-vm.conf
            │       └── systemd
            │           └── journald.conf
            ├── manifests
            │   ├── audisp.pp
            │   ├── files.pp
            │   ├── modprobe.pp
            │   ├── security.pp
            │   ├── shutdown.pp
            │   ├── sysconfig.pp
            │   ├── sysctl.pp
            │   ├── systemctl.pp
            │   └── systemd.pp
            └── templates
                ├── cws.erb
                ├── hosts.erb
                ├── networking.erb
                └── network_persistent.erb

32 directories, 98 files
[root@caspersb-pxesrc01 profile]#

I know I'm doing something wrong, but I'm not sure what. I followed this as much as I could - https://puppet.com/docs/pe/2017.2/r_n... - but there is some stuff that I think I need that isn't in there.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2018-03-22 03:53:23 -0500

Jeremiah Powell gravatar image

You have aide.pp directly in the top-level /manifests directory. It needs to be inside /manifests/packages to be found.

Running puppet-lint on this module should inform you that your files are not in "correct autoloader layout".

The code

include profile::base::packages::aide

instructs the Puppet autoloader to look for a module named profile. It will look inside that module's /manifests directory for a file in base/packages named aide.pp.

This would be

  .
└── manifests
    └── base
        └── packages
            └── aide.pp

following from your example.

But you instead have:

  .
└── manifests
    ├── aide.pp
    └── base
        └── packages

This would be correct for the class profile::aide.

There are some other odd things in your example. It looks like you have Puppet modules within Puppet modules.

The autoloader probably cannot find the code in a module inside of another module.

The profile and role modules are just simple regular modules. The classes they use can be internal to those modules or part of separate modules of their own. In the examples from the roles-and-profile blog post, profile module only references utility classes from other modules. However, a class can be so simple that it might be defined directly in the profile module.

edit flag offensive delete link more

Comments

If I separate the modules I want to install out of production/site/profile/manifests and put them back into production/modules it doesn't work either. Ideally that's what I'd prefer - site/profile and site/role by themselves, and all my puppet modules in modules/. Is that possible?

kmhuntly gravatar imagekmhuntly ( 2018-03-22 05:58:35 -0500 )edit

I've moved my modules back into production/modules and run puppet-lint on both production/site and production/modules - and fixed the errors that were present. That looks like it may have corrected things, but now I'm getting this an error on this:

kmhuntly gravatar imagekmhuntly ( 2018-03-22 07:27:37 -0500 )edit

Syntax error at '=' at production/modules/packages/manifests/ssh.pp:2
Which correlates to
class packages::ssh (
    Optional[String[1]] = lookup('profile::packages::ipaddr', {value_type => String[1], default_value => undef})
) {
I thought this syntax was ok?

kmhuntly gravatar imagekmhuntly ( 2018-03-22 07:29:06 -0500 )edit

i think i might have fixed it...

kmhuntly gravatar imagekmhuntly ( 2018-03-22 09:06:33 -0500 )edit

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-03-21 06:57:14 -0500

Seen: 34 times

Last updated: Mar 22