puppet

puppet: if one file exists then copy another file over

我们两清 提交于 2019-12-11 22:07:38
问题 I am trying to figure out how to make my puppet module work such I need to test if file exists on the client, if it does, then copy another file over. If the file does not exist then do nothing. I can't seem to get it working. Here is my module: class web-logs::config { # PATH TO LOG FILES $passenger='/var/tmp/puppet_test/passenger' # PATH TO LOGROTATE CONFIGS $passenger_logrotate='/var/tmp/puppet_test/logrotate.d/passenger' exec { 'test1': onlyif => "test -f $passenger", path => ['/usr/bin',

How does host groups work with foreman?

自作多情 提交于 2019-12-11 20:40:01
问题 I know how to declare foreman hostgroups using the online portal but how do you make it affect a host? Also where does all the manifests/module regarding the host group go? And is there a particular format to it? Thanks for replying in advance! 回答1: You need to set the host group on the host, by going to the hosts list ( Hosts > All hosts ), click Edit next to the host and select the host group from the dropdown list, then Submit . Any Puppet classes you set on the host group will apply to

Puppet onlyif and unless conditional test from boolean data in Hiera and CLI script output

℡╲_俬逩灬. 提交于 2019-12-11 16:00:04
问题 I am running Puppet v3.0 on RHEL 6 and am doing package management via the exec resource. I would like to add a number of control gates into my manifest via onlyif and unless . First I would like to use booleans as defined in Hiera [ auto lookup function ]. Secondly I would like to use booleans from a bash script running diff <() <() . Im using the following hiera data : --- my-class::package::patch_now: 0 my-class::package::package_list: acl-2.2.49-6.el6-x86_64 acpid-1.0.10-2.1.el6-x86_64 ..

Install mysql with puppet on vagrant vm

心已入冬 提交于 2019-12-11 13:43:49
问题 I'm trying to install mysql server on a vagrant vm with puppet ,I've added this line on the Vagrant file config.vm.provision "puppet" in the same Vagrantfile folder I've created the manifests folder and inside it folder it's default.pp with this content class { '::mysql::server': root_password => 'root', remove_default_accounts => false, override_options => $override_options } mysql::db { 'wordpress': user => 'wordpress', password => '12345', host => 'localhost', grant => ['ALL'], } But I get

Puppet - how to provision a user on the guest machine with the same username as the user on the host machine

空扰寡人 提交于 2019-12-11 12:36:58
问题 How can I configure puppet to provision a user on the guest machine with a username that matches the username of the user on the host machine who provisions the guest? (Using puppet apply, not server/master) $ puppet --version 3.4.3 $ vagrant --version Vagrant 1.7.2 This is what I've tried so far: Following the instructions in this SO answer I tried to use vagrant/puppet to create a user account on the guest machine which matches the user account on the host machine. But ultimately, it didn't

Function contain() vs. Anchor Pattern in Puppet

做~自己de王妃 提交于 2019-12-11 12:19:57
问题 This post refers to Puppet "require" not working as expected. Is it possible to replace the Anchor Pattern with the function contain maintaining execution order and hinder declared classes of floating out. The two manifests look as follows: class profile::maven inherits profile::base { # Hiera $version = hiera('profile::maven::version', '3.2.1') $settings = hiera_hash('profile::maven::settings', undef) $environments = hiera_hash('profile::maven::environments', undef) include 'profile::java'

How can I use Foreman host groups with Puppet?

☆樱花仙子☆ 提交于 2019-12-11 12:17:19
问题 I have this manifest: $foremanlogin = file('/etc/puppetlabs/code/environments/production/manifests/foremanlogin.txt') $foremanpass = file('/etc/puppetlabs/code/environments/production/manifests/foremanpass.txt') $query = foreman({foreman_user => "$foremanlogin", foreman_pass => "$foremanpass", item => 'hosts', search => 'hostgroup = "Web Servers"', filter_result => 'name', }) $quoted = regsubst($query, '(.*)', '"\1"') $query6 = join($quoted, ",") notify{"The value is: ${query6}": } node $

How to check if a directory exists in puppet

隐身守侯 提交于 2019-12-11 11:38:38
问题 Trying to create an autostart directory on a rpi using puppet. It is supposed to mkdir only if the location doesn't exist. Here is the current code: exec { "mkdir_autostart": command => "mkdir /home/pi/.config/autostart", unless => "[ -d /home/pi/.config/autostart ]", path => "/usr/local/bin/:/bin/", } Here is what I get: err: Failed to apply catalog: Parameter unless failed on Exec[mkdir_autostart]: '[ -d /home/pi/.config/autostart ]' is not qualified and no path was specified. Please

How do I turn a hash to a string in Puppet DSL?

走远了吗. 提交于 2019-12-11 11:29:24
问题 I have a hash of hashes that I need to embed in an exec resource command. My thought was to serialize the hash to a string and interpolate it into the exec call . The exec call will be executing ruby code via ruby -e 'ruby code here' . Using irb, I know that hash.to_s creates a single line parse-able version of the hash . Or I could use json. I doubt you can call to_s in puppet, but am not sure. The stdlib for Puppet has parseyaml and parsejson to deserialize, but is there a way to serialize

Cannot parse array into defined type

会有一股神秘感。 提交于 2019-12-11 10:46:37
问题 I am using following puppet class class myclass{ $foo = [{"id" => "bar", "ip" => "1.1.1.1"}, {"id" => "baz", "ip" => "2.2.2.2"}] map {$foo:} define map () { notify {$name['id']: } } } But this gives me err: Could not retrieve catalog from remote server: Could not intern from pson: Could not convert from pson: Could not find relationship target "Change_config::Map[ip1.1.1.1idbar]" warning: Not using cache on failed catalog err: Could not retrieve catalog; skipping run What is the reason for