Skip to content

Instantly share code, notes, and snippets.

@zmaupin
Last active August 21, 2019 21:02
Show Gist options
  • Select an option

  • Save zmaupin/ca53af41e6a013ccb95cd5a6aa2f3eb9 to your computer and use it in GitHub Desktop.

Select an option

Save zmaupin/ca53af41e6a013ccb95cd5a6aa2f3eb9 to your computer and use it in GitHub Desktop.

Managing the monitoring attribute on Chef nodes

Disabling monitoring

tl;dr

Add the role disabled_monitoring to your node. Run chef-client on the node.

How can I do that?

  • Add the role 'disabled_monitoring' to your node then run chef-client.

    $ knife node add run_list $node_fqdn 'role[disabled_monitoring]' ; knife ssh "fqdn:$node_fqdn" "sudo chef-client"

Wait...add a role to set a node attribute?

Yes! The role sets the attribute for you. If you want to perform this manually, add the following attribute to your node object.

    "monitoring": {
      "disabled": "true"
    }

This is what a node looks like with monitoring disabled.

{
  "name": "stage2-node.s2r1.internal.digitalocean.com",
  "chef_environment": "stage2_nyc3_s2r1",
  "normal": {
    "tags": [

    ],
    "monitoring": {
      "disabled": "true"
    }
  },
  "policy_name": null,
  "policy_group": null,
  "run_list": [
    "recipe[base-minimal]",
    "role[disabled_monitoring]"
  ]
}

Enabling monitoring

tl;dr

Remove the role disabled_monitoring from your node, delete the node['monitoring']['disabled'] attribute from your node, and run chef-client.

How can I do that?

  • Edit the node object

    $ knife node edit fqdn

    Delete the lines:

    "monitoring": {
      "disabled": "true"
    }

​ Then in the same file, remove role[disabled_monitoring] from the run list:

```bash` "role[disabled_monitoring]"


​	Save the file and then you're done!

This is what a node looks like with monitoring _enabled_.

```bash
{
  "name": "stage2-node.s2r1.internal.digitalocean.com",
  "chef_environment": "stage2_nyc3_s2r1",
  "normal": {
    "tags": [

    ],
  },
  "policy_name": null,
  "policy_group": null,
  "run_list": [
    "recipe[base-minimal]"
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment