Skip to content

Commit 9ac5f66

Browse files
committed
First checkin
0 parents  commit 9ac5f66

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2025
-0
lines changed

.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.vagrant
2+
/cookbooks
3+
4+
# Bundler
5+
bin/*
6+
.bundle/*
7+
8+
.kitchen/
9+
.kitchen.local.yml
10+
11+
*.lock.json
12+
Policyfile.lock.json
13+
14+
.DS_Store

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# chef-cookbook-enroll CHANGELOG
2+
3+
This file is used to list changes made in each version of the chef-cookbook-enroll cookbook.
4+
5+
## 1.0.0
6+
7+
- First Release

LICENSE

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Copyright 2024 The Authors
2+
3+
All rights reserved, do not redistribute.

Policyfile.rb

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Policyfile.rb - Describe how you want Chef Infra Client to build your system.
2+
#
3+
# For more information on the Policyfile feature, visit
4+
# https://docs.chef.io/policyfile/
5+
6+
# A name that describes what the system you're building with Chef does.
7+
name 'chef-cookbook-enroll'
8+
9+
# Where to find external cookbooks:
10+
default_source :supermarket
11+
12+
# run_list: chef-client will run these recipes in the order specified.
13+
run_list 'chef-cookbook-enroll::default'
14+
15+
# Specify a custom source for a single cookbook:
16+
cookbook 'chef-cookbook-enroll', path: '.'

README.md

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
### Overview
2+
3+
The `node_management_enroll` custom resource is designed to streamline the process of enrolling nodes into a Chef-360 platform. This resource automates the configuration and setup required to ensure nodes are properly registered and managed by the Chef platform's node management service.
4+
5+
### Enrollment and Enrollment Levels
6+
Enrollment is the process that enables Chef 360 to interact with and potentially manage your node. The enrollment status level determines the extent of management and control Chef 360 has over the node. This level indicates the type and degree of management capabilities available.
7+
8+
The `node_management_enroll` resource supports two levels of enrollment:
9+
10+
1. **Full Enrollment**: Chef 360 has both Node Management and Habitat installed on the node, running as a Habitat supervised service. This level allows Chef 360 to manage skill credentials, settings, installation, upgrades, and removal.
11+
12+
2. **Partial Enrollment**: Chef 360 has Node Management running on the node, but as a native service (not under the Habitat supervisor or package manager). This level allows for the detection of native skills and skill credential management but does not support skill installation, upgrades, or configuration. This is suitable for nodes that do not support Habitat but require a specific skill like Courier Runner.
13+
14+
### Resource Parameters
15+
16+
| Parameter | Description | Valid Value | Default Value |
17+
|--------------------|------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------|--------------------------------|
18+
| `chef_platform_url`| The fully qualified domain name (FQDN) URL for the Chef 360 platform. | A FQDN which must be accessible from the client node. | None |
19+
| `api_port` | The API port configured in the Chef 360 platform. | A valid port number. | `31000` |
20+
| `access_key` | Access key for secure communication with Chef 360. Store securely (e.g., Encrypted Chef data bags, Vault). | valid token | None |
21+
| `secret_key` | Secret key for secure communication with Chef 360. Store securely (e.g., Encrypted Chef data bags, Vault). | valid token | None |
22+
| `cohort_id` | A UUID representing a cohort. It provides all required skills and settings to the assigned node. | UUID | None |
23+
| `hab_builder_url` | URL for the Chef Habitat builder in your organization. | Valid URL | `https://bldr.habitat.sh` |
24+
| `working_dir_path` | Temporary working directory path where all required builds are downloaded. Specify a valid path based on the OS. | A valid directory with read and write permission. | `/tmp` |
25+
| `upgrade_skills` | For partial enrollment. If true, checks for the latest skill version and installs it if found. | `'true'` or `'false'` | `false` |
26+
27+
28+
### Example Usage
29+
30+
```ruby
31+
node_management_enroll 'Enroll Node' do
32+
chef_platform_url '<CHEF-360-FQDN>'
33+
enroll_type 'full/partial'
34+
api_port '<API_PORT>'
35+
access_key '<ACCESS_KEY>'
36+
secret_key '<SECRET_KEY>'
37+
cohort_id '<COHORT_ID>'
38+
hab_builder_url '<HABITAT_BUILDER_URL>'
39+
working_dir_path '<VALID_DIR_PATH>'
40+
upgrade_skills false
41+
end
42+
```
43+
## Using the `node_management_enroll` Custom Resource
44+
45+
The `node_management_enroll` custom resource is designed to simplify the process of enrolling nodes into a Chef-managed environment. Follow these steps to use this resource:
46+
47+
### 1. Upload the Custom Resource Cookbook to the Chef Server
48+
49+
First, upload the cookbook containing the `node_management_enroll` resource to the Chef server. Replace `COOKBOOK_DIR_PATH` with the path to your cookbook directory:
50+
51+
```bash
52+
knife cookbook upload chef-cookbook-enroll --cookbook-path COOKBOOK_DIR_PATH
53+
```
54+
55+
### 2. Create a Wrapper Cookbook
56+
57+
Next, create a wrapper cookbook to manage the custom resource's usage. In the `metadata.rb` file of your wrapper cookbook, add the following dependency to include the `chef-cookbook-enroll` cookbook:
58+
59+
```ruby
60+
depends 'chef-cookbook-enroll', '~> 1.0.0'
61+
```
62+
63+
### 3. Update the Wrapper Cookbook's Recipe with the Custom Resource
64+
65+
In your wrapper cookbook's recipe, configure the `node_management_enroll` resource as follows:
66+
67+
```ruby
68+
node_management_enroll 'Enroll Node' do
69+
chef_platform_url '<CHEF-360-FQDN>'
70+
enroll_type 'full/partial'
71+
api_port '<API_PORT>'
72+
access_key '<ACCESS_KEY>'
73+
secret_key '<SECRET_KEY>'
74+
cohort_id '<COHORT_ID>'
75+
hab_builder_url '<HABITAT_BUILDER_URL>'
76+
working_dir_path '<VALID_DIR_PATH>'
77+
upgrade_skills false
78+
end
79+
```
80+
81+
Replace the placeholders with the actual values for your environment.
82+
83+
### 4. Push the Wrapper Cookbook or Policy to the Chef Server
84+
85+
Depending on whether you are using a role or a policy, follow the appropriate steps:
86+
87+
#### a) If Using a Role
88+
89+
Push the wrapper cookbook to the Chef server using the following command:
90+
91+
```bash
92+
knife cookbook upload YOUR_WRAPPER_COOKBOOK_NAME --cookbook-path WRAPPER_COOKBOOK_DIR_PATH
93+
```
94+
95+
#### b) If Using a Policy
96+
97+
Push the policy to the Chef server using the following commands:
98+
99+
```bash
100+
chef install
101+
chef push <POLICY_GROUP> <POLICY_NAME>
102+
```
103+
104+
### 5. Apply the Wrapper Cookbook in Role/Policy
105+
106+
Finally, ensure that the wrapper cookbook is included in your node's run-list by adding it to a role or policy. This will execute the `node_management_enroll` resource during the Chef run.
107+

attributes/default.rb

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
default['enroll']['node_role_id'] = '633daf9a-7aa8-4851-9b7d-88b12be9a87b'
2+
default['enroll']['tools'] = %w(chef-gohai courier-client inspec_interpreter node-management-agent restart-interpreter shell-interpreter chef-client-interpreter)
3+
default['enroll']['interpreters'] = %w(shell-interpreter inspec-interpreter restart-interpreter chef-client-interpreter)
4+
default['enroll']['nodeman_pkg'] = 'node-management-agent'
5+
default['enroll']['runner_pkg'] = 'courier-runner'
6+
default['enroll']['gohai_pkg'] = 'chef-gohai'
7+
default['enroll']['cookbook_name'] = 'chef-cookbook-enroll'
8+
9+
default['enroll']['node_guid_file'] = if platform?('windows')
10+
"c:\\hab\\svc\\#{node['enroll']['nodeman_pkg']}\\data\\node_guid"
11+
else
12+
"/hab/svc/#{node['enroll']['nodeman_pkg']}/data/node_guid"
13+
end

chefignore

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Put files/directories that should be ignored in this file when uploading
2+
# to a Chef Infra Server or Supermarket.
3+
# Lines that start with '# ' are comments.
4+
5+
# OS generated files #
6+
######################
7+
.DS_Store
8+
ehthumbs.db
9+
Icon?
10+
nohup.out
11+
Thumbs.db
12+
.envrc
13+
14+
# EDITORS #
15+
###########
16+
.#*
17+
.project
18+
.settings
19+
*_flymake
20+
*_flymake.*
21+
*.bak
22+
*.sw[a-z]
23+
*.tmproj
24+
*~
25+
\#*
26+
REVISION
27+
TAGS*
28+
tmtags
29+
.vscode
30+
.editorconfig
31+
32+
## COMPILED ##
33+
##############
34+
*.class
35+
*.com
36+
*.dll
37+
*.exe
38+
*.o
39+
*.pyc
40+
*.so
41+
*/rdoc/
42+
a.out
43+
mkmf.log
44+
45+
# Testing #
46+
###########
47+
.circleci/*
48+
.codeclimate.yml
49+
.delivery/*
50+
.foodcritic
51+
.kitchen*
52+
.mdlrc
53+
.overcommit.yml
54+
.rspec
55+
.rubocop.yml
56+
.travis.yml
57+
.watchr
58+
.yamllint
59+
azure-pipelines.yml
60+
Dangerfile
61+
examples/*
62+
features/*
63+
Guardfile
64+
kitchen.yml*
65+
mlc_config.json
66+
Procfile
67+
Rakefile
68+
spec/*
69+
test/*
70+
71+
# SCM #
72+
#######
73+
.git
74+
.gitattributes
75+
.gitconfig
76+
.github/*
77+
.gitignore
78+
.gitkeep
79+
.gitmodules
80+
.svn
81+
*/.bzr/*
82+
*/.git
83+
*/.hg/*
84+
*/.svn/*
85+
86+
# Berkshelf #
87+
#############
88+
Berksfile
89+
Berksfile.lock
90+
cookbooks/*
91+
tmp
92+
93+
# Bundler #
94+
###########
95+
vendor/*
96+
Gemfile
97+
Gemfile.lock
98+
99+
# Policyfile #
100+
##############
101+
Policyfile.rb
102+
Policyfile.lock.json
103+
104+
# Documentation #
105+
#############
106+
CODE_OF_CONDUCT*
107+
CONTRIBUTING*
108+
documentation/*
109+
TESTING*
110+
UPGRADING*
111+
112+
# Vagrant #
113+
###########
114+
.vagrant
115+
Vagrantfile

compliance/README.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# compliance
2+
3+
This directory contains Chef InSpec profile, waiver and input objects which are used with the Chef Infra Compliance Phase.
4+
5+
Detailed information on the Chef Infra Compliance Phase can be found in the [Chef Documentation](https://docs.chef.io/chef_compliance_phase/).
6+
7+
```plain
8+
./compliance
9+
├── inputs
10+
├── profiles
11+
└── waivers
12+
```
13+
14+
Use the `chef generate` command from Chef Workstation to create content for these directories:
15+
16+
```sh
17+
# Generate a Chef InSpec profile
18+
chef generate profile PROFILE_NAME
19+
20+
# Generate a Chef InSpec waiver file
21+
chef generate waiver WAIVER_NAME
22+
23+
# Generate a Chef InSpec input file
24+
chef generate input INPUT_NAME
25+
```

files/test_default.txt

Whitespace-only changes.

kitchen.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
driver:
3+
name: vagrant
4+
5+
## The forwarded_port port feature lets you connect to ports on the VM guest
6+
## via localhost on the host.
7+
## see also: https://www.vagrantup.com/docs/networking/forwarded_ports
8+
9+
# network:
10+
# - ["forwarded_port", {guest: 80, host: 8080}]
11+
12+
provisioner:
13+
name: chef_zero
14+
15+
## product_name and product_version specifies a specific Chef product and version to install.
16+
## see the Chef documentation for more details: https://docs.chef.io/workstation/config_yml_kitchen/
17+
# product_name: chef
18+
# product_version: 17
19+
20+
verifier:
21+
name: inspec
22+
23+
platforms:
24+
- name: ubuntu-20.04
25+
- name: centos-8
26+
27+
suites:
28+
- name: default
29+
verifier:
30+
inspec_tests:
31+
- test/integration/default

0 commit comments

Comments
 (0)