Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Example Roles

Roman Gorodeckij edited this page Dec 11, 2013 · 7 revisions

This cookbook heavily depends on roles, so that some recipes could detect IP of your node.

For example, when you install logstash::agent it will automatically search for the IP of the node where logstash_server role have been applied.

Note: Rabbitmq is optional in here, logstash::server comes without any message-queue service, so it's up to you to setup one. You can use redis, zeromq, or whatever you prefer. If you have roles with any other message-queue service, please share :)

elasticsearch_server.json

If you want to use kibana (lusis/chef-kibana) cookbook, recipe will search for elasticsearch_server role. If you don't need kibana, then this role is optional, logstash::server has an option for installing elasticsearch locally.

Note: Name of roles should be exactly as specified here or else recipe will fail to find it.

{
   "name": "elasticsearch_server",
   "default_attributes": {
   },
   "json_class": "Chef::Role",
   "run_list": [
        "recipe[java]",
        "recipe[elasticsearch]"
   ],
   "description": "",
   "chef_type": "role",
   "override_attributes": {
         "java": {
             "install_flavor": "openjdk",
             "jdk_version": "7"
         },
     "elasticsearch": {
         "cluster_name" : "logstash",
         "bootstrap.mlockall" : false
     }
   }
}

logstash_server.json

Note: Rabbitmq mgmt_console parameter is optional, this is just for debug purpose.

{
  "name": "logstash_server",
  "default_attributes": {},
  "json_class": "Chef::Role",
  "run_list": [
    "recipe[logstash::server]",
    "recipe[kibana]"
  ],
  "description": "",
  "chef_type": "role",
  "override_attributes": {
    "rabbitmq": {
        "mgmt_console": true
    },
    "logstash": {
      "install_rabbitmq": true,
      "server": {
        "enable_embedded_es": false,
        "inputs": [ {
          "rabbitmq": {
            "type": "direct",
            "host": "127.0.0.1",
            "exchange": "logstash-exchange",
            "key": "logstash-key",
            "exclusive": false,
            "durable": false,
            "auto_delete": false
          }
        } ]
      }
    }
  }
}

logstash_client.json

In here beaver is used as a client for logstash. Beaver is written in python, so you don't need install java as logstash::agent requires. Feel free to provide your example of logstash::agent.

{
  "name": "logstash_client",
  "default_attributes": {},
  "json_class": "Chef::Role",
  "run_list": [
    "recipe[logstash::beaver]"
  ],
  "description": "",
  "chef_type": "role",
  "override_attributes": {
    "logstash": {
      "supervisor_gid" : "adm",
      "beaver": {
        "inputs": [
          {
            "file": {
              "path": [
                "/var/log/*log"
              ],
              "type": "syslog",
              "tags": [
                "sys"
              ]
            }
          }
        ],
        "outputs": [
          {
            "rabbitmq": {
                "exchange_type": "direct",
                "exchange": "logstash-exchange"
            }
          }
        ]
      }
    }
  }
}
Clone this wiki locally