I don't understand why the epoch_date fact doesn't work,  why you cannot
use the user resource? If it is because the password is enforced, you can
use the user resource to create the user, and launch a chpasswd once
created to setup the initial password.

Regards.

P.N. just realized the emails were sent just to me, please keep the group
in copy.
El 02/02/2014 17:05, "jyotir bhandari" <jyotirbhand...@gmail.com> escribió:

> Hi
>
> I tried ${::epoch_date}, mistakenly i wrote with (). still it didnt work.
>
> I have my master server on CentOS 5 and clients on Ubuntu 12.04
>
> I have tried with the link of user resources, but it didnt work for me
> that is why i went with this approach.
>
> Regards
> Jyotir
>
>
>
>
> On Sun, Feb 2, 2014 at 9:29 PM, José Luis Ledesma <
> joseluis.lede...@gmail.com> wrote:
>
>> Hi,
>>
>> First of all, which platform are you using? If it is linux, hpux,
>> Solaris... you should use the 'user' resource:
>>
>> http://docs.puppetlabs.com/references/latest/type.html
>>
>> About using the epoch_date fact it is ${::epoch_date} note its {} and not
>> ().
>>
>> Regards,
>>
>>
>> El 02/02/2014 16:50, "jyotir bhandari" <jyotirbhand...@gmail.com>
>> escribió:
>>
>>  Hi
>>>
>>> Just tried as per your guidance $(::epoch_date), it didnt work,
>>> epoch_date field is not showing up in the shadow fields.
>>>
>>> I tried to set password with libshadow too, but it didnt work for me, so
>>> i went with this approach, but now that hash is setting up, it is not
>>> setting epoch days, though i can hard code it but i want it to be correct
>>> as we can know when was the user actually created.'
>>>
>>> Please guide me as to what is the best approach.
>>>
>>>
>>> Regards
>>> Jyotir
>>>
>>>
>>>
>>>
>>> On Sun, Feb 2, 2014 at 1:35 PM, José Luis Ledesma <
>>> joseluis.lede...@gmail.com> wrote:
>>>
>>>> I supose that user resource do not work for you, right? ( note that the
>>>> link is an historic information, and perhaps  puppet currently supports
>>>> your platform)
>>>>
>>>> Have you tried ${::epoch_date}?
>>>>
>>>> Regards,
>>>> El 02/02/2014 05:59, "jyotir bhandari" <jyotirbhand...@gmail.com>
>>>> escribió:
>>>>
>>>>> 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
>>>>> <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" <jyotirb...@gmail.com>
>>>>>> 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 puppet-users...@googlegroups.com.
>>>>>>> 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.
>>>>>>>
>>>>>>
>>>
>

-- 
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/CAF_B3dcKhNgi%3DvnR_nhwJL74%3DLrZV4oAZbC0FqLqLbvOwCDwCQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to