博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Puppet apply命令参数介绍(五)
阅读量:7076 次
发布时间:2019-06-28

本文共 5703 字,大约阅读时间需要 19 分钟。

Puppet apply 命令参数介绍

之前说过puppet的两种运行方式,第一种:c/s结构,第二种:单机运行。apply就是单独执行本地*.pp文件的代码工具,通常用于本地测试调试puppet代码.

puppet apply常用参数:

[root@sh-proxy2 ~]# puppet apply -hpuppet-apply(8) -- Apply Puppet manifests locally========SYNOPSIS--------Applies a standalone Puppet manifest to the local system.USAGE-----puppet apply [-h|--help] [-V|--version] [-d|--debug] [-v|--verbose]  [-e|--execute] [--detailed-exitcodes] [-L|--loadclasses]  [-l|--logdest syslog|eventlog|
|console] [--noop]  [--catalog 
] [--write-catalog-summary] 
DESCRIPTION-----------This is the standalone puppet execution tool; use it to applyindividual manifests.When provided with a modulepath, via command line or config file, puppetapply can effectively mimic the catalog that would be served by puppetmaster with access to the same modules, although there are some subtledifferences. When combined with scheduling and an automated system forpushing manifests, this can be used to implement a serverless Puppetsite.Most users should use 'puppet agent' and 'puppet master' for site-widemanifests.OPTIONS-------Note that any setting that's valid in the configurationfile is also a valid long argument. For example, 'tags' is avalid setting, so you can specify '--tags 
,
'as an argument.See the configuration file documentation athttp://docs.puppetlabs.com/references/stable/configuration.html for thefull list of acceptable parameters. A commented list of allconfiguration options can also be generated by running puppet with'--genconfig'.* --debug:        #调试模式,输出执行过程的调试信息  Enable full debugging.* --detailed-exitcodes:#提供退出代码的信息,2表示代码有变化,4表示失败,6两者都有.  Provide transaction information via exit codes. If this is enabled, an exit  code of '2' means there were changes, an exit code of '4' means there were  failures during the transaction, and an exit code of '6' means there were both  changes and failures.* --help:  Print this help message* --loadclasses:    #加载任何存储的类,通常puppet agent类配置缓存在/etc/puppet/classes.txt,设置这个参数导致所有选择的类将设置在puppet 清单中.  Load any stored classes. 'puppet agent' caches configured classes  (usually at /etc/puppet/classes.txt), and setting this option causes  all of those classes to be set in your puppet manifest.* --logdest:        #日志路径  Where to send log messages. Choose between 'syslog' (the POSIX syslog  service), 'eventlog' (the Windows Event Log), 'console', or the path to a log  file. Defaults to 'console'.  A path ending with '.json' will receive structured output in JSON format. The  log file will not have an ending ']' automatically written to it due to the  appending nature of logging. It must be appended manually to make the content  valid JSON.* --noop:        #只运行代码,不应用catalog  Use 'noop' mode where Puppet runs in a no-op or dry-run mode. This  is useful for seeing what changes Puppet will make without actually  executing the changes.* --execute:        #执行一段puppet代码  Execute a specific piece of Puppet code* --test:        #启用测试  Enable the most common options used for testing. These are 'verbose',  'detailed-exitcodes' and 'show_diff'.* --verbose:        #打印详细执行过程  Print extra information.* --catalog:#catalog  Apply a JSON catalog (such as one generated with 'puppet master --compile'). You can  either specify a JSON file or pipe in JSON from standard input.* --write-catalog-summary        #编译完catalog后,将资源列表和类列表保存到节点。  After compiling the catalog saves the resource list and classes list to the node  in the state directory named classes.txt and resources.txtEXAMPLE-------    $ puppet apply -l /tmp/manifest.log manifest.pp    $ puppet apply --modulepath=/root/dev/modules -e "include ntpd::server"    $ puppet apply --catalog catalog.jsonAUTHOR------Luke KaniesCOPYRIGHT---------Copyright (c) 2011 Puppet Labs, LLC Licensed under the Apache 2.0 License

