如何从Puppet Forge获取puppet的各种模块

Puppet Forge是一个免费的模块库,网址为http://forge.puppetlabs.com/,截止目前为止已经有 1943 modules(统计时间 2014-1-14),基本覆盖所有操作系统以及常用软件。

1. 在http://forge.puppetlabs.com中查找nginx模块

[root@linuxmaster1poc ~]# puppet module search nginx
Searching http://forge.puppetlabs.com ...
NAME                    DESCRIPTION                                             AUTHOR         KEYWORDS                  
7terminals-nginx        The Nginx module installs and maintains the configu...  @7terminals    nginx proxy debian rhel   
BenoitCattie-nginx                                                              @BenoitCattie  web HTTP nginx fcgi       
MiMediaINC-php_fastcgi  Configures upstart job for php5-cgi                     @MiMediaINC    ubuntu fastcgi nginx      
arioch-nginx            NGINX module                                            @arioch        nginx web reverse proxy   
cmantix-nginxphp        Install Nginx, php-fpm also php debug and build env...  @cmantix       nginx php-fpm php         
ctrlcroot-nginx         NGINX Module                                            @ctrlcroot     nginx web                 
dcoxall-wordpress       Configure PHP-FPM and NGINX for Wordpress sites.        @dcoxall       nginx mysql php-fpm php   
dhutty-nginx            This module manages the NGINX webserver                 @dhutty        web servers               
example42-nginx         Puppet module for nginx                                 @example42     nginx example42           
guilhermef-nginx        Puppet NGINX management module tornado friendly         @guilhermef                              
jbussdieker-nginx       Nginx Module                                            @jbussdieker   ubuntu nginx www web      
jfryman-nginx           Puppet NGINX management module                          @jfryman       nginx http proxy rack     
jvaubourg-nginxpack     Nginx & PHP5 (opt.), vhosts, proxies, redirections,...  @jvaubourg     nginx php php5 ssl web    
kbatra-nginx_pagespeed  Puppet module for downloading Nginx source and Goog...  @kbatra        passenger nginx psol      
kbatra-nginx_passenger  Puppet module for Nginx through Passenger               @kbatra        nginx passenger deploy    
lookatitude-zserver     Zend Server Management                                  @lookatitude   nginx apache ubuntu debian
maestrodev-nginx        Puppet NGINX management module                          @maestrodev    nginx server http         
oris-nginx              Puppet NGINX management module                          @oris                                    
ploperations-nginx      Install and manage nginx                                @ploperations  nginx unicorn php load    
puppetlabs-nginx        Puppet NGINX management module                          @puppetlabs    web proxy HTTP nginx https
rhoml-threescale        This module helps install openresty and configure 3...  @rhoml         nginx lua proxy 3scale    
salekseev-repo_nginx    Configures the NGINX Yum repository config to point...  @salekseev     centos yum nginx redhat   
spantree-nginx          Puppet NGINX management module                          @spantree      nginx                     
spuder-gitlab           Puppet GitLab Module                                    @spuder        git gitlab ruby nginx     
thias-nginx             NGINX web server module                                 @thias         nginx rhel CentOS httpd   
thias-php               PHP module                                              @thias         apache nginx php rhel     
zooz-nginx              Puppet module for nginx web server.                     @zooz          nginx fedora debian vhost 

建议使用puppetlabs和example42提供的模块进行安装

[root@linuxmaster1poc ~]# puppet module search nginx | egrep -i 'puppetlabs|example42'
Searching http://forge.puppetlabs.com ...
example42-nginx         Puppet module for nginx                                 @example42     nginx example42           
puppetlabs-nginx        Puppet NGINX management module                          @puppetlabs    web proxy HTTP nginx https

2. 安装nginx模块

安装方法: http://docs.puppetlabs.com/puppet/2.7/reference/modules_installing.html

以安装example42上nginx模块版本2.1.1为例
http://forge.puppetlabs.com/example42/nginx

2.1 从example42上安装版本为2.1.1的nginx模块,安装在本地/etc/puppet/modules目录(默认安装目录)

[root@linuxmaster1poc modules]# puppet module install example42/nginx --version 2.1.1 --modulepath=/etc/puppet/modules #下载nginx模块及依赖模块
Preparing to install into /etc/puppet/modules ...
Downloading from http://forge.puppetlabs.com ...
Installing -- do not interrupt ...
/etc/puppet/modules
└─┬ example42-nginx (v2.1.1)
  ├── example42-puppi (v2.1.7)
  └─┬ puppetlabs-concat (v1.1.0-rc1)
    └── puppetlabs-stdlib (v4.1.0)

