Can I install puppet modules through puppet manifest?

后端 未结 5 1519
迷失自我
迷失自我 2021-02-13 03:34

Primary goal is to add all puppet modules automatically, so that all dev-env\'s and prod-env could be started with one command. How can I install puppet modules through puppet m

相关标签:
5条回答
  • 2021-02-13 03:39

    The "Puppet module" type and provider does exactly that:

    module { 'author/mymodule':
      ensure   => present,
    }
    module { 'puppetlabs/stdlib':
      ensure => '2.6.0',
    }
    module { 'puppetlabs/stdlib':
      ensure     => present,
      modulepath => '/etc/puppet/modules',
    }
    

    Recent versions of Puppet also have a puppet module command that allows you to install arbitrary Puppet modules from the Puppet forge, example:

    $ puppet module install rcoleman/puppet_module
    Notice: Preparing to install into /home/anarcat/.puppet/modules ...
    Notice: Created target directory /home/anarcat/.puppet/modules
    Notice: Downloading from https://forgeapi.puppetlabs.com ...
    Notice: Installing -- do not interrupt ...
    /home/anarcat/.puppet/modules
    └── rcoleman-puppet_module (v0.0.3)
    

    Other alternatives include:

    • librarian
    • r10k (cited as a replacement for librarian), supports dynamic environments and much more

    r10k is now part of Puppet Entreprise 2015.03, so it can certainly be considered best practice.

    0 讨论(0)
  • 2021-02-13 03:40

    Seems that writing module for installing puppet modules is possible - it'll be just wrapper for puppet module tool. However, I didn't hear about such module yet.

    I suppose this mechanism of installation is not popular because often you need to modify installed module, do some customizations. Practical tool for management of such modifications is version control system. For example, in our team we keep /etc/puppetlabs/puppet directory in git repostitory. After installation of any module from Puppet Forge we add its files to version control and push it to remote git server. Our internally developed modules are also kept in this repository. This way, several puppet masters (dev and prod environments) are synchronized with this central repository and always have up-to-date versions of all modules.

    0 讨论(0)
  • 2021-02-13 03:44

    We've been happily using librarian-puppet to sync all 3rd party modules, it supports setting the modules' locations and versions. So production and dev run the exact same code. The usage is one liner

    librarian-puppet install
    

    In other cases we have a shell script that runs puppet two times, one time a minimal module that is only responsible for fetching the required modules, and then the full blown puppet flow when all modules are available.

    0 讨论(0)
  • 2021-02-13 03:54

    Here is an example of mine:

      $module_stdlib = 'puppetlabs-stdlib'
      exec { 'puppet_module_stdlib':
        command => "puppet module install ${module_stdlib}",
        unless  => "puppet module list | grep ${module_stdlib}",
        path    => ['/bin', '/opt/puppetlabs/bin']
      }
    

    Where $module_stdlib is a module I whant to install. The /bin path is a path where the grep comes from. And the /opt/puppetlabs/bin is a path where for the puppet binary exists in my installation.

    0 讨论(0)
  • 2021-02-13 03:57

    I did this and it seemed to work

    exec { 'puppet-fstab':
        path => '/bin:/usr/bin',
        command => 'puppet module install -i /usr/share/puppet/modules/AlexCline-fstab >>/tmp/err.log',
    }
    
    0 讨论(0)
提交回复
热议问题