Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
ENC Puppet DSL with inline_template
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
eduardo  
View profile  
 More options Jun 9 2012, 9:48 am
From: eduardo <erodr...@gmail.com>
Date: Sat, 9 Jun 2012 06:48:44 -0700 (PDT)
Local: Sat, Jun 9 2012 9:48 am
Subject: ENC Puppet DSL with inline_template
  Dear all,

  I'm trying to do mass update ssh-accounts by ENC Puppet DSL. I found
great reference in http://jpmens.net/2011/07/25/external-node-classification-and-data-in...
from Jan-Piet , if anyone had test it may be could help me in a couple
issues.

1)  I got "Duplicate definition" error while calling define resource
one{ $user_array: } to workaround I change defined resource like
define one_user($arr) , so to call it one_user{ 'tit': arr => $res } .
Jan-Piet said 'to call my one_user() "function" once for each array
element' , It's essencial for the mass load but How to do it ?.

2) Testing are tell me that input parameter class for
inline_template() has not hash structure instead it is array. Putting
function split in a head of class having unique sense to check for
structure is tell me that parameter is an array not expected string
variable.  Why ?

 My test , I inserted some comments ## upercase  :

class updssh( $users ) {

   $users_array = split($users, '[ ;]')  ## NO SENSE , ONLY FOR CHECK
$users VARIABLE STRUCTURE

   notify{'MSG1': message => "$users" }

        $res = inline_template(     ## RETURN ARRAY
          "<% users.each_with_index do |usr, i| -%>
            <% usr.each do |k,v| -%>
               <%= k %>:<%= usr[k]['email'] %>:<%= v['type'] %>:<%=
v['key'] %>
           <% end -%>
            ;
         <% end -%>")

    # Now create an array from that result
    $users_array = split($res, '[ ;]')  ## $res IS AN ARRAY NOT AN
STRING VARIABLE  !!!

  #one_user{ $users_array: }   ## HOW TO DO IT ??

        one_user{ 'tit':   ## WORKAROUNT AVOIDING "Duplicate
definition" error
              arr => $res          ### SAME RETURN FROM INLINE,
               }

    define one_user($arr) {
       ##  $u = split($title, '[:]')
         $u = split($arr, '[:]')

        $username = $u[0]
        $email = $u[1]
        $type = $u[2]

        $dd = $u[6]

       $msg = sprintf('user=%s, email=%s, type=%s , dd=%s', $username,
$email, $type, $dd)

        notify{'MSG': message => "$msg" }

    }

}

The ENC data are :

  ---
parameters: {}

classes:
  updssh:
    users:
    - ppuser7:
        type: ssh-rsa
        user_auth: JOJOXX
        user_ssh: ppuser7
        key: XXLLAVEXX_DE_PRUEBA_UPD_SSH_PARA_PPUSER7
        email: ppus...@speedy.com
    - ppuser8:
        type: ssh-rsa
        user_ssh: ppuser8
        key: LLAVEXX_DE_PRUEBA_UPD_SSH_PARA_PPUSER8
        email: ppus...@speedy.com

  Any suggestion ?.
   Thanks in advanced,
   eduardo.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
eduardo  
View profile  
 More options Jun 9 2012, 10:03 am
From: eduardo <erodr...@gmail.com>
Date: Sat, 9 Jun 2012 07:03:19 -0700 (PDT)
Local: Sat, Jun 9 2012 10:03 am
Subject: Re: ENC Puppet DSL with inline_template
 errata for 2) , It should be

Putting function split in a head of class having unique sense to check
for structure is tell me that parameter is an array not expected hash
variable.  Why ?

 sorry

On 9 jun, 09:48, eduardo <erodr...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
eduardo  
View profile  
 More options Jun 10 2012, 12:48 pm
From: eduardo <erodr...@gmail.com>
Date: Sun, 10 Jun 2012 09:48:30 -0700 (PDT)
Local: Sun, Jun 10 2012 12:48 pm
Subject: Re: ENC Puppet DSL with inline_template
 Hi, first of all thanks to Jan-Piet for share it.
 My mistake was around shape an inline_template parameter, everything
is ok just deleting linefeeds and spaces characters in it, like this :

     -----
        $res = inline_template(
          "<% users.each do |usr| -%><% usr.each do |k,v| -%><%= k %>:<
%= usr[k]['email'] %>:<%= v['type'] %>:<%= v['key'] %>;<% end -%><%
end -%>")

    # Now create an array from that result
    $users_array = split($res, '[;]')

   one_user{ $users_array: }

     define one_user() {
        $u = split($title, '[:]')
     -----

 This way the inline_template parameter is not readable but it's the
way to do it.

 Regards,
  eduardo.

On 9 jun, 10:03, eduardo <erodr...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »