chef 配置之 Templates

chef template 简单例子

cat nginx_config.rb

.....template ‘/etc/nginx/nginx.conf‘ do
  source ‘nginx.conf.erb‘
  owner ‘root‘
  group ‘root‘
  mode ‘0644‘
end.......
/etc/nginx/nginx.conf 目标文件位置
nginx.conf.erb 模板文件

puppet 是这样表达的

file{"nginx.conf":
ensure => present,
mode => 644,owner => root,group => root,
path => "/etc/nginx/nginx.conf",
content=> template("nginx/nginx.conf.erb"),
require=> Package["nginx"],
}

简单对比下方便理解

chef template的resource

template ‘name‘ do
  atomic_update              TrueClass, FalseClass
  backup                     FalseClass, Integer
  cookbook                   String
  force_unlink               TrueClass, FalseClass
  group                      String, Integer
  helper(:method)            Method { String } # see Helpers below
  helpers(module)            Module # see Helpers below
  inherits                   TrueClass, FalseClass
  local                      TrueClass, FalseClass
  manage_symlink_source      TrueClass, FalseClass, NilClass
  mode                       String, Integer
  notifies                   # see description
  owner                      String, Integer
  path                       String # defaults to ‘name‘ if not specified
  provider                   Chef::Provider::File::Template
  rights                     Hash
  sensitive                  TrueClass, FalseClass
  source                     String, Array
  subscribes                 # see description
  variables                  Hash
  verify                     String, Block
  action                     Symbol # defaults to :create if not specified
end
  • template is the resource
  • name is the name of the resource block, typically the path to the location in which a file is created and also the name of the file to be managed. For example: /var/www/html/index.html, where /var/www/html/ is the fully qualified path to the location and index.html is the name of the file
  • source is the template file that will be used to create the file on the node, for example: index.html.erb; the template file is located in the /templates directory of a cookbook
  • :action identifies the steps the chef-client will take to bring the node into the desired state
  • atomic_updatebackupcookbookforce_unlinkgrouphelperhelpersinheritslocalmanage_symlink_sourcemodeowner,pathproviderrightssensitivesourcevariables, and verify are properties of this resource, with the Ruby type shown. See “Properties” section below for more information about all of the properties that may be used with this resource.
时间: 2024-08-10 17:19:24

chef 配置之 Templates的相关文章

django settings配置templates和static

我们用django创建项目后,一般需要在$PROJECT/$PROJECT/settings.py文件中做些配置,例如配置templates和static目录的路径 templates的配置: TEMPLATES = [     {         'BACKEND': 'django.template.backends.django.DjangoTemplates',         'DIRS': [os.path.join(BASE_DIR,'templates')],         '

从图形界面配置zabbix

以admin权限用户登录: configuration -> host groups -> create host group administration->users -> create user group, 在permission tab页中关联上一步建立的host group administration->users -> create user, 关联前一步建立的user group 退出admin账户,登录新user开始配置 configuration

深入浅出Zabbix 3.0 -- 第七章 模板配置与管理

第七章  模板配置与管理 我们在主机中不仅可以添加很多需要监控的指标(即监控项),还可以添加图形.触发器.监控项组.展示屏.Web scenarios和low-level Discovery,如果在每个主机中添加这些对象,尤其是在一个大型环境中,其工作量是不可想象的,何况需要监控的主机有很多具有相同的监控属性,需要重复相同的配置工作,如果手工完成这些配置任务几乎是不可能的.好在Zabbix为我们提供了模板,通过在不同的模板中添加监控项.触发器.图形等配置并应用到任意数量的主机上.当然对于特殊的监

四 Django框架,models.py模块,数据库操作——创建表、数据类型、索引、admin后台,补充Django目录说明以及全局配置文件配置

Django框架,models.py模块,数据库操作--创建表.数据类型.索引.admin后台,补充Django目录说明以及全局配置文件配置 数据库配置 django默认支持sqlite,mysql, oracle,postgresql数据库. 1,django默认使用sqlite的数据库,默认自带sqlite的数据库驱动   引擎名称:django.db.backends.sqlite3 在全局配置文件settings.py可以看到确认配置使用的sqlite数据库 # Database # h

MyEclipse个性化配置

转载自:http://blog.csdn.net/chen_zw/article/details/18728529 MyEclipse个性化配置 1.修改项目文件默认编码 Note:myEclipse默认的编码是GBK, 也就是未设置编码格式的文件都默认使用GBK进行编码, 而更糟糕的是JSP.JavaScriptt默认编码竟然是ISO-8859-1,我们知道ISO-8859-1是不支持中文字符的,所以我们必须修改项目文件的默认编码.         步骤一.修改缺省默认编码:[window]-

Django 配置信息 ,新手三件套,orm简单应用

Django 配置信息 创建了app,要在配置文件中注册 python3 mangage.py startapp app 创建app项目然后注册 模板路径配置: 1 templates文件夹 2 settings里注册一下 TEMPLATES = [ 'DIRS': [os.path.join(BASE_DIR, 'templates'),] ] 静态文件配置: 1 STATIC_URL = '/static/' 一般不要改 2 创建一个static文件夹(放cs/js/图片/各种文件夹) 一般

Django文件配置及orm

http协议 -特点: 1 基于TCP/IP协议之上的应用层协议 2 基于请求-响应模式 3 无状态保存 4 无连接 -请求头: 请求首行 get / http/1.1\r\n key:value\r\n key:value\r\n \r\n 请求体的内容 -响应头: 响应首行 http/1.1 200 ok \r\n 响应头: key:value\r\n \r\n 响应体: html的代码 -状态码: 1开头(正在处理) 2开头(处理完毕) 3开头(重定向) 4开头(客户端问题) 5开头(服务

Django-下载安装-配置-创建django项目-三板斧简单使用

目录 Django 简介 使用 django 的注意事项 计算机名不能有中文 Django版本问题 django下载安装 在命令行下载安装 在pycharm图形界面下载安装 检验是否安装成功 创建Django项目 命令行下创建与启动 pycharm下创建与启动 django项目目录介绍 新建应用(app)特别注意***** 配置文件 settings.py 解析 django小白必会三板斧 HttpResponse 举例 render 举例(可传数据模板渲染) redirect 案例 Djang

Django知识点总结

一.什么是web框架? 框架,即framework,特指为解决一个开放性问题而设计的具有一定约束性的支撑结构,使用框架可以帮你快速开发特定的系统,简单地说,就是你用别人搭建好的舞台来做表演. web应用  访问请求流程 *浏览器发送一个HTTP请求: *服务器收到请求,生成一个HTML文档(待补充:是否是全部类型的访问都需要生成文档): *服务器把HTML文档作为HTTP响应的Body发送给浏览器: *浏览器收到HTTP响应,从HTTP Body取出HTML文档并解析显示 对于所有的Web应用,