FAQ
Hi guys!

I have a problem in a custom resource type, because the idea is that I had
to put in the manifest options "on or off" as an example below, but these
rules are not working case. any idea what it is?

define mysql ( $server_id, $relay_log_index, $performance_schema,
$rpl_semi_sync_master_enabled, $rpl_semi_sync_master_timeout,
$rpl_semi_sync_slave_enabled, $semisync_master, $semisync_slave, $mod_opr,
$read_only, $expire_logs_days, $max_binlog_size, $binlog_format,
$query_cache_limit, $query_cache_size, $server_id, $innodb_file_per_table,
$innodb_buffer_pool_size, $innodb_open_files, $key_buffer_size,
$tmp_table_size, $max_heap_table_size, $table_open_cache, $max_connections,
$thread_cache_size ) {

file { "/etc/my.cnf":
ensure => present,
owner => root,
group => root,
mode => 0640,
notify => Service["mysql"],
source => template("global/mysql/my.cnf.erb"),
}

file { "/var/log/mysql":
ensure => directory,
owner => mysql,
group => mysql,
mode => 0750,
}
case $read_only {

on: { $readonly = "red_only=1" }

off: { $readonly = "red_only=0" }
}

case $relay_log_index {

on: {
$relay_log_index =
"relay_log_index=/var/log/mysql/relay_$(hostname).log"
}
off: {
$relay_log_index =
";relay_log_index=/var/log/mysql/relay_$(hostname).log"
}
}

case $semisync_master {

on: {
$semisync_master =
"plugin_load=rpl_semi_sync_master=semisync_master.so"
}
off: {
$semisync_master =
";plugin_load=rpl_semi_sync_master=semisync_master.so"
}
}

case $semisync_slave {

on: {
$semisync_slave =
"plugin_load=rpl_semi_sync_slave=semisync_slave.so"
}
off: {
$semisync_slave =
";plugin_load=rpl_semi_sync_slave=semisync_slave.so"
}
}

case $performance_schema {
on: {
$performance_schema = "performance_schema"
}
off: {
$performance_schema = ";performance_schema"
}
}

case $mod_opr {

master: {
$server_id = "1"
}
slave: {
$server_id = "2"
}
}

case $rpl_semi_sync_master_enabled {

on: {
$rpl_semi_sync_master_enabled =
"rpl_semi_sync_master_enabled=1"
}
off: {
$rpl_semi_sync_master_enabled =
";rpl_semi_sync_master_enabled=1"
}
}

case $rpl_semi_sync_master_timeout {

on: {
$rpl_semi_sync_master_timeout =
"rpl_semi_sync_master_timeout=10"
}
off: {
$rpl_semi_sync_master_timeout =
";rpl_semi_sync_master_timeout=1"
}
}

case $rpl_semi_sync_slave_enabled {

on: {
$rpl_semi_sync_slave_enabled =
"rpl_semi_sync_slave_enabled=1"
}
off: {
$rpl_semi_sync_slave_enabled =
";rpl_semi_sync_slave_enabled=1"
}
}

packages { mysql-server:
ensure => present,
}

}

And it is my manifest:

class global::mysql::teste {

mysql { "teste":
mod_ops => "master",
server_id => "1",
innodb-file-per-table => "1",
innodb-buffer-pool-size => "256M",
innodb-open-files => "400",
key-buffer-size => "256M",
tmp-table-size => "16M",
max-heap-table-size => "128M",
table-open-cache => "400",
max-connections => "1000",
thread-cache-size => "20",
read_only => "off",
relay-log-index => "off",
binlog_format => "run",
max_binlog_size => "32M",
query_cache_limit => "2098",
query_cache_size => "32M",
semisync_master => "off",
semisync_slave => "off",
rpl_semi_sync_master_enabled => "off",
rpl_semi_sync_master_timeout => "off",
rpl_semi_sync_slave_enabled => "off",
performance_schema => "off",
}
}

