puppet module是puppet的基础模块工具,agent和master都可以使用,主要包含下载、更新、查找、升级、创建等功能.它可以从Puppetforge上查找已经开发好的puppet基础模块代码为我们使用,不需要自己再去编写,提升工作效率.
查看puppet module的帮助信息:
[root@puppet ~]# puppet help moduleUSAGE: puppet module[--environment production ][--modulepath $basemodulepath ]This subcommand can find, install, and manage modules from the Puppet Forge,a repository of user-contributed Puppet code. It can also generate emptymodules, and prepare locally developed modules for release on the Forge.OPTIONS: --render-as FORMAT - The rendering format to use. --verbose - Whether to log verbosely. --debug - Whether to log debug information. --environment production - The environment Puppet is running in. For clients (e.g., `puppet agent`) this determines the environment itself, which is used to find modules and much more. For servers (i.e., `puppet master`) this provides the default environment for nodes we know nothing about. --modulepath $basemodulepath - The search path for modules, as a list of directories separated by the system path separator character. (The POSIX path separator is ':', and the Windows path separator is ';'.) Setting a global value for `modulepath` in puppet.conf is deprecated. Please use directory environments instead. If you need to use something other than the default modulepath of ` :$basemodulepath`, you can set `modulepath` in environment.conf. For more info, see http://docs.puppetlabs.com/puppet/latest/reference/environments.htmlACTIONS: build Build a module release package. changes Show modified files of an installed module. generate Generate boilerplate for a new module. install Install a module from the Puppet Forge or a release archive. list List installed modules search Search the Puppet Forge for a module. uninstall Uninstall a puppet module. upgrade Upgrade a puppet module.See 'puppet man module' or 'man puppet-module' for full help.
build 构建模块源码软件包
changes显示一个已经安装的模块的改变
generate 创建一个新的模块
install 从puppet forge安装一个模块
list 查找模块
uninstall 卸载模块
upgrade 升级一个模块
#查看本地安装的puppet模块
[root@puppet ~]# puppet module list/etc/puppet/modules (no modules installed)/usr/share/puppet/modules (no modules installed)
#搜索vmware-vcenter模块
[root@puppet ~]# puppet module search vmware-vcenterNotice: Searching https://forgeapi.puppetlabs.com ...NAME DESCRIPTION AUTHOR KEYWORDS vmware-vcenter VMware vCenter puppet module @vmware vmware vcenter
#安装vmware-vcenter模块
[root@puppet ~]# puppet module install vmware-vcenterNotice: Preparing to install into /etc/puppet/modules ...Notice: Downloading from https://forgeapi.puppetlabs.com ...Notice: Installing -- do not interrupt .../etc/puppet/modules└─┬ vmware-vcenter (v0.10.0) ├── nanliu-staging (v1.0.3) ├── puppetlabs-stdlib (v4.19.0) └── vmware-vmware_lib (v0.7.0)
#卸载vmware-vcenter模块
[root@puppet ~]# puppet module uninstall vmware-vcenterNotice: Preparing to uninstall 'vmware-vcenter' ...Removed 'vmware-vcenter' (v0.10.0) from /etc/puppet/modules
generate参数创建一个模块,名为example-meng
[root@puppet ~]# puppet module generate example-mengWe need to create a metadata.json file for this module. Please answer thefollowing questions; if the question is not applicable to this module, feel freeto leave it blank.
#这个模块的版本,默认为0.1.0.
Puppet uses Semantic Versioning (semver.org) to version modules.What version is this module? [0.1.0]--> #这个模块谁写的?Who wrote this module? [example]--> example-meng#这个模块属于哪个许可机构?What license does this module code fall under? [Apache 2.0]--> apache#一句话描述这个模块?How would you describe this module in a single sentence?--> My name is meng#这个模块的源码仓库在哪?Where is this module's source code repository?--> /tmp #其他人去哪学习这个模块?Where can others go to learn more about this module?--> 51cto.com#关于这个模块的文件问题去哪解决?Where can others go to file issues about this module?--> no ----------------------------------------{ "name": "example-meng", "version": "0.1.0", "author": "example-meng", "summary": "My name is meng", "license": "apache", "source": "/tmp", "issues_url": "no", "project_page": "51cto.com", "dependencies": [ {"version_requirement":">= 1.0.0","name":"puppetlabs-stdlib"} ]}----------------------------------------About to generate this metadata; continue? [n/Y]--> yNotice: Generating module at /root/example-meng...Notice: Populating templates...Finished; module generated in example-meng.example-meng/Gemfileexample-meng/specexample-meng/spec/classesexample-meng/spec/classes/init_spec.rbexample-meng/spec/spec_helper.rbexample-meng/testsexample-meng/tests/init.ppexample-meng/manifestsexample-meng/manifests/init.ppexample-meng/README.mdexample-meng/metadata.jsonexample-meng/Rakefile