basho-labs / riak-chef-cookbook

Chef cookbook for Riak
https://supermarket.chef.io/cookbooks/riak
94 stars 78 forks source link

changing PB IP and port using Chef #81

Closed kkalin78 closed 11 years ago

kkalin78 commented 11 years ago

I have two issues with changing PB IP using chef-solo + vagrant 1) Looks like Documentation is out date. It says that there is pb_ip attribute, but cookbook doesn't have such attribute. 2) Since Chef always do concatenation for array attributes it's impossible to overwrite default value. Thus ['riak_api']['pb'] ends up as two tuples in app.config: default and new one.

For example: chef.json = { :riak => { :config => { :riak_api => { :pb => [["tuple", "string_127.0.0.1", 8087]] } } } } will produce following app.config {riak_api, [ {pb, [ {"10.0.2.15", 8087}, {"127.0.0.1", 8087} ]} ]},

hectcastro commented 11 years ago

Taking a look at this.

  1. The documentation is up-to-date – pb_ip and pb_port are being deprecated in favor of the pb list with IP and port tuples (similar to the existing HTTP interface configuration method).
  2. I believe you are correct here. We need to look and see if this can be done a different way.
hectcastro commented 11 years ago

On second look, I was able to use Vagrant's JSON attributes to override the default attributes of the Riak cookbook:

chef.json = {
  "riak" => {
    "args" => {
      "+S" => 1,
      "-name" => "riak@33.33.33.10"
    },
    "config" => {
      "riak_api" => {
        "pb" => [["__tuple", "__string_33.33.33.10", 8888]]
      },
      "riak_control" => {
        "enabled" => (index == 1 ? true : false)
      }
    }
  }
}

And the corresponding app.config:

[
    {bitcask, [
        {data_root, "/var/lib/riak/bitcask"},
        {io_mode, erlang}
    ]},
    {kernel, [
        {inet_dist_listen_max, 7999},
        {inet_dist_listen_min, 6000}
    ]},
    {lager, [
        {crash_log, "/var/log/riak/crash.log"},
        {crash_log_count, 5},
        {crash_log_date, "$D0"},
        {crash_log_msg_size, 65536},
        {crash_log_size, 10485760},
        {error_logger_hwm, 100},
        {error_logger_redirect, true},
        {handlers, [
            {lager_file_backend, [
                {"/var/log/riak/error.log", error, 10485760, "$D0", 5},
                {"/var/log/riak/console.log", info, 10485760, "$D0", 5}
            ]}
        ]}
    ]},
    {merge_index, [
        {buffer_rollover_size, 1048576},
        {data_root, "/var/lib/riak/merge_index"},
        {max_compact_segments, 20}
    ]},
    {riak_api, [
        {pb, [
            {"33.33.33.10", 8888}
        ]}
    ]},
    {riak_control, [
        {admin, true},
        {auth, userlist},
        {enabled, true},
        {userlist, [
            {"user", "pass"}
        ]}
    ]},
    {riak_core, [
        {dtrace_support, false},
        {handoff_port, 8099},
        {http, [
            {"10.0.2.15", 8098}
        ]},
        {https, [
            {"10.0.2.15", 8069}
        ]},
        {platform_bin_dir, "/usr/sbin"},
        {platform_data_dir, "/var/lib/riak"},
        {platform_etc_dir, "/etc/riak"},
        {platform_lib_dir, "/usr/lib/riak"},
        {platform_log_dir, "/var/log/riak"},
        {ring_creation_size, 64},
        {ring_state_dir, "/var/lib/riak/ring"},
        {ssl, [
            {certfile, "/etc/riak/riak-control-cert.pem"},
            {keyfile, "/etc/riak/riak-control-key.pem"}
        ]}
    ]},
    {riak_jmx, [
        {enabled, false}
    ]},
    {riak_kv, [
        {anti_entropy, {on, [
            ]}},
        {anti_entropy_build_limit, {1, 3600000}},
        {anti_entropy_concurrency, 2},
        {anti_entropy_data_dir, "/var/lib/riak/anti_entropy"},
        {anti_entropy_expire, 604800000},
        {anti_entropy_leveldb_opts, [
            {write_buffer_size, 4194304},
            {max_open_files, 20}
        ]},
        {anti_entropy_tick, 15000},
        {fsm_limit, 50000},
        {hook_js_vm_count, 2},
        {http_url_encoding, on},
        {js_max_vm_mem, 8},
        {js_thread_stack, 16},
        {listkeys_backpressure, true},
        {map_js_vm_count, 8},
        {mapred_2i_pipe, true},
        {mapred_name, "mapred"},
        {object_format, v1},
        {reduce_js_vm_count, 6},
        {storage_backend, riak_kv_bitcask_backend},
        {vnode_vclocks, true}
    ]},
    {riak_repl, [
        {data_root, "/var/lib/riak/riak_repl"}
    ]},
    {riak_search, [
        {enabled, false}
    ]},
    {riak_sysmon, [
        {busy_dist_port, true},
        {busy_port, true},
        {gc_ms_limit, 0},
        {heap_word_limit, 40111000},
        {port_limit, 2},
        {process_limit, 30}
    ]},
    {sasl, [
        {sasl_error_logger, false}
    ]},
    {snmp, [
        {agent, [
            {config, [
                {dir, "/etc/riak/snmp/agent/conf"},
                {force_load, true}
            ]},
            {db_dir, "/var/lib/riak/snmp/agent/db"},
            {net_if, [
                {options, [
                    {bind_to, true}
                ]}
            ]}
        ]}
    ]}
].

What version of Chef are you running?

$ chef-client --version
Chef: 11.6.0
kkalin78 commented 11 years ago

Hmm. I will try one more time. I use chef-solo 10.26

hectcastro commented 11 years ago

So after taking a closer look, Chef 11 overrides the attributes but 10.26 does not. For users on 10.x, we've suggested the following wrapper cookbook approach:

include_recipe "riak"

# Remove merged settings because override works differently on Chef 10
file "#{node['riak']['package']['config_dir']}/app.config" do
  content Proc.new {
    config = node['riak']['config'].to_hash
    # Deletes the unwanted attribute index
    config['riak_core']['pb'].delete_at(0)

    Eth::Config.new(config).pp
  }.call
  owner "root"
  mode 0644
  notifies :restart, "service[riak]"
end