Puppet apply 命令参数介绍

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

puppet apply常用参数:

[root@sh-proxy2 ~]# puppet apply -h
puppet-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 apply
individual manifests.
When provided with a modulepath, via command line or config file, puppet
apply can effectively mimic the catalog that would be served by puppet
master with access to the same modules, although there are some subtle
differences. When combined with scheduling and an automated system for
pushing manifests, this can be used to implement a serverless Puppet
site.
Most users should use 'puppet agent' and 'puppet master' for site-wide
manifests.
OPTIONS
-------
Note that any setting that's valid in the configuration
file is also a valid long argument. For example, 'tags' is a
valid setting, so you can specify '--tags <class>,<tag>'
as an argument.
See the configuration file documentation at
http://docs.puppetlabs.com/references/stable/configuration.html for the
full list of acceptable parameters. A commented list of all
configuration 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 exitcode of '2' means there were changes, an exit code of '4' means there werefailures during the transaction, and an exit code of '6' means there were bothchanges 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 causesall of those classes to be set in your puppet manifest.
* --logdest:        #日志路径Where to send log messages. Choose between 'syslog' (the POSIX syslogservice), 'eventlog' (the Windows Event Log), 'console', or the path to a logfile. Defaults to 'console'.A path ending with '.json' will receive structured output in JSON format. Thelog file will not have an ending ']' automatically written to it due to theappending nature of logging. It must be appended manually to make the contentvalid JSON.
* --noop:        #只运行代码,不应用catalogUse 'noop' mode where Puppet runs in a no-op or dry-run mode. Thisis useful for seeing what changes Puppet will make without actuallyexecuting 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:#catalogApply a JSON catalog (such as one generated with 'puppet master --compile'). You caneither 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 nodein the state directory named classes.txt and resources.txt
EXAMPLE
-------$ puppet apply -l /tmp/manifest.log manifest.pp$ puppet apply --modulepath=/root/dev/modules -e "include ntpd::server"$ puppet apply --catalog catalog.json
AUTHOR
------
Luke Kanies
COPYRIGHT
---------
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 seconds
Notice: /Stage[main]/Main/Package[httpd]/ensure: created
Notice: Finished catalog run in 12.67 seconds
#确认已经安装
[root@sh-proxy2 ~]# rpm -qa httpd
httpd-2.2.15-60.el6.centos.5.x86_64

--verbose参数:

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

--execute参数:

#test模块下test类.
[root@sh-proxy2 manifests]# pwd
/etc/puppet/modules/test/manifests
[root@sh-proxy2 manifests]# ls
init.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 seconds
Notice: /Stage[main]/Test/Package[httpd]/ensure: created
Notice: Finished catalog run in 3.11 seconds
[root@sh-proxy2 manifests]# rpm -qa httpd
httpd-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 seconds
Notice: hello world
Notice: /Stage[main]/Main/Notify[hello world]/message: defined 'message' as 'hello world'
Notice: Finished catalog run in 0.01 seconds

转载于:https://blog.51cto.com/215687833/1963705

