You have declarer lsyncd class without parameters

class lsyncd {

Regards,
El 16/05/2014 04:37, "Ugo Bellavance" <u...@lubik.ca> escribió:

>
>
> On Thursday, May 15, 2014 5:45:57 PM UTC-4, Jakov Sosic wrote:
>>
>> On 05/15/2014 09:25 PM, Ugo Bellavance wrote:
>> > Hi,
>> >
>> > I wrote my first puppet module and it is for lsyncd.  I know that there
>> > is already a module for that but I think it was written to manage
>> lsyncd
>> > and csync2 syncs and I don't really understand everything it it so I
>> > can't really use it or learn from it.  I have been able to create a
>> > simple module, below is the code from init.pp (I know, I should
>> > modularize it so that init.pp calls ::install and ::config, but I'll do
>> > that once the module works as I want).  It is actually working, but
>> only
>> > allows for one sync to be configured.  I'd like it to be able to
>> > configure more than one sync, but since all the configs for lsyncd is
>> in
>> > one file, I wouldn't know how to do it unless I add some variables
>> > like $method, $source2, $dest2, $desthost2, $append2 and $method,
>> > $source3, $dest3, $desthost3, $append3, $method, $sourcex, $destx,
>> > $desthostx, $appendx. I think someone here would know how to do it.
>> >
>>
>> I would suggest you to take a look at concat module.
>>
>> You can basically split your single config file into multiple parts, and
>> write a defined type for sync sections. For example:
>>
>>    # smb.conf
>>    concat { 'lsyncd.conf':
>>      path    => '/etc/lsyncd.conf',
>>      owner   => root,
>>      group   => root,
>>      mode    => '0644',
>>    }
>>
>>    ::concat::fragment { 'lsyncd.conf:settings':
>>      target  => 'lsyncd.conf',
>>      content => template('lsyncd/settings.conf.erb'),
>>      order   => '100',
>>    }
>>
>> And write your own defined type, for example:
>>
>> define lsycnd::sync (
>>    $method,
>>    $source,
>>    $host,
>>    $targetdir,
>> ) {
>>
>>    include ::lsyncd
>>
>>    ::concat::fragment { "lsyncd.conf:sync:${title}":
>>      target  => 'lsyncd.conf',
>>      content => template('lsyncd/sync.conf.erb'),
>>      order   => '200',
>>    }
>>
>> }
>>
>> Now, your sync.conf.erb would look like:
>>
>> sync {
>>     <%= @method %>,
>>     source     = "<%= source %>",
>>     host       = "<%= desthost %>",
>>     targetdir  = "<%= dest %>",
>>
>> <% if @append -%>
>>     rsync      = {
>>        _extra = {"--append"}
>>     }
>> <% end -%>
>> }
>>
>>
>> I worked on this tonight, but now I get an error when I try to apply it:
>
> Could not retrieve catalog from remote server: Error 400 on SERVER:
> Invalid parameter dest at /etc/puppet/manifests/nodes/nodes.pp:29
>
> If I comment out this variable, another one generate an Invalid parameter
> error...
>
> I tried debugging it, but I think I need a little help.
>
> Here is my init.pp:
>
> class lsyncd {
>
>   package { 'lsyncd':
>         ensure => installed,
>   }
>
>   concat { 'lsyncd.conf':
>     path    => '/etc/lsyncd.conf',
>     owner   => root,
>     group   => root,
>     mode    => '0644',
>   }
>
>   ::concat::fragment { 'lsyncd.conf:settings':
>     target  => 'lsyncd.conf',
>     content => template('lsyncd/settings.conf.erb'),
>     order   => '100',
>   }
>
> define lsyncd::sync (
>   $method,
>   $source,
>   $dest,
>   $desthost,)
>   {
>
>   include ::lsyncd
>
>   ::concat::fragment { "lsyncd.conf:sync:${title}":
>     target  => 'lsyncd.conf',
>     content => template('lsyncd/sync.conf.erb'),
>     order   => '200',
>   }
>
>     service { 'lsyncd':
>         ensure      => running,
>         enable      => true,
>         hasrestart  => true,
>         hasstatus   => true,
>         require     => [Package['lsyncd'], File['lsyncd.conf']],
>         subscribe   =>
>             File[
>                 'lsyncd.conf'
>             ],
>     }
>
>   }
> }
>
> My settings.conf.erb:
>
> settings {
>    logfile    = "/var/log/lsyncd.log",
>    statusFile = "/tmp/lsyncd.status",
>    inotifyMode = "CloseWrite or Modify",
>    delay       = "1"
> }
>
> My sync.conf.erb:
>
> sync {
>     <%= @method %>,
>     source     = "<%= source %>",
>     host       = "<%= desthost %>",
>     targetdir  = "<%= dest %>",
>
> <% if @append -%>
>     rsync      = {
>        _extra = {"--append"}
>     }
> <% end -%>
> }
>
> Here is how I call it:
>
> node "test.example.com" {
>    class { "lsyncd":
>        title    => ["src1"],
>        method   => ["default.rsyncssh"],
>        source   => ["/var/www/test/src"],
>        dest     => ["/var/www/test/dst1"],
>        desthost => ["www.example.com"],
>        append   => ["true"]
>    }
> }
>
> Thanks,
>
> --
> 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/c18e50c3-c978-48ba-9fb9-268d0652747d%40googlegroups.com<https://groups.google.com/d/msgid/puppet-users/c18e50c3-c978-48ba-9fb9-268d0652747d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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_B3dcOSLdgrcXT4WrRY55LCDbxG6FqXKX0TLnEcEtDJEQyLw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to