Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compliance uses ChefDK 1.0.3 #20

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions build_compliance_workstations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh
# Builds training instances in EC2
USAGE="Usage: $0 [number] [name] [department] [contact] [project] [termination-date]"

AMI_ID=ami-614d7476

NUMHOSTS=$1
NAME=$2
DEPT=$3
CONTACT=$4
PROJECT=$5
TERM_DATE=$6

INSTANCE_TYPE="t2.small"
KEY_NAME=$AWS_KEYPAIR_NAME

if [ "$#" -ne 6 ]; then
echo $USAGE
exit 1
fi

for host in $(aws ec2 run-instances --image-id $AMI_ID --region us-east-1 --count $NUMHOSTS --instance-type $INSTANCE_TYPE --key-name $KEY_NAME --security-group-ids "sg-a1c3b1db" --subnet-id subnet-46b55431 | jq -r ".Instances|.[].InstanceId"); do
echo "Created instance: $host"
echo "Tagging $host with \"$NAME\""
aws ec2 create-tags --resources $host --tags "Key=Name,Value=\"$NAME\""
aws ec2 create-tags --resources $host --tags "Key=X-Dept,Value=\"$DEPT\""
aws ec2 create-tags --resources $host --tags "Key=X-Contact,Value=\"$CONTACT\""
aws ec2 create-tags --resources $host --tags "Key=X-Project,Value=\"$PROJECT\""
aws ec2 create-tags --resources $host --tags "Key=X-Termination-Date,Value=\"$TERM_DATE\""
done
15 changes: 7 additions & 8 deletions compliance-centos.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"variables": {
"aws_access_key": "",
"aws_secret_key": "",
"aws_keypair_name": "training-ec2-keypair",
"aws_keypair_file": "{{env `TRAINING_AWS_KEYPAIR`}}"
"aws_access_key": "{{env `AWS_ACCESS_KEY`}}",
"aws_secret_key": "{{env `AWS_SECRET_KEY`}}",
"aws_keypair_name": "{{env `AWS_KEYPAIR_NAME`}}",
"aws_keypair_file": "{{env `AWS_PRIVATE_KEY_PATH`}}"
},
"builders": [{
"type": "amazon-ebs",
Expand All @@ -14,14 +14,13 @@
"ssh_private_key_file": "{{user `aws_keypair_file`}}",
"region": "us-east-1",
"instance_type": "m3.medium",
"source_ami": "ami-c10044a4",
"ssh_username": "root",
"ami_name": "Compliance - CentOS 6.7 - 1.0.9"
"source_ami": "ami-6d1c2007",
"ssh_username": "centos",
"ami_name": "Compliance - CentOS 7 - 1.1.1"
}],