2.2 查看安装的nginx模块

[root@linuxmaster1poc modules]# ll /etc/puppet/modules/ 
total 16
drwxr-xr-x 7 root root 4096 Jan  8 01:11 concat
drwxr-xr-x 5 root root 4096 Nov 22 16:15 nginx
drwxr-xr-x 7 root root 4096 Nov 22 17:10 puppi
drwxr-xr-x 6 root root 4096 May 13  2013 stdlib
[root@linuxmaster1poc modules]# tree /etc/puppet/modules/
/etc/puppet/modules/
├── concat
│   ├── CHANGELOG
│   ├── files
│   │   ├── concatfragments.rb
│   │   └── concatfragments.sh
│   ├── Gemfile
│   ├── Gemfile.lock
│   ├── lib
│   │   └── facter
│   │       └── concat_basedir.rb
│   ├── LICENSE
│   ├── manifests
│   │   ├── fragment.pp
│   │   ├── init.pp
│   │   └── setup.pp
│   ├── metadata.json
│   ├── Modulefile
│   ├── Rakefile
│   ├── README.md
│   ├── spec
│   │   ├── spec_helper.rb
│   │   ├── spec_helper_system.rb
│   │   ├── system
│   │   │   ├── basic_spec.rb
│   │   │   ├── concat_spec.rb
│   │   │   ├── deprecation_warnings_spec.rb
│   │   │   ├── empty_spec.rb
│   │   │   ├── fragment_source_spec.rb
│   │   │   ├── replace_spec.rb
│   │   │   ├── symbolic_name_spec.rb
│   │   │   └── warn_spec.rb
...

[root@linuxmaster1poc modules]# puppet module list
/etc/puppet/modules
├── example42-nginx (v2.1.1)
├── example42-puppi (v2.1.7)
├── puppetlabs-concat (v1.1.0-rc1)
└── puppetlabs-stdlib (v4.1.0)

[root@linuxmaster1poc modules]# puppet module list --tree #可现实模块之间的依赖关系
/etc/puppet/modules
└─┬ example42-nginx (v2.1.1)
  ├── example42-puppi (v2.1.7)
  └─┬ puppetlabs-concat (v1.1.0-rc1)
    └── puppetlabs-stdlib (v4.1.0)

2.3 升级nginx版本至2.1.2

[root@linuxmaster1poc modules]# puppet module upgrade example42/nginx --version 2.1.2 
Preparing to upgrade 'example42-nginx' ...
Found 'example42-nginx' (v2.1.1) in /etc/puppet/modules ...
Downloading from http://forge.puppetlabs.com ...
Upgrading -- do not interrupt ...
/etc/puppet/modules
└── example42-nginx (v2.1.1 -> v2.1.2)

[root@linuxmaster1poc modules]# puppet module list --tree
/etc/puppet/modules
└─┬ example42-nginx (v2.1.2)
  ├── example42-puppi (v2.1.7)
  └─┬ puppetlabs-concat (v1.1.0-rc1)
    └── puppetlabs-stdlib (v4.1.0)

2.4 删除安装的nginx模块

注:依赖模块需要手动删除
[root@linuxmaster1poc modules]# puppet module uninstall example42/nginx
Preparing to uninstall 'example42-nginx' ...
Removed 'example42-nginx' (v2.1.2) from /etc/puppet/modules
[root@linuxmaster1poc modules]# puppet module list --tree
/etc/puppet/modules
├─┬ puppetlabs-concat (v1.1.0-rc1)
│ └── puppetlabs-stdlib (v4.1.0)
└── example42-puppi (v2.1.7)    
[root@linuxmaster1poc modules]# puppet module uninstall example42/puppi
Preparing to uninstall 'example42-puppi' ...
Removed 'example42-puppi' (v2.1.7) from /etc/puppet/modules
[root@linuxmaster1poc modules]# puppet module uninstall puppetlabs/concat
Preparing to uninstall 'puppetlabs-concat' ...
Removed 'puppetlabs-concat' (v1.1.0-rc1) from /etc/puppet/modules
[root@linuxmaster1poc modules]# puppet module uninstall puppetlabs/stdlib
Preparing to uninstall 'puppetlabs-stdlib' ...
Removed 'puppetlabs-stdlib' (v4.1.0) from /etc/puppet/modules
[root@linuxmaster1poc modules]# puppet module list --tree
/etc/puppet/modules (no modules installed)
[root@linuxmaster1poc modules]# ll /etc/puppet/modules/
total 0
[root@linuxmaster1poc modules]#