Skip to content

Instantly share code, notes, and snippets.

@smford22
smford22 / config.xml
Created May 1, 2015 05:24
Jenkins Accept Job
<?xml version='1.0' encoding='UTF-8'?>
<project>
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties>
<com.coravy.hudson.plugins.github.GithubProjectProperty plugin="github@1.11">
<projectUrl>https://github.com/smford22/sample-cookbook/</projectUrl>
</com.coravy.hudson.plugins.github.GithubProjectProperty>
<hudson.model.ParametersDefinitionProperty>
@smford22
smford22 / config.xml
Created May 1, 2015 05:25
Jenkins Ship Job
<?xml version='1.0' encoding='UTF-8'?>
<project>
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties>
<com.coravy.hudson.plugins.github.GithubProjectProperty plugin="github@1.11">
<projectUrl>https://github.com/smford22/chef-repo/</projectUrl>
</com.coravy.hudson.plugins.github.GithubProjectProperty>
<hudson.model.ParametersDefinitionProperty>
@smford22
smford22 / local-user-account.md
Last active October 29, 2015 13:32
Local user account creation rule
rules 'local-user-account-creation'
  rule on run_resource
  when
    resource_type = 'user'
      and
    resource_result = 'create'
  then
   alert:warn('Local user account {{message.resource_name}} created on {{message.run.node_name}}')
 notify('slack', '
@smford22
smford22 / updated_resources.md
Created November 5, 2015 16:18
Updated resource - Chef Analytics Rule
rules 'updated-resources'
  rule on run_converge
  when
    updated_resource_count > 0
  then
   notify('slack', '
{
"username": "Chef Server",
"icon_emoji": ":chef:",
@smford22
smford22 / failed_audit.md
Created November 5, 2015 16:20
failed audit Chef Analytics rule
rules 'failed-audit'
 rule on run_control_group
 when
   status != 'success'
 then
   alert:warn('{{message.cookbook_name}} {{message.recipe_name}} audit failed')
   notify('slack', '
{
"username": "Audit Alarm",
@smford22
smford22 / unauthorized_cookbook_upload.md
Created November 5, 2015 16:21
Unauthorized cookbook upload rule
rules 'Unauthorized Cookbook Upload'
  rule on action
  when
    parent_type = 'cookbook' and requestor_name != 'jenkins_user'
  then
    audit:error("An unauthorized user updated the {{message.parent_name}} cookbook at {{message.recorded_at}} UTC! USERNAME: {{message.requestor_name}}!")
   notify('slack', '
{
"username": "Audit Alarm",
@smford22
smford22 / chef_compliance_api.md
Last active December 15, 2016 00:24
Getting Started with the Chef Compliance API

Getting Started with the Chef Compliance API

Demo how to setup accessing the Chef Compliance server's api and some of the useful things you can do with it.

Access tokens

In order to make requests against the Chef Compliance's API you need to have a token to authenticate. There are two types of token:

  1. Refresh Tokens - A long-lived token that can be used to initially identify with the service, in exchange for an access token
  2. Access Tokens - A short-lived (12 hours) and used for every request against the API.

Obtaining Tokens

There are a couple of ways to get refresh tokens and access tokens which are explained on the doc.chef.io

@smford22
smford22 / config.json
Last active February 16, 2017 00:18
Workflow base config.json
{
"version": "2",
"build_cookbook": {
"name": "build_cookbook",
"path": ".delivery/build_cookbook"
},
"delivery-truck": {
"publish": {
"chef_server": true
}
@smford22
smford22 / delivery_rb.md
Created February 17, 2017 16:54
Add valid SSL to Chef Automate

Overview

The folloiwng example shows how to add valid SSL certs to your Chef Automate server

/etc/delivery/delivery.rb

delivery["ssl_certificates"] = {
  "<my_hostname>" => {
    "crt" => "file:///etc/delivery/certificate_chained.pem",
    "key" => "file:///etc/delivery/key.pem"
 }
@smford22
smford22 / base_linux.md
Last active March 2, 2017 17:54
base linux role
name "base_linux"
description "A base role for all linux nodes"
run_list 'recipe[cookbook::recipe]', 'recipe[cookbook::recipe]'
default_attributes({
  "audit" => {
    "collector" => "chef-server-visibility",
    "profiles" => [
      {
 "name" =&gt; 'linux-patch-baseline',