puppet module是puppet的基础模块工具,agent和master都可以使用,主要包含下载、更新、查找、升级、创建等功能.它可以从Puppetforge上查找已经开发好的puppet基础模块代码为我们使用,不需要自己再去编写,提升工作效率.
查看puppet module的帮助信息:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
[root@puppet ~] # puppet help module
USAGE: puppet module <action> [--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 empty modules, 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 `<ACTIVE ENVIRONMENT'S
MODULES DIR>:$basemodulepath`, you can set
`modulepath` in environment.conf. For more
info, see
http: //docs .puppetlabs.com /puppet/latest/reference/environments .html
ACTIONS: 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模块
1
2
3
|
[root@puppet ~] # puppet module list
/etc/puppet/modules (no modules installed)
/usr/share/puppet/modules (no modules installed)
|
#搜索vmware-vcenter模块
1
2
3
4
|
[root@puppet ~] # puppet module search vmware-vcenter
Notice: Searching https: //forgeapi .puppetlabs.com ...
NAME DESCRIPTION AUTHOR KEYWORDS vmware-vcenter VMware vCenter puppet module @vmware vmware vcenter |
#安装vmware-vcenter模块
1
2
3
4
5
6
7
8
9
|
[root@puppet ~] # puppet module install vmware-vcenter
Notice: 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模块
1
2
3
|
[root@puppet ~] # puppet module uninstall vmware-vcenter
Notice: Preparing to uninstall 'vmware-vcenter' ...
Removed 'vmware-vcenter' (v0.10.0) from /etc/puppet/modules
|
generate参数创建一个模块,名为example-meng
1
2
3
4
|
[root@puppet ~] # puppet module generate example-meng
We need to create a metadata.json file for this module. Please answer the
following questions; if the question is not applicable to this module, feel free
to leave it blank. |
#这个模块的版本,默认为0.1.0.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
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 ]
--> y Notice: Generating module at /root/example-meng ...
Notice: Populating templates... Finished; module generated in example-meng.
example-meng /Gemfile
example-meng /spec
example-meng /spec/classes
example-meng /spec/classes/init_spec .rb
example-meng /spec/spec_helper .rb
example-meng /tests
example-meng /tests/init .pp
example-meng /manifests
example-meng /manifests/init .pp
example-meng /README .md
example-meng /metadata .json
example-meng /Rakefile
|
本文转自青衫解衣 51CTO博客,原文链接:http://blog.51cto.com/215687833/1963792