puppet

Puppet - set defaults in manifest if not present in hiera when iterating over hash

只谈情不闲聊 提交于 2019-12-05 21:49:37
I am iterating over many entries in a hiera hash, and wish to remove identical duplicate lines from hiera by setting defaults in the manifest (such as ensure , groups , managehome etc), and have the defaults overridden IF the duplicate key/value pair exists in hiera. To date, everything I have tried fails to get the default values. I get the idea that I need to declare a resource, but am uncertain. I have tried setting "default_values_hash" in the lookup and other methods, but nothing appears to pass defaults into the iteration and --debug output This is a (pseudo) example of my manifest and

How to config timezone with Vagrant, Puppet and Hiera?

蓝咒 提交于 2019-12-05 20:52:50
I'm using PuPHPet for my testing environments, which is based on Vagrant/Puppet+Hiera. In the config.yml (Hiera config file) I would like to add section for my timezone and with command vagrant provision setup it properly. It's that possible? Just add your timezone to whatever key you want in your hiera file, let's call it timezone . The value for which and the puppet code you'd need to set that timezone depends on the system you're firing up, but I'll assume RedHat flavor of unix. I recommend setting that to any valid value you'd see under /usr/share/zoneinfo . As an example your key may look

Iterate over a deeply nested hiera hash in puppet manifest

十年热恋 提交于 2019-12-05 19:46:27
I'm working on building a structure for my webservers. I have my setup in hiera, but I can't seem to get puppet to give back the correct types. In common.yaml vhosts: hostname: sitename: app_url: value app_type: value I have multiple sites per vhost and multiple vhosts. In my manifest I'm going to be creating the folder structure and other setup tasks, but for for now I can't even get it to iterate over the sites. Current manifest: define application($app_name, $app_url) { notice("App Type: ${app_type}") notice("App Url: ${app_url}") } $vhosts = hiera('vhosts') $vhosts.each |$vhost| { create

How to convert array to comma separated string in Puppet 2.7

妖精的绣舞 提交于 2019-12-05 15:56:01
问题 I am using Puppet 2.7 and I need to convert an array to comma separated list. $hosts_fqdn= ['host1','host2','host3'] And I need to convert it to desired result: 'host1,host2,host3' I guess that Puppet 3.2 offers lambda expression - reduce . But unfortunately that is not possible with 2.7. 回答1: Function join from puppetlabs/stdlib: join($hosts_fqdn,",") 来源: https://stackoverflow.com/questions/18526456/how-to-convert-array-to-comma-separated-string-in-puppet-2-7

CentOS 6.4下通过Rdo方式安装OpenStack

僤鯓⒐⒋嵵緔 提交于 2019-12-05 15:07:25
环境: VmwareWorkstation+CentOS 6.4(64bit) 关闭防火墙: service iptables stop chkconfig iptables off 关闭selinux: vi /etc/sysconfig/selinux SELINUX=disabled 安装 epel 源 默认使用 base 的源 在后面 packstack --allinone 会报错,这里进行修改. 备份 CentOS-Base.repo 下载国内源: wget http://lug.ustc.edu.cn/wiki/_export/code/mirrors/help/centos?codeblock=2 重命名为mv centos?codeblock=2 CentOS-Base.repo rpm -Uvh http://mirrors.ustc.edu.cn/epel/6/x86_64/epel-release-6-8.noarch.rpm ( 注意 : 这里需在进入 epel 里面将 HTTPS 方式去掉 ) yum makecache 安装 rdo 与P ackstack wget https://repos.fedorapeople.org/repos/openstack/openstack-icehouse/rdo-release-icehouse-4

How to handle data such as Mysql, web sites sources with Vagrant?

谁说我不能喝 提交于 2019-12-05 12:34:44
How to handle data such as Mysql, web sites sources with Vagrant ? As a programmer, I like being able to easily set up environments for develop. So I created a vagrant box and provisioned it with puppet but I'm asking to myself, what about the data in the box ? What happen if I need to destroy the box and recreate it? All my data will be erased ! I had some problems with a crashed VM and I don't want to redo the same mistake, I want to have the control of my data. How do you do ? Do you use shared folders to put your live data ? Where do you keep your data, in or out the box ? In the current

Puppet: relationship between resources on different nodes

喜欢而已 提交于 2019-12-05 09:51:49
I know that we can specify relationship between resources, which determines the deployment order. But is it possible to create relationship between resources on different nodes in Puppet? For example, I have apache web server in node A and mysql server in node B. I want to start mysql first before starting apache web server. How could I express this in Puppet language? I have tried the following codes: node ‘host1’ { @@service { ‘mysql’: ensure => running, tag => ‘host1-mysql’, } } node ‘host2’ { service { ‘apache2’: ensure => running, } Service<<| tag == ‘host1-mysql’ |>> -> Service[‘apache2’

puppet - How do I append to path variable?

拜拜、爱过 提交于 2019-12-05 09:37:21
I have access to just a module for our team, where as the global manifests are maintained by infrastructure team. The PATH variable gets set in the global manifests. I want to append to the PATH variable, but puppet ignores my exec block. file { "/etc/profile.d/set_java_home.sh": ensure => file, source => "puppet:///modules/teamXXX/set_java_home.sh", mode => "u=rw,go=r" } Exec { path => [ "\${PATH}", "\${JAVA_HOME}/bin" ] } How can I append to the PATH variable? edit I should have mentioned, I am looking to enhance the PATH variable for users's shell environment, rather than puppet's execution

How to Mock a Custom Type in Rspec-Puppet

痴心易碎 提交于 2019-12-05 07:08:02
问题 I am able to test custom types using rspec-puppet due to implementing the answer of this question. However, I would like to avoid to create a symlink to the custom folder in every puppet-module by mocking cystom types . The question is how to mock Custom Puppet Types in Rspec-Puppet. I have found an example regarding the mocking of a Custom Puppet Function but I am looking for an example to mock Puppet Custom Types . Puppet Code class vim::ubuntu::config { custom_multiple_files { 'line

VSCode - how to keybind an external command

流过昼夜 提交于 2019-12-05 05:01:49
问题 Im trying to run "puppet-lint -f (currently open file) The Puppet extenstion provides puppet-lint check, but doesnt auto fix any issues, it just gives warnings. How can I add a keyboard shortcut to run "puppet-lint -f" on a file Im currently editing? Thanks 回答1: I don't know anything about the Puppet extension but in general here is how you can bind a shell command to a keychord: Make a task for it (.vscode/tasks.json): { "version": "2.0.0", { "label": "node version", "command": "node", "args