Tks Again!
--
Douglas Brancaglion
Security Analist

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Search Discussions

  • Henrik Lindberg at Oct 5, 2012 at 2:52 pm
    From a quick glance, it seems like you are trying to reassign a
    variable value - that is not allowed in puppet. You may assign to a
    variable that exists in an outer scope (thereby shadowing it), but not
    reassign in the same scope.

    As an example:
    case $semisync_master {
    on: {
    $semisync_master = ...
    }
    off: {
    $semisync_master = ...
    }
    }

    will not work because $semisync_master is a parameter with a bound value.

    Use different variable names in your logic and template, or pass on
    different values to a second define.

    You will probably find the selector expression easier to use in cases
    like this. i.e.

    $semisync = $semisync_master ? {
    'on' => 'value when on',
    'off' => 'value when off',
    }

    Regards
    - henrik
    On 2012-05-10 15:23, Douglas Brancaglion wrote:
    Hi guys!

    I have a problem in a custom resource type, because the idea is that I
    had to put in the manifest options "on or off" as an example below, but
    these rules are not working case. any idea what it is?

    define mysql ( $server_id, $relay_log_index, $performance_schema,
    $rpl_semi_sync_master_enabled, $rpl_semi_sync_master_timeout,
    $rpl_semi_sync_slave_enabled, $semisync_master, $semisync_slave,
    $mod_opr, $read_only, $expire_logs_days, $max_binlog_size,
    $binlog_format, $query_cache_limit, $query_cache_size, $server_id,
    $innodb_file_per_table, $innodb_buffer_pool_size, $innodb_open_files,
    $key_buffer_size, $tmp_table_size, $max_heap_table_size,
    $table_open_cache, $max_connections, $thread_cache_size ) {

    file { "/etc/my.cnf":
    ensure=> present,
    owner=> root,
    group=> root,
    mode=> 0640,
    notify=> Service["mysql"],
    source=> template("global/mysql/my.cnf.erb"),
    }

    file { "/var/log/mysql":
    ensure=> directory,
    owner=> mysql,
    group=> mysql,
    mode=> 0750,
    }
    case $read_only {

    on: { $readonly = "red_only=1" }

    off: { $readonly = "red_only=0" }
    }

    case $relay_log_index {

    on: {
    $relay_log_index =
    "relay_log_index=/var/log/mysql/relay_$(hostname).log"
    }
    off: {
    $relay_log_index =
    ";relay_log_index=/var/log/mysql/relay_$(hostname).log"
    }
    }

    case $semisync_master {

    on: {
    $semisync_master =
    "plugin_load=rpl_semi_sync_master=semisync_master.so"
    }
    off: {
    $semisync_master =
    ";plugin_load=rpl_semi_sync_master=semisync_master.so"
    }
    }

    case $semisync_slave {

    on: {
    $semisync_slave =
    "plugin_load=rpl_semi_sync_slave=semisync_slave.so"
    }
    off: {
    $semisync_slave =
    ";plugin_load=rpl_semi_sync_slave=semisync_slave.so"
    }
    }

    case $performance_schema {
    on: {
    $performance_schema = "performance_schema"
    }
    off: {
    $performance_schema = ";performance_schema"
    }
    }

    case $mod_opr {

    master: {
    $server_id = "1"
    }
    slave: {
    $server_id = "2"
    }
    }

    case $rpl_semi_sync_master_enabled {

    on: {
    $rpl_semi_sync_master_enabled =
    "rpl_semi_sync_master_enabled=1"
    }
    off: {
    $rpl_semi_sync_master_enabled =
    ";rpl_semi_sync_master_enabled=1"
    }
    }

    case $rpl_semi_sync_master_timeout {

    on: {
    $rpl_semi_sync_master_timeout =
    "rpl_semi_sync_master_timeout=10"
    }
    off: {
    $rpl_semi_sync_master_timeout =
    ";rpl_semi_sync_master_timeout=1"
    }
    }

    case $rpl_semi_sync_slave_enabled {

    on: {
    $rpl_semi_sync_slave_enabled =
    "rpl_semi_sync_slave_enabled=1"
    }
    off: {
    $rpl_semi_sync_slave_enabled =
    ";rpl_semi_sync_slave_enabled=1"
    }
    }

    packages { mysql-server:
    ensure=> present,
    }

    }

    And it is my manifest:

    class global::mysql::teste {

    mysql { "teste":
    mod_ops=> "master",
    server_id=> "1",
    innodb-file-per-table=> "1",
    innodb-buffer-pool-size=> "256M",
    innodb-open-files=> "400",
    key-buffer-size=> "256M",
    tmp-table-size=> "16M",
    max-heap-table-size=> "128M",
    table-open-cache=> "400",
    max-connections=> "1000",
    thread-cache-size=> "20",
    read_only=> "off",
    relay-log-index=> "off",
    binlog_format=> "run",
    max_binlog_size=> "32M",
    query_cache_limit=> "2098",
    query_cache_size=> "32M",
    semisync_master=> "off",
    semisync_slave=> "off",
    rpl_semi_sync_master_enabled=> "off",
    rpl_semi_sync_master_timeout=> "off",
    rpl_semi_sync_slave_enabled=> "off",
    performance_schema=> "off",
    }
    }

    Tks Again!
    --
    Douglas Brancaglion
    Security Analist

    --
    You received this message because you are subscribed to the Google
    Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to
    puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/puppet-users?hl=en.

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedOct 5, '12 at 1:24p
activeOct 5, '12 at 2:52p
posts2
users2
websitepuppetlabs.com

People

Translate

site design / logo © 2022 Grokbase