puppet

Puppet,Chef,Ansible的共性

前提是你 提交于 2019-12-18 16:03:19
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 本文试图找到类似Puppet、Chef、Ansible这样自动化配置管理工具的共性,以不至于迷失在杂乱的尘世中。总会有各种人为各种目的造 概念 ,来让世界更复杂。 本文同样适用于没有运维经验的人。因为我就是一个没有运维经验的人。欢迎斧正。 与这仨之间的历史 本人接触自动化运维的时间比较晚,也就一年前才知道Puppet及自动化运维(只限于知道),而Chef、Ansible就更晚了。然而在学习它们之前,我对运维要做哪些事情并没有概念。这就对我学习Puppet,Chef和Ansible造成的障碍。因为不知道这三个工具在运维领域的位置,解决运维过程中的哪些问题。我对这三个工具的最初印象就是有了它们,不用我手工的SSH上服务器,然后一条条命令去执行安装软件,不用SCP war包上服务器等,对服务器的操作都可以自动化了。 这个最初印象也就是我跟它们的历史。为什么要说这些呢?就是因为这个最初印象,让我觉得它们是有共性。所谓共性就是存在一些共通的概念或原理之类的东西,掌握这些“东西”,我就可以站在一个更高的高度去思考。Puppet, Chef, Ansible都是工具,对于工具来说,共性指的是它们共同要解决的问题。 但是当我翻了不少文章后依然没有结果。所以,我决定自己去找它们的共性,并记录下来。 自制一个自动化运维工具

puppet自动化运维之tag标签

早过忘川 提交于 2019-12-18 15:37:42
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 标签能更好的让puppet识别一段代码。同时,客户端也可以执行指定的tag,而不需要全部都执行。 tag 元参数 ,用于标签资源; tag 函数 ,用于标签容器; tagged 函数 ,用于判断一个容器,是否有某个标签,即用于检查 tag 函数。 puppet 的自动分配标签分两种:资源和容器。默认是以自己的类型,作为标签名。 资源 自动分配标签的特点: ①自己的资源类型; ② title ; ③所在容器的类型; ④所在容器的 tital 和每个命名空间; ⑤继承的 tag 。 容器 自动分配标签的特点: ①自己的类型; ② title 和每个命名空间; ③所在容器的类型; ④所在容器的 tital 和每个命名空间; ⑤继承的 tag 。 注:凡 title 的内容有“ / ”,该 title 不会被添加为标签名。 #title 含 / file {"/tmp/filebucket": ensure => file, content => "hello wrold", } #title 不含 / file {"filebucket": ensure => file, content => "hello wrold", path => "/tmp/filebucke ", } ①.tag元参数: 一般用于,

puppet自动化运维之cron资源

烈酒焚心 提交于 2019-12-18 15:09:03
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 每一个cron资源需要一个 command属性 和 user属性 以及至少一个 周期属性 (hour, minute, month, monthday, weekday)。 计划任务的名字不是计划任务的一部分 ,它是puppet用来存储和检索该资源。假如你指定了一个除了名字其他的都和一个已经存在的计划任务相同,那么这两个计划任务被认为是等效的,并且新名字将会永久地与该计划任务相关联。一旦这种关联建立并写入磁盘之后,你就可以方便的进行计划任务的管理了。可以通过文件的方式来管理计划任务也可以通过计划任务格式来管理计划任务。 随机数: minute => inline_template("<%= hostname.hash % 60 %>"), hour => inline_template("<%= (hostname+name).hash.abs % 24 %>"), 时间参数: 分 时 日 月 周 命令 minute hour month monthday weekday command 格式: cron {"title": ensure => {present|absent}, #present不存在,则添加;absent存在,则删除 command => " 命令", #欲执行的命令或脚本路径,也可不写

Puppet/Facter “Could not retrieve fact fqdn”: How to fix or circumvent?

房东的猫 提交于 2019-12-18 10:27:18
问题 I'm learning about puppet and trying to experiment with it on a VM at home. I'm not using a puppet server yet, just running things locally. It works okay, but every time I run puppet apply ... , I get a delay of several seconds, after which it displays the message warning: Could not retrieve fact fqdn I assume the message is linked to the delay, and I want to get rid of it (the delay--I can live with the message). Googling for a solution seems to indicate that it's somehow related to DNS

Puppet/Facter “Could not retrieve fact fqdn”: How to fix or circumvent?

回眸只為那壹抹淺笑 提交于 2019-12-18 10:27:13
问题 I'm learning about puppet and trying to experiment with it on a VM at home. I'm not using a puppet server yet, just running things locally. It works okay, but every time I run puppet apply ... , I get a delay of several seconds, after which it displays the message warning: Could not retrieve fact fqdn I assume the message is linked to the delay, and I want to get rid of it (the delay--I can live with the message). Googling for a solution seems to indicate that it's somehow related to DNS

Puppet manifest has a file declaration that somehow duplicates itself

被刻印的时光 ゝ 提交于 2019-12-18 09:01:48
问题 Given the confusing error message: err: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate declaration: File[/etc/logstash/conf.d] is already declared in file /var/lib/puppet/envs/SYS_15378/modules/logstash/manifests/config.pp at line 54; cannot redeclare at /var/lib/puppet/envs/SYS_15378/modules/logstash/manifests/config.pp:54 on node foo.bar.com Questions: If this is really duplicating a file, how do I go about debugging it (finding the file)? If not... what is

Set Environment Variables with Puppet

﹥>﹥吖頭↗ 提交于 2019-12-18 03:51:23
问题 I am using vagrant with puppet to set up virtual machines for development environments. I would like to simply set a few environment variables in the .pp file. Using virtual box and a vagrant base box for Ubuntu 64 bit. I have this currently. $bar = 'bar' class foobar { exec { 'foobar': command => "export Foo=${bar}", } } but when provisioning I get an error: Could not find command 'export'. This seems like it should be simple enough am I missing some sort of require or path for the exec type

How to iterate over an array in Puppet

感情迁移 提交于 2019-12-17 17:44:29
问题 I would like to iterate over an array that is stored as a Facter fact, and for each element of the array create a new system user and a directory, and finally make API calls to AWS. Example of the fact: my_env => [shared1,shared2,shared3] How can I iterate over an array in Puppet? 回答1: This might work, depending on what you are doing # Assuming fact my_env => [ shared1, shared2, shared3 ] define my_resource { file { "/var/tmp/$name": ensure => directory, mode => '0600', } user { $name: ensure

Hiera 3 + Puppet 4.2 can't manage empty value in yaml datasource

ぃ、小莉子 提交于 2019-12-13 20:24:58
问题 I'm facing some issues to use Hiera 3 with Puppet 4.2. When applying my puppet manifest using this command: puppet apply environments/production/manifests/init.pp --hiera_config=hiera.yaml I get the following error: Error: Evaluation Error: Error while evaluating a Function Call, Could not find data item myclass::ensure in any Hiera data file and no default supplied at /home/vagrant/temp/environments/production/manifests/init.pp:13:39 on node a Here is the directory structure : $ tree . ├──

optionally passing a parameter to puppet resource

时光总嘲笑我的痴心妄想 提交于 2019-12-13 17:19:31
问题 Is there a way to pass a parameter to a puppet resource only if it's been set? For example, say I have a manifest that creates a new user, and I may or may not want to set the uid and gid manually. Best way I can think to do is like this: class example ( $uid = undef, $gid = undef, $username = 'default' ) { user { $username: ensure => present, # etc } if $uid != undef { user { "uid-${username}": name => $username, uid => $uid, require => User[$username] } } if $gid != undef { user { "gid-$