Deploy with Chef

This guide provides a complete Chef cookbook for installing and enrolling LinuxGuard. Credentials are managed with chef-vault, which encrypts data bag items using each node's public key so only authorised nodes can decrypt them. The recipe is idempotent — safe to run on already-enrolled nodes because the enroll resource includes a not_if guard on /var/lib/linuxguard/config.

Prerequisites

  • Chef Workstation installed on your workstation

  • Chef Infra Server with nodes registered and their public keys uploaded

  • The chef-vault gem available on your workstation (chef gem install chef-vault if not already installed)

  • A LinuxGuard API key and tenant ID (from the LinuxGuard console)

Important: chef-vault requires Chef Infra Server with public/private key pairs per node. It is not compatible with chef-solo or knife-solo. If you are using chef-solo or chef-zero, use the Chef secret() helper (available in Chef Infra Client 17.5+) to integrate with AWS Secrets Manager or Azure Key Vault instead.

Cookbook Structure

Create the following structure in your Chef repository's cookbooks/ directory:

cookbooks/
└── linuxguard/
    ├── metadata.rb          # Cookbook name, version, description
    ├── attributes/
    │   └── default.rb       # Default attribute values
    └── recipes/
        └── default.rb       # Install, enable, enroll

Step 1: Create the chef-vault Item

Store LinuxGuard credentials in a chef-vault item. The vault encrypts the data bag item using the public keys of the nodes you specify — only those nodes can decrypt it during a Chef run.

Run the following command from your workstation:

  • --search — specifies which nodes should have decryption access. Adjust the search query to match the nodes in your environment (for example, role:linuxguard-node or name:*).

  • --admins — specifies Chef Server users who can administer the vault item (read, update, delete).

To verify the vault item was created:

Step 2: Create the Cookbook Files

metadata.rb

attributes/default.rb

recipes/default.rb

Note: The not_if { ::File.exist?('/var/lib/linuxguard/config') } guard skips enrollment if the agent is already enrolled. The sensitive true attribute prevents credentials from appearing in Chef run logs. See Automated Deployment Overview for details on the agent's built-in idempotency behavior.

Step 3: Add the Cookbook to a Run List

Add the cookbook to a node's run list:

Or add recipe[linuxguard] to a role's run list so all nodes in that role receive the cookbook automatically:

Then run the Chef client on the target node to apply the cookbook:

Verifying the Deployment

After the Chef run completes, you can add a verification step to your recipe to confirm the agent is running:

Enrolled nodes also appear in the Infrastructure view of the LinuxGuard console within a few minutes of successful enrollment.


Related: Automated Deployment Overview | Installation | Configuration

Last updated

Was this helpful?