Re: [Puppet Users] Inter-node dependency

2015-02-28 Thread Garrett Honeycutt
On 2/26/15 9:59 AM, lupindet...@gmail.com wrote:
> Hello,
> 
> I'm pondering what is the best way to approach this problem( without 
> MCollective).
> 
> I have a serverA than will run a DB backup copy it over to serverB, then 
> serverB do restore then notify serverA for it to execute the next phase of 
> action.
> 
> This scenario will have to take at least four occurences back and forth 
> between the two servers, this is to setup a log shipping for a DB server.
> 
> In my mind I can think of;
> 
> A) scp a file as flag every after execution between servers so it will only 
> proceed to next step if flag file is present.
> B) Export an Exec resources from one server to another
> C) Create a wrapper script for tasks intended for serverB, execute the script 
> from serverA using Exec resource.
> 
> I'm biased on B) if it's doable as I would love to have this pure DSL as much 
> as possible but what would be the downside, performance?
> 
> 
> Appreciate any input and further ideas.
> 
> cheers lupin
> 

Hi,

What is sounds like you have is a recurring task, not a desired system
state. Suggest using puppet to setup ssh keys and a cron job that runs
your backup script.

Best regards,
-g

-- 
Garrett Honeycutt
@learnpuppet
Puppet Training with LearnPuppet.com
Mobile: +1.206.414.8658

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/54F2202F.8000404%40garretthoneycutt.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Copying a hash with changes

2015-02-28 Thread Garrett Honeycutt
On 2/28/15 1:27 PM, Tom Limoncelli wrote:
> I want to copy a hash to a variable but change some settings along the way.
> 
> For example:
> 
> I have $haproxy::params::global_options (which is a hash) and I want
> to create a copy with some changes.
> 
> I tried this:
>   $global_options = $haproxy::params::global_options += {
>   'log' =>  "${log_ip} local0",
>   }
> But that gives me:
> Error: Syntax error at '+='; expected '}' at ...
> 
> If I do:
>   $global_options = $haproxy::params::global_options
>   $global_options['log'] = "${log_ip} local0"
> This gives me:
> Error: Assigning to the hash 'global_options' with an existing key
> 'log' is forbidden
> 
> Suggestions?
> 
> Tom
> 

Hi Tom,

Suggest using a template as it provides a way to hack around issues
involving munging data and types by going straight to ruby. You could
use the inline_template() function, though I prefer having it in a
separate file for readability and for syntax checking.

Here's a quick and dirty hack that might work for you. Notice in the
template that the ruby code is between <% %> and the interpolation that
is being returned to $hn in your manifest is between <%= %>.

manifests/init.pp

class tl (
) {

  $h = {
'k' => 'v',
  }

  $hn = template('tl/hack.erb')

  notify { 'asdf':
message => "h = ${h}",
  }
  notify { "hn = ${hn}":
require => Notify['asdf'],
  }
}


# templates/hack.erb
<% ht = {}
ht = @h.merge 'log' => "#{@ipaddress} local0"%>
<%= ht %>

# puppet apply -v tests/init.pp
Notice: h = {"k"=>"v"}
Notice: hn =
{"k"=>"v", "log"=>"10.0.1.3 local0"}

Best regards,
-g

-- 
Garrett Honeycutt
@learnpuppet
Puppet Training with LearnPuppet.com
Mobile: +1.206.414.8658

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/54F21A1F.2090207%40garretthoneycutt.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Copying a hash with changes

2015-02-28 Thread Dan White
Make a hash with the update in it and then merge them (needs stdlib)

Like this:

$new_hash = {
  'log' => "${log_ip} local0",
}

$global_options = merge ( $haproxy::params::global_options, $new_hash )

https://forge.puppetlabs.com/puppetlabs/stdlib#reference

• merge: Merges two or more hashes together and returns the resulting hash.

Example:
$hash1 = {'one' => 1, 'two' => 2}
$hash2 = {'two' => 'dos', 'three' => 'tres'}
$merged_hash = merge($hash1, $hash2)
# The resulting hash is equivalent to:
# $merged_hash =  {'one' => 1, 'two' => 'dos', 'three' => 'tres'}

When there is a duplicate key, the key in the rightmost hash "wins." Type: 
rvalue


> On Feb 28, 2015, at 1:27 PM, Tom Limoncelli  wrote:
> 
> I want to copy a hash to a variable but change some settings along the way.
> 
> For example:
> 
> I have $haproxy::params::global_options (which is a hash) and I want
> to create a copy with some changes.
> 
> I tried this:
>  $global_options = $haproxy::params::global_options += {
>  'log' =>  "${log_ip} local0",
>  }
> But that gives me:
> Error: Syntax error at '+='; expected '}' at ...
> 
> If I do:
>  $global_options = $haproxy::params::global_options
>  $global_options['log'] = "${log_ip} local0"
> This gives me:
> Error: Assigning to the hash 'global_options' with an existing key
> 'log' is forbidden
> 
> Suggestions?
> 
> Tom
> 
> -- 
> Email: t...@whatexit.orgWork: tlimonce...@stackoverflow.com
> Skype: YesThatTom
> Blog:  http://EverythingSysadmin.com
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/puppet-users/CAHVFxgnmdYrNOUdujza-EE0M5KyMZDR%3Dzt3wB-5tvbh8%3DaC4-w%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

“Sometimes I think the surest sign that intelligent life exists elsewhere in 
the universe is that none of it has tried to contact us.” 
Bill Waterson (Calvin & Hobbes)

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/8234B6C9-10E0-4272-8FCE-9B9DACCE6166%40icloud.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Copying a hash with changes

2015-02-28 Thread Tom Limoncelli
I want to copy a hash to a variable but change some settings along the way.

For example:

I have $haproxy::params::global_options (which is a hash) and I want
to create a copy with some changes.

I tried this:
  $global_options = $haproxy::params::global_options += {
  'log' =>  "${log_ip} local0",
  }
But that gives me:
Error: Syntax error at '+='; expected '}' at ...

If I do:
  $global_options = $haproxy::params::global_options
  $global_options['log'] = "${log_ip} local0"
This gives me:
Error: Assigning to the hash 'global_options' with an existing key
'log' is forbidden

Suggestions?

Tom

-- 
Email: t...@whatexit.orgWork: tlimonce...@stackoverflow.com
Skype: YesThatTom
Blog:  http://EverythingSysadmin.com

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAHVFxgnmdYrNOUdujza-EE0M5KyMZDR%3Dzt3wB-5tvbh8%3DaC4-w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.