Puppet apply命令参数介绍(五)相关推荐

  1. Puppet 命令参数介绍(三)

    Puppet 命令参数介绍 前言: Puppet的工作原理: puppet master启动默认是监听tcp协议的8140端口.通过ruby的webrick web接收agent端的请求,根据请求内容 ...

  2. HDFS命令行客户端使用,命令行客户端支持的命令参数,常用命令参数介绍

    3.HDFS的shell(命令行客户端)操作 3.1 HDFS命令行客户端使用 HDFS提供shell命令行客户端,使用方法如下: [toto@hadoop hadoop-2.8.0]$ hdfs d ...

  3. ansible命令参数介绍

    ansible命令参数介绍 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 -m:要执行的模块,默认为command -a:模块的参数 -u:ssh连接 ...

  4. HDFS的简介及基本操作(常用的命令参数介绍)

    目录 前言: 1.HDFS基本概念 2.HDFS基本操作 总结: 目录 前言: 总算有空来接着写大数据的学习笔记了,今天就把之前学过的HDFS的基础知识详细的介绍一下,如有哪点写的不足希望大家多多指教 ...

  5. 第五章 Mininet常用命令参数介绍

    mn 观察,可以知道,已经进入了这个自带的网络,网络中有1个交换机和2个主机,且在打开这个网络之后,进入了  mininet>  这个命令模式 然后输入相关命令查看网络状态,如下图所示: 查看可 ...

  6. linux编程参数列表,Linux编程 14 文件权限(用户列表passwd,用户控制shadow,useradd模板与useradd命令参数介绍)...

    一. 概述 linux安全系统的核心是用户账户. 创建用户时会分配用户ID(UID). UID是唯一的,但在登录系统时不是用UID,而是用登录名.在讲文件权限之之前,先了解下linux是怎样处理用户账 ...

  7. Ubuntu18.04系统下,gcc编译过程分析、命令参数介绍及ELF文件格式学习

    GCC编译器背后的故事及常用命令.了解ELF文件格式 文章目录 GCC编译器背后的故事及常用命令.了解ELF文件格式 前言 一.GCC简介 二.GCC背后的战友 1.Binutils 2.C运行库 三 ...

  8. Mysqldump命令参数介绍

    mysqldump命令参数 mysql  mysqldump客户端可用来转储数据库或搜集数据库进行备份或将数据转移到另一个SQL服务器(不一定是一个MySQL服务器).转储包含创建表和/或装载表的SQ ...

  9. Hadoop常用命令参数介绍

    常用命令 - help 功能:输出这个命令参数手册 - ls 功能:显示目录信息 示例:hadoop fs -ls hdfs://hadoop-hello/ 备注:这些参数中,所有的hdfs路径都可以 ...

  10. Ping命令 参数介绍!

    Ping命令详解 对于Windows下ping命令相信大家已经再熟悉不过了,但是能把ping的功能发挥到最大的人却并不是很多,当然我也并不是说我可以让ping发挥最大的功能,我也只不过经常用ping这 ...

最新文章

  1. 清华 Aminer 发布最新2018人脸识别研究报告
  2. vue 路由传参 params 与 query两种方式的区别(转载)
  3. WatchOS系统开发大全(8)-WKInterfaceGroup
  4. mac mysql-python 失败_MAC OS安装MySQL-python总是失败,请帮忙看看什么原因?
  5. html5 页面答题算分,JavaScript实现答题评分功能页面
  6. 并行计算课程上机作业
  7. 矩阵连乘备忘录算法java_矩阵连乘(备忘录方法:自顶向下递归)
  8. 相机和镜头选型计算公式
  9. Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Access denied for user
  10. 手游虚拟机服务器,手游剑侠情缘虚拟机镜像一键服务端+安卓客户端+远程工具+架设教程...
  11. MicroStation里CASS地形数据生成三维地形模型
  12. 升级Mac Catalina后OBS录屏软件麦克风和内置声音输出没有声音的问题
  13. 链表的基本操作(C语言)
  14. oracle日期导出mysql_Oracle 获取系统日期时间,导出数据库
  15. 雅思IELTS精讲——【作文】
  16. Linux 企业级安全原理和防范技巧
  17. 问下大家,chorme里用开发者工具看headers,点network标签然后刷新网页并没有headers选项,怎么破?...
  18. 单片机学习(二)——继电器
  19. 8.跨阻放大器TIA的阻抗:无穷大还是零? 究竟是什么?
  20. halcon提取桔子(橙子)

热门文章

  1. [HAOI2007] 修筑绿化带
  2. python 将字符串转换为字典
  3. Vuejs2.0学习之二(Render函数,createElement,vm.$slots,函数化组件,模板编译,JSX)...
  4. IT部门域事件与业务分析
  5. 30个免费网页设计模板
  6. 考研编程练习----开门人和关门人
  7. 百度2013校园招聘移动软件研发工程师笔试题(一)
  8. 常用正则表达式(不断更新ing...)
  9. 天津东软实训第八天------倒排索引
  10. C++面向对象高级编程(上) 第一周笔记 GeekBand