Hi
I tried to create custom facts, but still on client it is not reflecting as desired. Please check the $::epoch_date called in setpass. I'm trying setpass from *http://projects.puppetlabs.com/projects/1/wiki/Password_Management_Patterns* Files *epoch_date.rb* require 'facter' Facter.add(:epoch_date) do setcode do Facter::Util::Resolution.exec('echo $(($(date +%s) / 60 / 60 / 24))') end end *[root@server ~]# facter --puppet epoch_date* 16103 *basic.pp *define accounts::basic($file, $key, $value, $delimiter = " ") { # passing the values via the environment simplifies quoting. Exec { environment => [ "P_KEY=$key", "P_VALUE=$value", "P_DELIM=$delimiter", "P_FILE=$file" ], path => "/bin:/usr/bin", } # append line if "$key" not in "$file" exec { "append-$name": command => 'printf "%s\n" "$P_KEY$P_DELIM$P_VALUE" >> "$P_FILE"', unless => 'grep -Pq -- "^\Q$P_KEY\E\s*\Q$P_DELIM\E" "$P_FILE"', } # update it if it already exists exec { "update-$name": command => 'perl -pi -e \'s{^\Q$ENV{P_KEY}\E\s*\Q$ENV{P_DELIM}\E.*}{$ENV{P_KEY}$ENV{P_DELIM}$ENV{P_VALUE}}g\' -- "$P_FILE"', unless => 'grep -Pq -- "^\Q$P_KEY\E\s*\Q$P_DELIM\E\s*\Q$P_VALUE\E$" "$P_FILE"', } } *setpass.pp* define accounts::setpass($file='/etc/shadow', $hash) { accounts::basic{ "set_pass_$name": file => $file, key => $name, value => "$hash:*$::epoch_date*:0:99999:7:::", delimiter => ':' } } *init.pp* class accounts { @accounts::system { 'demo': comment => 'demo users', } @accounts::setpass { "demo": hash => '$6$salt$gUxP.t8.YpGkzSXlD5XOUBFAI7Jeat2pRraF7S2ycm36qprk76ihcTCqtgS3YS/dMk9j0EXIK..ZnVqi5YBKs1' } } Jyotir On Sunday, 2 February 2014 02:18:49 UTC+5:30, Jose Luis Ledesma wrote: > > Hi, > > It seems you are thinking that puppet is like other scripting language, > but it is not. With puppet you define a final state, a model, so there is > not "first I exec this, get the output and do something". > > If you ask how to get a date to model something, I would answer just use > (custom) facts. But I think that the best question is why do you need that? > > Regards, > El 01/02/2014 17:15, "jyotir bhandari" <[email protected]> escribió: > >> Hi >> >> I have date as shell command 'echo $(($(date +%s) / 60 / 60 / 24))', I >> want to call this command in parameter of puppet module, how can i do it. >> >> or how can i use exec { "date": commnand => 'echo $(($(date +%s) / 60 / >> 60 / 24))' } redirect ouput into some variable as $date and call into >> puppet parameter. >> >> Jyotir >> -- >> 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 [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/puppet-users/b1100867-b76c-4a5c-8663-96e03dbc04b8%40googlegroups.com >> . >> For more options, visit https://groups.google.com/groups/opt_out. >> > On Saturday, 1 February 2014 21:45:37 UTC+5:30, jyotir bhandari wrote: > > Hi > > I have date as shell command 'echo $(($(date +%s) / 60 / 60 / 24))', I > want to call this command in parameter of puppet module, how can i do it. > > or how can i use exec { "date": commnand => 'echo $(($(date +%s) / 60 / 60 > / 24))' } redirect ouput into some variable as $date and call into puppet > parameter. > > Jyotir > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/aa26019e-8c43-48c9-8ee0-42258c5065d5%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