"provisioners": [{
"type": "chef-solo",
"install_command": "curl -L https://www.chef.io/chef/install.sh | {{if .Sudo}}sudo{{end}} bash -s",
"cookbook_paths": ["cookbooks"],
"run_list": ["workstations::compliance"]

Expand Down
28 changes: 28 additions & 0 deletions compliance-rhel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"variables": {
"aws_access_key": "{{env `AWS_ACCESS_KEY`}}",
"aws_secret_key": "{{env `AWS_SECRET_KEY`}}",
"aws_keypair_name": "{{env `AWS_KEYPAIR_NAME`}}",
"aws_keypair_file": "{{env `AWS_PRIVATE_KEY_PATH`}}"
},
"builders": [{
"type": "amazon-ebs",
"ssh_pty": true,
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"ssh_keypair_name": "{{user `aws_keypair_name`}}",
"ssh_private_key_file": "{{user `aws_keypair_file`}}",
"region": "us-east-1",
"instance_type": "m3.medium",
"source_ami": "ami-2051294a",
"ssh_username": "ec2-user",
"ami_name": "Compliance Workshop Workstation (ChefDK 1.0.3)- RedHat 7 - 1.3.1"
}],

"provisioners": [{
"type": "chef-solo",
"cookbook_paths": ["cookbooks"],
"run_list": ["workstations::compliance"]

}]
}
35 changes: 35 additions & 0 deletions cookbooks/compat_resource/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# compat_resource Cookbook CHANGELOG

This file is used to list changes made in each version of the compat_resource cookbook.

## 12.14.7 (2016-09-26)
- Update to 12.14.89 Chef
- Fix autoload by applying fix from #106

## 12.14.6 (2016-09-20)

- Update backported codebase to Chef 12.14.77 which brings in yum_repository updates and why-run enabled by default in custom resources

## 12.14.5 (2016-09-19)

- Prevent spamming messages in Chefspec runs for cookbooks that depend on compat_resource

## 12.14.4 (2016-09-19)

- Fix delayed notifications cloning

## 12.14.3 (2016-09-12)

- Fix subscribes notifications

## 12.14.2 (2016-09-09)

- Improve documentation
- keep ChefCompat::Resource defined even if we don't load

## 12.14.1 (2016-09-07)

- add yum_repository resource from Chef 12.14
- Update the minimum chef version in the metadata to 12.1
- Added maintainers files
- suppress constant redef warnings when running chefspec
2 changes: 2 additions & 0 deletions cookbooks/compat_resource/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Please refer to
https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD
16 changes: 16 additions & 0 deletions cookbooks/compat_resource/MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!-- This is a generated file. Please do not edit directly -->

# Maintainers

This file lists how this cookbook project is maintained. When making changes to the system, this file tells you who needs to review your patch - you need a review from an existing maintainer for the cookbook to provide a :+1: on your pull request. Additionally, you need to not receive a veto from a Lieutenant or the Project Lead.

Check out [How Cookbooks are Maintained](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD) for details on the process and how to become a maintainer or the project lead.

# Project Maintainer
* [Lamont Granquist](https://github.com/lamont-granquist)

# Maintainers
* [Jennifer Davis](https://github.com/sigje)
* [Tim Smith](https://github.com/tas50)
* [Thom May](https://github.com/thommay)
* [Lamont Granquist](https://github.com/lamont-granquist)
51 changes: 51 additions & 0 deletions cookbooks/compat_resource/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# compat_resource cookbook

[![Build Status](https://travis-ci.org/chef-cookbooks/compat_resource.svg?branch=master)](https://travis-ci.org/chef-cookbooks/compat_resource) [![Cookbook Version](https://img.shields.io/cookbook/v/compat_resource.svg)](https://supermarket.chef.io/cookbooks/compat_resource)

This cookbook backports functionality introduced in the latest chef-client releases to any chef-client from 12.1 onwards. This includes [Custom Resource](https://docs.chef.io/custom_resources.html) functionality, notification improvements, as well as new resources added to core chef. It allows for the usage of these new resources in cookbooks without requiring the very latest Chef client release.

## Backported functionality

- [Custom Resources](https://docs.chef.io/custom_resources.html)
- [apt_repository](https://docs.chef.io/resource_apt_repository.html)
- [apt_update](https://docs.chef.io/resource_apt_update.html)
- [systemd_unit](https://docs.chef.io/resource_systemd_unit.html)
- [yum_repository](https://docs.chef.io/resource_yum_repository.html)
- [:before notifications](https://docs.chef.io/resources.html#timers)

## Requirements

### Platforms

- All platforms supported by Chef

### Chef

- Chef 12.1+

### Cookbooks

- none

## Usage

To use this cookbook, put `depends 'compat_resource'` in the metadata.rb of your cookbook. Once this is done, you can use all the new custom resource features to define resources. It Just Works.

## Custom Resources?

Curious about how to use custom resources?

- Docs: <https://docs.chef.io/custom_resources.html>
- Slides: <https://docs.chef.io/decks/custom_resources.html>

## License & Authors

**Author:** John Keiser ([jkeiser@chef.io](mailto:jkeiser@chef.io))

**Copyright:** 2015-2016, Chef Software, Inc. ``` Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

```
http://www.apache.org/licenses/LICENSE-2.0
```

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module ChefCompat
module CopiedFromChef
def self.extend_chef_module(chef_module, target)
target.instance_eval do
include chef_module
@chef_module = chef_module
def self.method_missing(name, *args, &block)
@chef_module.send(name, *args, &block)
end
def self.const_missing(name)
@chef_module.const_get(name)
end
end
end

# This patch to CopiedFromChef's ActionClass is necessary for the include to work
require 'chef/resource'
class Chef < ::Chef
class Resource < ::Chef::Resource
module ActionClass
def self.use_inline_resources
end
def self.include_resource_dsl(include_resource_dsl)
end
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#
# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
#
# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!!
#
# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
#

begin
require 'chef/constants'
rescue LoadError; end

require 'chef_compat/copied_from_chef'
class Chef
module ::ChefCompat
module CopiedFromChef
#
# Author:: John Keiser <jkeiser@chef.io>
# Copyright:: Copyright 2015-2016, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

class Chef < (defined?(::Chef) ? ::Chef : Object)
NOT_PASSED = Object.new
def NOT_PASSED.to_s
"NOT_PASSED"
end

def NOT_PASSED.inspect
to_s
end
NOT_PASSED.freeze
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
#
# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!!
#
# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
#

begin
require 'chef/delayed_evaluator'
rescue LoadError; end

require 'chef_compat/copied_from_chef'
class Chef
module ::ChefCompat
module CopiedFromChef
#
# Author:: John Keiser <jkeiser@chef.io>
# Copyright:: Copyright 2015-2016, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

class Chef < (defined?(::Chef) ? ::Chef : Object)
class DelayedEvaluator < (defined?(::Chef::DelayedEvaluator) ? ::Chef::DelayedEvaluator : Proc)
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#
# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
#
# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!!
#
# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
#

begin
require 'chef/dsl/core'
rescue LoadError; end

require 'chef_compat/copied_from_chef'
class Chef
module ::ChefCompat
module CopiedFromChef
#--
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Christopher Walters (<cw@chef.io>)
# Copyright:: Copyright 2008-2016, 2009-2015 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require "chef_compat/copied_from_chef/chef/dsl/declare_resource"
require "chef_compat/copied_from_chef/chef/dsl/universal"
require "chef_compat/copied_from_chef/chef/mixin/notifying_block"
require "chef_compat/copied_from_chef/chef/mixin/lazy_module_include"

class Chef < (defined?(::Chef) ? ::Chef : Object)
module DSL
CopiedFromChef.extend_chef_module(::Chef::DSL, self) if defined?(::Chef::DSL)
# Part of a family of DSL mixins.
#
# Chef::DSL::Recipe mixes into Recipes and LWRP Providers.
# - this does not target core chef resources and providers.
# - this is restricted to recipe/resource/provider context where a resource collection exists.
# - cookbook authors should typically include modules into here.
#
# Chef::DSL::Core mixes into Recipes, LWRP Providers and Core Providers
# - this adds cores providers on top of the Recipe DSL.
# - this is restricted to recipe/resource/provider context where a resource collection exists.
# - core chef authors should typically include modules into here.
#
# Chef::DSL::Universal mixes into Recipes, LWRP Resources+Providers, Core Resources+Providers, and Attributes files.
# - this adds resources and attributes files.
# - do not add helpers which manipulate the resource collection.
# - this is for general-purpose stuff that is useful nearly everywhere.
# - it also pollutes the namespace of nearly every context, watch out.
#
module Core
CopiedFromChef.extend_chef_module(::Chef::DSL::Core, self) if defined?(::Chef::DSL::Core)
include Chef::DSL::Universal
include Chef::DSL::DeclareResource
include Chef::Mixin::NotifyingBlock
extend Chef::Mixin::LazyModuleInclude
end
end
end
end
end
end
Loading