举例:

本地使用puppet 安装apache.

[root@sh-proxy2 ~]# rpm -qa httpd[root@sh-proxy2 ~]# vim httpd.pp[root@sh-proxy2 ~]# cat httpd.pp package {"httpd":ensure => true,}#应用本地httpd.pp代码文件[root@sh-proxy2 ~]# puppet apply httpd.pp Notice: Compiled catalog for sh-proxy2.localdomain in environment production in 0.18 secondsNotice: /Stage[main]/Main/Package[httpd]/ensure: createdNotice: Finished catalog run in 12.67 seconds#确认已经安装[root@sh-proxy2 ~]# rpm -qa httpdhttpd-2.2.15-60.el6.centos.5.x86_64

--verbose参数:

[root@sh-proxy2 ~]# puppet apply httpd.pp --verboseNotice: Compiled catalog for sh-proxy2.localdomain in environment production in 0.12 secondsInfo: Applying configuration version '1504671755'Notice: /Stage[main]/Main/Package[httpd]/ensure: createdNotice: Finished catalog run in 3.51 seconds

--execute参数:

#test模块下test类.[root@sh-proxy2 manifests]# pwd/etc/puppet/modules/test/manifests[root@sh-proxy2 manifests]# lsinit.pp#模块下必须有init.pp文件声明一个和模块同名的类.[root@sh-proxy2 manifests]# cat init.pp class test {    package {"httpd":        ensure => true,    }}

-e等同于--execute参数参数,类要想使用必须声明类使用include.

[root@sh-proxy2 manifests]# puppet apply -e "include test"Notice: Compiled catalog for sh-proxy2.localdomain in environment production in 0.15 secondsNotice: /Stage[main]/Test/Package[httpd]/ensure: createdNotice: Finished catalog run in 3.11 seconds[root@sh-proxy2 manifests]# rpm -qa httpdhttpd-2.2.15-60.el6.centos.5.x86_64

举例2:

notify 资源输出命令. 

注意:puppet中的notify命令和shell中的echo相似,都是将代码执行结果通过屏幕终端打印出来.

[root@sh-proxy2 ~]# cat test.pp notify {"hello world":}[root@sh-proxy2 ~]# puppet apply test.pp Notice: Compiled catalog for sh-proxy2.localdomain in environment production in 0.02 secondsNotice: hello worldNotice: /Stage[main]/Main/Notify[hello world]/message: defined 'message' as 'hello world'Notice: Finished catalog run in 0.01 seconds

转载地址:http://rddml.baihongyu.com/

你可能感兴趣的文章
云计算与网格计算的深入比较
查看>>
《VMware Virtual SAN权威指南》一2.3.3 二层或三层
查看>>
《计算机科学与工程导论:基于IoT和机器人的可视化编程实践方法第2版》一1.1.2 计算机就业形势分析...
查看>>
同济大学博导陈明:解读中国制造2025
查看>>
中国少年儿童新闻出版总社CIO:快乐工作
查看>>
一款成熟的数据中心模型设计
查看>>
论坛程序vBulletin 5曝漏洞 可能已泄露千万用户数据
查看>>
大数据资源争夺战此起彼伏 对用户而言是福是祸?
查看>>
一文读懂分布式系统
查看>>
Flask中的请求上下文和应用上下文
查看>>
Web应用防护系统OpenWAF开源CC防护模块
查看>>
重拾百度定位之踩坑篇(上)
查看>>
联想Luigi Brochard:高性能计算三大战略, 推动人工智能飞速发展
查看>>
芒果贴冯振:我是怎么做老年人产品的
查看>>
软银集团任命新董事 ARM与Sprint CEO正式进入董事会
查看>>
“630”后市场急冷 台湾光伏企业营收下滑
查看>>
Facebook调整动态消息算法:更加重视朋友家人的帖子
查看>>
内蒙古云计算 向国家级基地迈进
查看>>
中生代嘉年华 | OKR管理
查看>>
详解让乌克兰总理都“哭泣”的勒索病毒,你到底要不要怕
查看>>