这个例子完成将master节点上的一个文件放至agent节点上的功能

创建要传输的文件

echo “helloWorld” > /etc/puppet/modules/puppet-example/files/hello

不使用module

创建site.pp

直接把对agent的操作写入site.pp文件中。

touch /etc/puppet/manifests/site.pp

内容如下:

 node 'agentHostname' {
file { '/root/tmp/hello':
owner => 'root',
group => 'root',
mode => '0440',
source => 'puppet:///modules/puppet-example/hello'
}
}

启动agent

在agent上执行如下命令:

puppet agent --test

就会看到/root/tmp/hello文件了。

使用module

创建module

module的目录结构是固定的,目录的结构一般如下所示:

├── files

├── manifests

└── templates

  • files: 属于模块的文件

  • manifests: 脚本文件

  • templates:模板文件

    md -p /etc/puppet/modules/puppet-example/{files,templates,manifests}

生成init.pp文件

init.pp是模块必须要有的文件,放至在模块的manifests路径下。

touch /etc/puppet/modules/puppet-example/manifests/init.pp

class puppet-example {
file { '/root/tmp/hello':
owner => 'root',
group => 'root',
mode => '0440',
source => 'puppet:///modules/puppet-example/hello'
}
}

生成site.pp文件

touch /etc/puppet/manifests/site.pp

内容如下:

node 'agentHostname' {

include puppet-example

}

至此,文件全部创建完毕。

目录结构

最终的目录结构如下所示:

/etc/puppet# tree

├── manifests
│   └── site.pp
├── modules
│   └── puppet-example
│   ├── files
│   │   └── hello
│   ├── manifests
│   │   └── init.pp
│   └── templates
└── templates

启动agent

在agent上执行如下命令:

puppet agent --test

就会看到/root/tmp/hello文件了。

puppet的使用:puppet的hello world的更多相关文章

  1. Puppet简易入门

    一.查看官方提供的下载源 https://docs.puppet.com/guides/puppetlabs_package_repositories.html 二. 选择对应系统的下载源 因为本机是 ...

  2. 配置管理工具 Puppet的安装和使用

    今天碰到一个linux下的puppet的问题,才发现原来这个是 用ruby语言编写的自动化的管理工具.有兴趣的同学,可以学习下. 这里重点讲述下 mac下 puppet的安装方法: 在Mac下采用Gi ...

  3. [翻译]用 Puppet 搭建易管理的服务器基础架构(2)

    我通过伯乐在线翻译了一个Puppet简明教程,一共分为四部分,这是第二部分. 原文地址:http://blog.jobbole.com/87680/ 本文由 伯乐在线 - Wing 翻译,黄利民 校稿 ...

  4. [翻译]用 Puppet 搭建易管理的服务器基础架构(1)

    我通过伯乐在线翻译了一个Puppet简明教程,一共分为四部分,这是第一部分. 原文地址:http://blog.jobbole.com/87679/ 本文由 伯乐在线 - Wing 翻译,黄利民 校稿 ...

  5. Puppet安装及部署

    本篇博客主要介绍Puppet的安装部署,后续会更新其他相关内容 一.简介 二.环境介绍 三.安装Puppet 四.配置Puppet-dashboard 五.配置Puppet Kick 一.简介 Pup ...

  6. 运维自动化工具---Puppet

    案例环境:-----------------------------------------------------------------主机  操作系统   IP地址  主要软件--------- ...

  7. 烂泥:puppet添加带密码的用户

    本文由秀依林枫提供友情赞助,首发于烂泥行天下. 前一篇文章,我们介绍了有关puppet3.7的安装与配置,这篇文章我们再来介绍下如何利用puppet添加带密码的用户. 要通过puppet添加带密码的用 ...

  8. puppet的配置

    1时间问题 agent与master端务必要保持时间的一致性,最好使用ntp服务 检查ntp服务是否安装 [root@master-elk ~]# rpm -qa|grep ntp ntpdate-. ...

  9. puppet安装

    server  xuesong1     10.152.14.85 client  xuesong      10.152.14.106   系统centos5.8   两台配置都配置 /etc/ho ...

  10. puppet 安装

    yum源配置 1. wget http://ftp.kaist.ac.kr/fedora//epel/6/i386/epel-release-6-8.noarch.rpm 2. yum list | ...

随机推荐

  1. AE IRasterCursor 获取栅格图层像素值

    在编写使用栅格图层的代码时,常常要获取栅格图层的像素值(PixelValue).如果想获取某一点的像素值,可以使用IRaster2中的getPixelValue方法.但如果想要获得的是图层中的某一块甚 ...

  2. 201709011工作日记--Volley源码详解(二)

    1.Cache接口和DiskBasedCache实现类 首先,DiskBasedCache类是Cache接口的实现类,因此我们需要先把Cache接口中的方法搞明白. 首先分析下Cache接口中的东西, ...

  3. struts2从浅至深(三)拦截器

    一:拦截器概述 Struts2中的很多功能都是由拦截器完成的. 是AOP编程思想的一种应用形式. 二:拦截器执行时机                             interceptor表示 ...

  4. (线段树) Count the Colors --ZOJ --1610

    链接: http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82832#problem/F http://acm.zju.edu.cn/onli ...

  5. STL中list中push_back(对象)保存对象的内部实现

    STL中list中push_back(对象)保存对象的内部实现 1. 在容器中,存放的是对象拷贝 #include<iostream> #include<list> using ...

  6. Google Summer of Code礼包

    这个暑假参加google summer of code, 给Google的分布式容器管理系统kubernates开发新的特性,希望从中学习更多的分布式的技术,锻炼自己的编程技巧. 中午在学校的图书馆吗 ...

  7. LeetCode142:Linked List Cycle II

    题目: Given a linked list, return the node where the cycle begins. If there is no cycle, return null. ...

  8. 【 PLSQL Developer安装、tnsnames.ora配置 解答】

    使用plsql远程连接数据库需要安装plsql工具+ oracle的远程客户端 在不登录的状态打开plsql: 点击工具---首选项:指定oracle客户端的安装路径: C:\javaSoft\PLS ...

  9. Asp.net MVC Linq to SQL Model verification

    Models public class Student { public int Id { get; set; } [Required(ErrorMessage = "姓名不能为空!&quo ...

  10. item style edit in sharepoint 2013

    标题头添加属性:(如果需要使用ddwrt)xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime&quo ...