simple module logic help

18 views
Skip to first unread message

Bogdan Baba

unread,
Sep 4, 2014, 2:06:44 PM9/4/14
to puppet...@googlegroups.com
H Guys,

I'm kind of new to puppet and programming I've made  a few simpler modules so far but  i'm trying to expand and build them better and i think i'm hitting my "i don't get programming logic bar".

For example i'm trying to build a module that will take parameters such as php_version=variable and based on that i can install either  php 5.3 5.4 or 5.5 and the necessary yum repo's.
I'm not getting anywhere and was wandering if my case logic and how i request the variable is correct . 

I cannot get to where it just installs the packages i need based on php_version.

Thank you!
Bogdan


site.pp(node)

$php_version='php55'
include php


php/init.pp
class php {
        include php::install
        include php::params
}

php/params.pp

class php::params {

        case $php_version {

         'php55': {
                $installrepo = "remi-php55"
                $package_prefix ="php55"
                }
         'php54': {
                $installrepo = "remi"
                $package_prefix ="php54"
                }
         'php53': {
                $installrepo = "epel"
                $package_prefix ="php"
                }
        }
}

php/install.pp

class php::install {

 include php::params

      $packlist = [ "$package_prefix", "$package_prefix-gd", "$package_prefix-pear", "$package_prefix-devel", "$package_prefix-bcmath", "$package_prefix-cli", "$package_prefix-fpm", "$package_prefix-imap", "$package_prefix-mbstring", "$package_prefix-mcrypt", "$package_prefix-mysql", "$package_prefix-pdo", "$package_prefix-pecl-apc", "$package_prefix-pecl-memcache", "$package_prefix-pecl-memcached", "$package_prefix-pecl-sphinx", "$package_prefix-soap", "$package_prefix-xml" ]

      package { "$packlist":
            ensure => "latest",
              }
}      


Christopher Wood

unread,
Sep 4, 2014, 2:26:14 PM9/4/14
to puppet...@googlegroups.com
On Thu, Sep 04, 2014 at 11:06:44AM -0700, Bogdan Baba wrote:
> H Guys,
> I'm kind of new to puppet and programming I've made  a few simpler modules
> so far but  i'm trying to expand and build them better and i think i'm
> hitting my "i don't get programming logic bar".
> For example i'm trying to build a module that will take parameters such as
> php_version=variable and based on that i can install either  php 5.3 5.4
> or 5.5 and the necessary yum repo's.
> I'm not getting anywhere and was wandering if my case logic and how i
> request the variable is correct . 
> I cannot get to where it just installs the packages i need based on
> php_version.
> Thank you!
> Bogdan
> site.pp(node)
> $php_version='php55'
> include php
> php/init.pp

Sounds like that should be php/manifests/init.pp? Also for the other manifests below.

https://docs.puppetlabs.com/puppet/latest/reference/modules_fundamentals.html
> --
> 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 [1]puppet-users...@googlegroups.com.
> To view this discussion on the web visit
> [2]https://groups.google.com/d/msgid/puppet-users/c3e1e83d-5dd4-4f2f-a6d7-043843b99250%40googlegroups.com.
> For more options, visit [3]https://groups.google.com/d/optout.
>
> References
>
> Visible links
> 1. mailto:puppet-users...@googlegroups.com
> 2. https://groups.google.com/d/msgid/puppet-users/c3e1e83d-5dd4-4f2f-a6d7-043843b99250%40googlegroups.com?utm_medium=email&utm_source=footer
> 3. https://groups.google.com/d/optout

Bogdan Baba

unread,
Sep 4, 2014, 2:48:40 PM9/4/14
to puppet...@googlegroups.com, christop...@pobox.com
Hi,

The files where in the proper places i don't think my include was working i changed it to inherit and works great installs exactly what i want.

class php::install inherits php::params {

      $packlist = [ "$package_prefix", "$package_prefix-gd", "$package_prefix-pear", "$package_prefix-devel", "$package_prefix-bcmath", "$package_prefix-cli", "$package_prefix-fpm", "$package_prefix-imap", "$package_prefix-mbstring", "$

      package { $packlist:
            ensure => "latest",
              }
}





The manifests are all inside the proper places my problem is that 
Reply all
Reply to author
Forward
0 new messages