Puppet Apply Command parameter introduction (v)

Source: Internet
Author: User

Puppet Apply Command parameter Introduction

Previously said puppet two modes of operation, the first type: C/S structure, the second type: single-machine operation. Apply is a code tool that executes local *.pp files independently, and is typically used to test debug puppet code locally.


Puppet Apply Common parameters:

[[Email protected] ~]# 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|<file>|console] [--noop]  [--catalog <catalog>] [-- Write-catalog-summary] <file>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 <class> ,<tag> ' 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:         #调试模式, Debug information for output execution   enable full debugging.* --detailed-exitcodes: #提供退出代码的信息, 2 means code changes, 4 means failure, 6 there are both.   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:     #加载任何存储的类, usually puppet agent class configuration is cached in/etc/puppet/classes.txt, Setting this parameter causes all selected classes to be set in the puppet  list .  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:         #只运行代码, Do not apply 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后, save the list of resources and the list of classes to the node.   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


Example:

Install Apache locally using puppet.

[[email protected] ~]# rpm-qa httpd[[email protected] ~]# vim Httpd.pp[[email protected] ~]# cat httpd.pp Package {"httpd ": ensure = True,} #应用本地httpd. pp code file [[email protected] ~]# 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# confirm installed [[email protected] ~]# Rpm-qa httpdhttpd-2.2.15-60.el6.centos.5.x86_64

--verbose Parameters:

[Email protected] ~]# puppet apply httpd.pp--verbosenotice:compiled Catalog for Sh-proxy2.localdomain in environment PR Oduction in 0.12 secondsinfo:applying configuration version ' 1504671755 ' Notice:/stage[main]/main/package[httpd]/ ensure:createdNotice:Finished catalog run in 3.51 seconds

--execute Parameters:

#test模块下test类. [Email protected] manifests]# pwd/etc/puppet/modules/test/manifests[[email protected] manifests]# lsinit.pp# The module must have a init.pp file that declares a class with the same name as the module. [[email protected] manifests]# cat Init.pp class Test {package {"httpd": ensure = True,}}

-E is equivalent to the--execute parameter parameter, and the class wants to use an include that must declare the class.

[Email protected] manifests]# puppet apply-e "include test" notice:compiled catalog for Sh-proxy2.localdomain in Environ ment production in 0.15 secondsnotice:/stage[main]/test/package[httpd]/ensure:creatednotice:finished catalog run in 3. Seconds[[email protected] manifests]# Rpm-qa httpdhttpd-2.2.15-60.el6.centos.5.x86_64


Example 2:

The Notify resource Output command.

Note: The Notify command in Puppet is similar to echo in the shell, which prints the results of the code execution through the screen terminal.

[[email protected] ~]# cat test.pp notify {"Hello World":}[[email protected] ~]# puppet apply test.pp notice:compiled cat Alog for Sh-proxy2.localdomain in environment production in 0.02 Secondsnotice:hello Worldnotice:/stage[main]/main/noti Fy[hello world]/message:defined ' message ' as ' Hello World ' notice:finished catalog run in 0.01 seconds


This article is from the "green shirt and clothes" blog, please make sure to keep this source http://215687833.blog.51cto.com/6724358/1963705

Puppet Apply Command parameter introduction (v)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.