|
| 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 | + |
0 commit comments