Configure Sensu to use the RabbitMQ cluster using sensu-puppet module and rabbitmq_cluster

Hello everyone,

I hope this is the correct place to ask about the sensu-puppet module. I could find no better place but if there is one, please let me know.

I’m working on puppetizing our sensu server deploy and configuration. It work quite well but there is one thing I can’t get to work and I can’t find any documentation on how it should work. I’m using the latest version of sensu and the puppet module.

The issue

After the initial puppet run I get this error

Error: /Stage[main]/Sensu::Rabbitmq::Config/Sensu_rabbitmq_config[sensu-26-0.foo.bar]: Could not evaluate: no implicit conversion of String into Integer

If I remove /etc/sensu/conf.d/rabbitmq.json the next puppet run will run fine but the following one fails with the same error.

I’m trying to use **rabbitmq_cluster (**https://github.com/sensu/sensu-puppet/blob/master/manifests/init.pp#L157-L159)

The only documentation I can find is that rabbitmq_cluster should be **"**Array of hashes. Rabbitmq Cluster configuration and connection information for one or more Cluster"

In hiera I have

sensu::rabbitmq_cluster:

  • port: 5671

    host: 192.168.113.9

    user: sensu

    password: REDACTED

    vhost: “sensu”

    heartbeat: 30

    prefetch: 50

    ssl: {

    cert_chain_file: “/etc/sensu/ssl/cert.pem”,

    private_key_file: “/etc/sensu/ssl/key.pem”

    }

  • port: 5671

    host: 192.168.113.10

    user: sensu

    password: REDACTED

    vhost: “sensu”

    heartbeat: 30

    prefetch: 50

    ssl: {

    cert_chain_file: “/etc/sensu/ssl/cert.pem”,

    private_key_file: “/etc/sensu/ssl/key.pem”

    }

  • port: 5671

    host: 192.168.113.11

    user: sensu

    password: REDACTED

    vhost: “sensu”

    heartbeat: 30

    prefetch: 50

    ssl: {

    cert_chain_file: “/etc/sensu/ssl/cert.pem”,

    private_key_file: “/etc/sensu/ssl/key.pem”

    }

That will generate a working /etc/sensu/conf.d/rabbitmq.json that looks like this

sensu-26-0 /root # cat /etc/sensu/conf.d/rabbitmq.json

{

“rabbitmq”: [

{

  "port": 5671,

  "host": "192.168.113.9",

  "user": "sensu",

  "password": "REDACTED",

  "vhost": "sensu",

  "heartbeat": 30,

  "prefetch": 50,

  "ssl": {

    "cert_chain_file": "/etc/sensu/ssl/cert.pem",

    "private_key_file": "/etc/sensu/ssl/key.pem"

  }

},

{

  "port": 5671,

  "host": "192.168.113.10",

  "user": "sensu",

  "password": "REDACTED",

  "vhost": "sensu",

  "heartbeat": 30,

  "prefetch": 50,

  "ssl": {

    "cert_chain_file": "/etc/sensu/ssl/cert.pem",

    "private_key_file": "/etc/sensu/ssl/key.pem"

  }

},

{

  "port": 5671,

  "host": "192.168.113.11",

  "user": "sensu",

  "password": "REDACTED",

  "vhost": "sensu",

  "heartbeat": 30,

  "prefetch": 50,

  "ssl": {

    "cert_chain_file": "/etc/sensu/ssl/cert.pem",

    "private_key_file": "/etc/sensu/ssl/key.pem"

  }

}

]

}

That looks like what I want to see based on the latests Sensu documentation

https://sensuapp.org/docs/0.26/reference/rabbitmq.html#configure-sensu-to-use-the-rabbitmq-cluster

Problem/Cause

This behavior seems to be caused by https://github.com/sensu/sensu-puppet/blob/master/lib/puppet/provider/sensu_rabbitmq_config/json.rb which seems to be reading the active rabbitmq.json from disk before attempting to make changes. This read fails, or that is my interpretation to the situation. I do not know Ruby so I might very well be completely wrong. It also seems that the json.br does not know heartbeat and prefetch but leaving them out does not change the situation.

If anyone has used rabbitmq_cluster succesfully, could you please let me know how you structured your list of hashes.

Cheers,

AB

I think you are correct. Specifically it looks like the “value.to_i” things are activating even when in “cluster mode” (an array of hashes).

I don’t know exactly what should be done, but probably the best support channel would be on the sensu-puppet github itself. Open an issue and cc the original author (whermann) for advice.

···

On Mon, Jan 2, 2017 at 12:50 AM, AB anders@brandwatch.com wrote:

Hello everyone,

I hope this is the correct place to ask about the sensu-puppet module. I could find no better place but if there is one, please let me know.

I’m working on puppetizing our sensu server deploy and configuration. It work quite well but there is one thing I can’t get to work and I can’t find any documentation on how it should work. I’m using the latest version of sensu and the puppet module.

The issue

After the initial puppet run I get this error

Error: /Stage[main]/Sensu::Rabbitmq::Config/Sensu_rabbitmq_config[sensu-26-0.foo.bar]: Could not evaluate: no implicit conversion of String into Integer

If I remove /etc/sensu/conf.d/rabbitmq.json the next puppet run will run fine but the following one fails with the same error.

I’m trying to use rabbitmq_cluster (https://github.com/sensu/sensu-puppet/blob/master/manifests/init.pp#L157-L159)

The only documentation I can find is that rabbitmq_cluster should be **“**Array of hashes. Rabbitmq Cluster configuration and connection information for one or more Cluster”

In hiera I have

sensu::rabbitmq_cluster:

  • port: 5671
host: 192.168.113.9
user: sensu
password: REDACTED
vhost: "sensu"
heartbeat: 30
prefetch: 50
ssl: {
  cert_chain_file: "/etc/sensu/ssl/cert.pem",
  private_key_file: "/etc/sensu/ssl/key.pem"
  }
  • port: 5671
host: 192.168.113.10
user: sensu
password: REDACTED
vhost: "sensu"
heartbeat: 30
prefetch: 50
ssl: {
  cert_chain_file: "/etc/sensu/ssl/cert.pem",
  private_key_file: "/etc/sensu/ssl/key.pem"
  }
  • port: 5671
host: 192.168.113.11
user: sensu
password: REDACTED
vhost: "sensu"
heartbeat: 30
prefetch: 50
ssl: {
  cert_chain_file: "/etc/sensu/ssl/cert.pem",
  private_key_file: "/etc/sensu/ssl/key.pem"
  }

That will generate a working /etc/sensu/conf.d/rabbitmq.json that looks like this

sensu-26-0 /root # cat /etc/sensu/conf.d/rabbitmq.json

{

“rabbitmq”: [

{
  "port": 5671,
  "host": "192.168.113.9",
  "user": "sensu",
  "password": "REDACTED",
  "vhost": "sensu",
  "heartbeat": 30,
  "prefetch": 50,
  "ssl": {
    "cert_chain_file": "/etc/sensu/ssl/cert.pem",
    "private_key_file": "/etc/sensu/ssl/key.pem"
  }
},
{
  "port": 5671,
  "host": "192.168.113.10",
  "user": "sensu",
  "password": "REDACTED",
  "vhost": "sensu",
  "heartbeat": 30,
  "prefetch": 50,
  "ssl": {
    "cert_chain_file": "/etc/sensu/ssl/cert.pem",
    "private_key_file": "/etc/sensu/ssl/key.pem"
  }
},
{
  "port": 5671,
  "host": "192.168.113.11",
  "user": "sensu",
  "password": "REDACTED",
  "vhost": "sensu",
  "heartbeat": 30,
  "prefetch": 50,
  "ssl": {
    "cert_chain_file": "/etc/sensu/ssl/cert.pem",
    "private_key_file": "/etc/sensu/ssl/key.pem"
  }
}

]

}

That looks like what I want to see based on the latests Sensu documentation

https://sensuapp.org/docs/0.26/reference/rabbitmq.html#configure-sensu-to-use-the-rabbitmq-cluster

Problem/Cause

This behavior seems to be caused by https://github.com/sensu/sensu-puppet/blob/master/lib/puppet/provider/sensu_rabbitmq_config/json.rb which seems to be reading the active rabbitmq.json from disk before attempting to make changes. This read fails, or that is my interpretation to the situation. I do not know Ruby so I might very well be completely wrong. It also seems that the json.br does not know heartbeat and prefetch but leaving them out does not change the situation.

If anyone has used rabbitmq_cluster succesfully, could you please let me know how you structured your list of hashes.

Cheers,

AB

In case someone else is struggling with the same issue I had. It turned out to be an issue between the chair and the screens…

If you want to use rabbitmq_cluster you can not define any other rabbitmq*_ parameters

This is what I ended up with in hiera

profile::service::sensu::rabbitmq_cluster:

  • port: 5671
    host: 10.0.0.9
    user: sensu
    password: password
    vhost: “sensu”
    prefetch: 50
    heartbeat: 30
    ssl: {
    cert_chain_file: “/etc/sensu/rabbitmq_ssl_cert.pem”,
    private_key_file: “/etc/sensu/rabbitmq_ssl_key.pem”
    }
  • port: 5671
    host: 10.0.0.10
    user: sensu
    password: password
    vhost: “sensu”
    prefetch: 50
    heartbeat: 30
    ssl: {
    cert_chain_file: “/etc/sensu/rabbitmq_ssl_cert.pem”,
    private_key_file: “/etc/sensu/rabbitmq_ssl_key.pem”
    }
  • port: 5671
    host: 10.0.0.11
    user: sensu
    password: password
    vhost: “sensu”
    prefetch: 50
    heartbeat: 30
    ssl: {
    cert_chain_file: “/etc/sensu/rabbitmq_ssl_cert.pem”,
    private_key_file: “/etc/sensu/rabbitmq_ssl_key.pem”
    }

``

I had to create separate file resources for the SSL certs.

Cheers,

AB

···

On Monday, 2 January 2017 17:56:49 UTC+1, Kyle Anderson wrote:

I think you are correct. Specifically it looks like the “value.to_i” things are activating even when in “cluster mode” (an array of hashes).

I don’t know exactly what should be done, but probably the best support channel would be on the sensu-puppet github itself. Open an issue and cc the original author (whermann) for advice.

On Mon, Jan 2, 2017 at 12:50 AM, AB and...@brandwatch.com wrote:

Hello everyone,

I hope this is the correct place to ask about the sensu-puppet module. I could find no better place but if there is one, please let me know.

I’m working on puppetizing our sensu server deploy and configuration. It work quite well but there is one thing I can’t get to work and I can’t find any documentation on how it should work. I’m using the latest version of sensu and the puppet module.

The issue

After the initial puppet run I get this error

Error: /Stage[main]/Sensu::Rabbitmq::Config/Sensu_rabbitmq_config[sensu-26-0.foo.bar]: Could not evaluate: no implicit conversion of String into Integer

If I remove /etc/sensu/conf.d/rabbitmq.json the next puppet run will run fine but the following one fails with the same error.

I’m trying to use rabbitmq_cluster (https://github.com/sensu/sensu-puppet/blob/master/manifests/init.pp#L157-L159)

The only documentation I can find is that rabbitmq_cluster should be **“**Array of hashes. Rabbitmq Cluster configuration and connection information for one or more Cluster”

In hiera I have

sensu::rabbitmq_cluster:

  • port: 5671
host: 192.168.113.9
user: sensu
password: REDACTED
vhost: "sensu"
heartbeat: 30
prefetch: 50
ssl: {
  cert_chain_file: "/etc/sensu/ssl/cert.pem",
  private_key_file: "/etc/sensu/ssl/key.pem"
  }
  • port: 5671
host: 192.168.113.10
user: sensu
password: REDACTED
vhost: "sensu"
heartbeat: 30
prefetch: 50
ssl: {
  cert_chain_file: "/etc/sensu/ssl/cert.pem",
  private_key_file: "/etc/sensu/ssl/key.pem"
  }
  • port: 5671
host: 192.168.113.11
user: sensu
password: REDACTED
vhost: "sensu"
heartbeat: 30
prefetch: 50
ssl: {
  cert_chain_file: "/etc/sensu/ssl/cert.pem",
  private_key_file: "/etc/sensu/ssl/key.pem"
  }

That will generate a working /etc/sensu/conf.d/rabbitmq.json that looks like this

sensu-26-0 /root # cat /etc/sensu/conf.d/rabbitmq.json

{

“rabbitmq”: [

{
  "port": 5671,
  "host": "192.168.113.9",
  "user": "sensu",
  "password": "REDACTED",
  "vhost": "sensu",
  "heartbeat": 30,
  "prefetch": 50,
  "ssl": {
    "cert_chain_file": "/etc/sensu/ssl/cert.pem",
    "private_key_file": "/etc/sensu/ssl/key.pem"
  }
},
{
  "port": 5671,
  "host": "192.168.113.10",
  "user": "sensu",
  "password": "REDACTED",
  "vhost": "sensu",
  "heartbeat": 30,
  "prefetch": 50,
  "ssl": {
    "cert_chain_file": "/etc/sensu/ssl/cert.pem",
    "private_key_file": "/etc/sensu/ssl/key.pem"
  }
},
{
  "port": 5671,
  "host": "192.168.113.11",
  "user": "sensu",
  "password": "REDACTED",
  "vhost": "sensu",
  "heartbeat": 30,
  "prefetch": 50,
  "ssl": {
    "cert_chain_file": "/etc/sensu/ssl/cert.pem",
    "private_key_file": "/etc/sensu/ssl/key.pem"
  }
}

]

}

That looks like what I want to see based on the latests Sensu documentation

https://sensuapp.org/docs/0.26/reference/rabbitmq.html#configure-sensu-to-use-the-rabbitmq-cluster

Problem/Cause

This behavior seems to be caused by https://github.com/sensu/sensu-puppet/blob/master/lib/puppet/provider/sensu_rabbitmq_config/json.rb which seems to be reading the active rabbitmq.json from disk before attempting to make changes. This read fails, or that is my interpretation to the situation. I do not know Ruby so I might very well be completely wrong. It also seems that the json.br does not know heartbeat and prefetch but leaving them out does not change the situation.

If anyone has used rabbitmq_cluster succesfully, could you please let me know how you structured your list of hashes.

Cheers,

AB