puppet

Correct way to start RSpec-puppet unit tests

二次信任 提交于 2019-12-12 19:41:22
问题 I have created a simple Puppet 4 class and a unit test to go along with it as follows (after executing touch metadata.json; rspec-puppet-init while in modules/test/ ): # modules/test/manifests/hello_world1.pp class test::hello_world1 { file { "/tmp/hello_world1": content => "Hello, world!\n" } } # modules/test/spec/classes/test__hello_world1_spec.rb require 'spec_helper' describe 'test::hello_world1' do it { is_expected.to compile } it { is_expected.to contain_file('/tmp/hello_world1')\ .with

Foreman with puppet node.rb error 404 Not Found

你。 提交于 2019-12-12 14:24:41
问题 I have installed foreman-1.2 with puppet, after installation i have registered my puppet to smart-proxy on foreman. when i run following command [root@puppet ~]# puppet agent -t Warning: Unable to fetch my node definition, but the agent run will continue: Warning: Error 400 on SERVER: Failed to find puppet.example.com via exec: Execution of '/etc/puppet/node.rb puppet.example.com' returned 1: --- false Info: Retrieving plugin Error: Could not retrieve catalog from remote server: Error 400 on

Puppet - Escaping YAML variables for Hiera

对着背影说爱祢 提交于 2019-12-12 13:59:06
问题 I have a pretty simple requirement, but I've tried every escape sequence I can think of, but can't get the output needed. I need to litterally output into a file: %{VAR} Here's my YAML file: myclass::outputstuff: - Heres a litteral var %{VAR} - Heres something else %{SOMETHING} And my template.erb: <%= @outputstuff.each do | ostuff | -%> <%= ostuff -%> <% end -%> But it like this, it outputs: Heres a litteral var Heres something else If I add a percent sign like %%{VAR} , as advised by other

Puppet Exec what “<| |>” means?

半城伤御伤魂 提交于 2019-12-12 12:32:42
问题 I'm learning puppet language and noticed one very intriguing line of code: Exec["apt-update"] -> Package <| |> on following context: class manifest::module { exec { "apt-update": command => "/usr/bin/apt-get -y update", timeout => 3600; } package { ["alien", "bc", "libaio1", "unixodbc", "unzip", "rlwrap"]: ensure => installed; } Exec["apt-update"] -> Package <| |> } Why Exec is followed by the -> ? And most important, what's the meaning of <| |> ??? 回答1: This expression essentially instructs

Puppet, how to use the exec return value as a trigger?

怎甘沉沦 提交于 2019-12-12 12:12:08
问题 I have a bash script that perform a check and return a boolean 0|1 . Example of such script below : # less /path/to/script/check_kernel.sh #! /bin/bash # Check if running kernel match default=0 kernel in grub.conf KERNEL_RUNN=`/bin/uname -r | /bin/sed -e 's/^//' -e 's/[[:space:]]*$//'` KERNEL_GRUB=`/bin/grep kernel /boot/grub/menu.lst | /bin/grep -v '#' \ | /bin/awk '{print $2}' | /bin/sed -e 's/\/vmlinuz-//g' | /usr/bin/head -1 \ | /bin/sed -e 's/^//' -e 's/[[:space:]]*$//'` if [ "$KERNEL

Puppet 3 file recurse terribly slow

夙愿已清 提交于 2019-12-12 11:11:46
问题 I'm using Puppet 3 on Amazon Linux 2012.09, one of my manifests sets up and reconfigs some directories. One of the tasks is just changing the folder owner and group recursivelt to another user - however, this takes over a 60 seconds to complete and there is barely anything in the directory - the chown myuser:myuser /var/lib/jenkins in the terminal take less than a second. My question is: Is there a better/faster way to change directory ownership recursively in Puppet? Thanks file {'/var/lib

Rspec + puppet: nested fixtures?

孤街浪徒 提交于 2019-12-12 06:38:10
问题 i am trying to start using rspec to test some already made (and in production) puppet modules, but this thing keep trying to make me mad. First off, i am doing a "complete" test with rake. The task is: Rakefile: desc 'Validate manifests, templates, and ruby files' task :validate do Dir['manifests/**/*.pp'].each do |manifest| sh "puppet parser validate --noop #{manifest}" end Dir['spec/**/*.rb', 'lib/**/*.rb'].each do |ruby_file| sh "ruby -c #{ruby_file}" unless ruby_file =~ %r{spec/fixtures}

Installing execSync using Puppet

拥有回忆 提交于 2019-12-12 06:17:17
问题 I am writing a Puppet module to setup an application on our test servers. The testing environment requires us to install a node package called execSync (https://github.com/mgutz/execSync). Since execSync is a native package, it gets compiled on installation. When I try to manually install it on the server, it gets installed. However, when I do the same thing using Puppet, compilation step fails. I have tried installing execSync using the puppetlabs-nodejs module (https://github.com/puppetlabs

How to setup a default hiera lookup value

巧了我就是萌 提交于 2019-12-12 06:00:08
问题 I am setting up my Puppet code using Hiera such that if a value is not found in Hiera, it assigns a default value to it. I am not getting the desired results and wanted to know how others did it : lookup( <NAME>, [<VALUE TYPE>], [<MERGE BEHAVIOR>], [<DEFAULT VALUE>] ) I think I found the answer https://www.devco.net/archives/2016/03/13/the-puppet-4-lookup-function.php , will try it shortly lookup({"name" => "some::thing", "default_value" => "default"}) 回答1: The solution that worked for me was

Puppet Local Account Notify Issue

心不动则不痛 提交于 2019-12-12 05:09:46
问题 user { 'acc1': ensure => present, managehome => true, password => 'Test123', groups => ['Administrators'], auth_membership => 'minimum', notify => Exec['app config'] } exec { 'app config': path => 'c:\\program files (x86)\\app\\bin', command => 'config.bat -f responsefile.rsp', refreshonly => true } The user is getting created, but I need the local account to be used for the app configuration. The above puppet script is executed by domain account abc\myname , and the application requires a