### Starting and Provisioning Chef Automate Vagrant VM (Bash) Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/automate/components/docs-chef-io/content/automate/get_started.md This command instructs Vagrant to start and provision the virtual machine defined by the `Vagrantfile` in the current directory. Vagrant will download the base box if necessary, configure the VM settings, and execute the provision steps, which include running the embedded shell script to install Chef Automate. ```bash vagrant up ``` -------------------------------- ### Example Initial Chef Workstation Config Source: https://github.com/chef/chef-web-docs/blob/main/content/saas/get_started.md This is an example of the initial credentials file content created by `knife configure init` before a new user/organization is set up. It typically points to the 'pivotal' user key and the base Chef SaaS URL provided in the Starter Kit. ```Ruby [default] client_name - 'pivotal' client_key = '/home/admin/.chef/pivotal.pem' chef_server_url - 'https://saas.example.com' ``` -------------------------------- ### Example Updated Chef Workstation Config Source: https://github.com/chef/chef-web-docs/blob/main/content/saas/get_started.md This is an example of the updated credentials file content in `~/.chef` after creating a new user and organization. The `client_name`, `client_key`, and `chef_server_url` are modified to point to the new user's PEM file and the organization-specific URL. ```Ruby [default] client_name - 'CLIENT_NAME' client_key = '/home/admin/.chef/.pem' chef_server_url - 'https://saas-example.com' ``` -------------------------------- ### Initializing Chef Workstation Configuration Source: https://github.com/chef/chef-web-docs/blob/main/content/saas/get_started.md This command initializes the Chef Workstation configuration. It prompts the user for Chef Infra Server details, such as the URL and initial API username/client_name (often 'pivotal' from the Starter Kit), and creates a credentials file in the `~/.chef` directory. ```Shell knife configure init ``` -------------------------------- ### Building a Habitat Package in the Studio Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/habitat-sh/habitat/components/docs-chef-io/content/habitat/get_started.md Inside the Habitat Studio, this command executes the build process defined in the `plan.sh` file for the current project. It compiles the source code (if applicable), installs dependencies, and packages the application into a Habitat artifact (`.hart` file), placing it in the `results` directory. ```Bash build ``` -------------------------------- ### Complete Wrapper Recipe Example (Ruby) Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/supermarket/docs-chef-io/content/supermarket/install_supermarket.md This is an example of a complete Chef wrapper recipe for installing Supermarket. It loads configuration from a data bag, sets necessary node attributes using those values, and then includes the supermarket-omnibus-cookbook recipe to perform the installation. ```ruby app = data_bag_item('apps', 'supermarket') node.override['supermarket_omnibus']['chef_server_url'] = app['chef_server_url'] node.override['supermarket_omnibus']['chef_oauth2_app_id'] = app['chef_oauth2_app_id'] node.override['supermarket_omnibus']['chef_oauth2_secret'] = app['chef_oauth2_secret'] include_recipe 'supermarket-omnibus-cookbook' ``` -------------------------------- ### Listing Chef Clients Source: https://github.com/chef/chef-web-docs/blob/main/content/saas/get_started.md This command lists all registered clients (nodes and workstations) within the currently configured organization on the Chef Infra Server using `knife`. Successfully running this command indicates a successful connection and configuration with the new organization. ```Shell knife client list ``` -------------------------------- ### Downloading Effortless Packages from Public Builder (Example) - Shell Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/automate/components/docs-chef-io/content/automate/on_prem_builder.md Provides a specific example of using `hab pkg download` to get packages listed in the Effortless seed list (`package_seed_lists/effortless_x86_64-linux_stable`) for the `x86_64-linux` architecture from the `stable` channel, saving them to the `builder_bootstrap` directory. Authentication uses the `HAB_AUTH_TOKEN`. ```shell HAB_AUTH_TOKEN= hab pkg download --target x86_64-linux --channel stable --file package_seed_lists/effortless_x86_64-linux_stable --download-directory builder_bootstrap ``` -------------------------------- ### Example Python Installation Commands in Chef Ruby Source: https://github.com/chef/chef-web-docs/blob/main/content/infra_language/checking_platforms.md Provides examples of potential shell commands that could be used within the `execute` resource's `command` block (from the previous snippet) to install Python and pip. ```Ruby #{node['python']['binary']} distribute_setup.py #{::File.dirname(pip_binary)}/easy_install pip ``` -------------------------------- ### Creating a New Chef User Source: https://github.com/chef/chef-web-docs/blob/main/content/saas/get_started.md This command creates a new user account on the Chef Infra Server using `knife`. This user will typically be associated with the new organization. It requires a username, email address, and password, and generates a new PEM key file for this user. ```Shell knife user create --email --password ``` -------------------------------- ### Deploy Chef Automate (shell) Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/automate/components/docs-chef-io/content/automate/install.md This command initiates the deployment of Chef Automate using the settings defined in the `config.toml` file. The process includes pre-flight checks and guides the user through accepting the terms of service. ```shell sudo ./chef-automate deploy config.toml ``` -------------------------------- ### Using Example Domains Source: https://github.com/chef/chef-web-docs/blob/main/content/style/chef_house.md Specifies the use of 4thcafe.com for generic examples and chef.io or progress.com when referring directly to the company, ensuring clear context in documentation examples. ```Text 4thcafe.com ``` ```Text chef.io ``` ```Text progress.com ``` -------------------------------- ### Example Munki Manifest File (XML) Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/desktop-config/docs-chef-io/content/desktop/zero_touch/windows/application_management.md This XML snippet shows a basic Munki manifest file. Manifests define which catalogs a client uses and list packages to be managed under sections like `managed_installs`, `managed_uninstalls`, or `optional_installs`. This example includes `Firefox`, `VSCode`, and several `munkitools` for managed installation. ```xml catalogs my_catalog included_manifests managed_installs munkitools_app munkitools_app_usage munkitools_core munkitools_launchd Firefox VSCode managed_uninstalls managed_updates optional_installs ``` -------------------------------- ### Adding a User to an Organization Source: https://github.com/chef/chef-web-docs/blob/main/content/saas/get_started.md This command adds an existing user account to a specific organization on the Chef Infra Server using `knife`. This links the user to the organization, allowing them to manage resources within that organization based on their permissions. ```Shell knife org user add ``` -------------------------------- ### Successful Service Start Output Example - Bash Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/chef-server/docs-chef-io/content/server/reusable/md/ctl_chef_server_start.md This snippet shows an example of the output you should expect to see in the console when a Chef Infra Server service is successfully started using the `chef-server-ctl start` command. It confirms the service is running and provides basic status information like the process ID (pid) and uptime. ```bash ok: run: service_name: (pid 12345) 1s ``` -------------------------------- ### Loading a Habitat Service in the Studio Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/habitat-sh/habitat/components/docs-chef-io/content/habitat/get_started.md This command instructs the Habitat Supervisor, running within the Studio, to load and start a service based on a Habitat package. It requires the package identifier in the format `ORIGIN_NAME/pkg_name`. The Supervisor ensures the service is running and healthy. ```Bash hab svc load ORIGIN_NAME/sample-node-app ``` -------------------------------- ### Example Chef Recipe Structure - Chef/Ruby Source: https://github.com/chef/chef-web-docs/blob/main/content/ruby.md Provides a comprehensive example of a Chef recipe demonstrating variable definition, resource declarations for setting up MySQL, Apache, PHP, and WordPress, including dependencies and notifications. ```ruby ########### # variables ########### connection_info = { host: '127.0.0.1', port: '3306', username: 'root', password: 'm3y3sqlr00t', } ################# # Mysql resources ################# mysql_service 'default' do port '3306' initial_root_password 'm3y3sqlr00t' action [:create, :start] end mysql_database 'wordpress_demo' do connection connection_info action :create end mysql_database_user 'wordpress_user' do connection connection_info database_name 'wordpress_demo' password 'w0rdpr3ssdem0' privileges [:create, :delete, :select, :update, :insert] action :grant end ################## # Apache resources ################## httpd_service 'default' do listen_ports %w(80) mpm 'prefork' action [:create, :start] end httpd_module 'php' do notifies :restart, 'httpd_service[default]' action :create end ############### # Php resources ############### package 'php-gd' do action :install end package 'php-mysql' do action :install end directory '/etc/php.d' do action :create end template '/etc/php.d/mysql.ini' do source 'mysql.ini.erb' action :create end httpd_config 'php' do source 'php.conf.erb' notifies :restart, 'httpd_service[default]' action :create end ##################### # wordpress resources ##################### directory '/srv/wordpress_demo' do user 'apache' recursive true action :create end tar_extract 'https://wordpress.org/wordpress-4.1.tar.gz' do target_dir '/srv/wordpress_demo' tar_flags ['--strip-components 1'] user 'apache' creates '/srv/wordpress_demo/index.php' action :extract end directory '/srv/wordpress_demo/wp-content' do user 'apache' action :create end httpd_config 'wordpress' do source 'wordpress.conf.erb' variables( servername: 'wordpress', server_aliases: %w(computers.biz www.computers.biz), document_root: '/srv/wordpress_demo' ) notifies :restart, 'httpd_service[default]' action :create end template '/srv/wordpress_demo/wp-config.php' do source 'wp-config.php.erb' owner 'apache' variables( db_name: 'wordpress_demo', db_user: 'wordpress_user', db_password: 'w0rdpr3ssdem0', db_host: '127.0.0.1', db_prefix: 'wp_', db_charset: 'utf8', auth_key: 'You should probably use randomly', secure_auth_key: 'generated strings. These can be hard', logged_in_key: 'coded, pulled from encrypted databags,', nonce_key: 'or a ruby function that accessed an', auth_salt: 'arbitrary data source, such as a password', secure_auth_salt: 'vault. Node attributes could work', logged_in_salt: 'as well, but you take special care', nonce_salt: 'so they\'re not saved to your chef-server.', allow_multisite: 'false' ) action :create end ``` -------------------------------- ### Example Chef Habitat Supervisor Run Command - Shell Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/automate/components/docs-chef-io/content/automate/applications_setup.md Illustrates a concrete example of the 'hab sup run' command configured with specific values for application, environment, site, Automate hostname, and API token. This command starts a Habitat supervisor and directs its event stream to the specified Chef Automate instance. ```Shell hab sup run \ --event-stream-application="AmazingEnterpriseApp" \ --event-stream-environment="acceptance" \ --event-stream-site="us-west-2" \ --event-stream-url="automate.company.com:4222" \ --event-stream-token="1234567890abcdefgh" \ ``` -------------------------------- ### Verifying Chef Workstation Installation (Bash) Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/desktop-config/docs-chef-io/content/desktop/install.md Executes the `chef --version` command to confirm that Chef Workstation was successfully installed and displays the versions of the bundled tools. This command is run from the command line after the installer completes. ```bash chef --version ``` -------------------------------- ### Generating Chef Infra Repository (Bash) Source: https://github.com/chef/chef-web-docs/blob/main/content/quick_start.md This Bash command uses the `chef` command-line tool provided by Chef Workstation to generate a new Chef Infra repository with a standard directory structure and an example cookbook. The command requires Chef Workstation to be installed and accessible in the system's PATH. ```bash chef generate repo my_first_repo ``` -------------------------------- ### Example Role Usage in Chef Documentation Source: https://github.com/chef/chef-web-docs/blob/main/content/style/chef_house.md Illustrates how the example role name 'webserver' is used in different contexts within Chef documentation, including configuration definitions, resource references, and search queries. ```YAML name: webserver ``` ```Chef DSL role[webserver] ``` ```Chef Search role:webserver ``` -------------------------------- ### Manage Habitat Supervisor Systemd Service (sh) Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/license-service/docs-chef-io/content/licensing/local_license_service/install.md Reloads the systemd daemon, starts the newly defined Habitat Supervisor service, and enables it to start on boot. It then waits for the supervisor to become healthy before proceeding. ```sh systemctl daemon-reload systemctl start hab-sup systemctl enable hab-sup # wait for the sup to come up before proceeding. until hab svc status > /dev/null 2>&1; do sleep 1 done ``` -------------------------------- ### Installing Habitat via Curl (Shell) Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/automate/components/docs-chef-io/content/automate/ha_chef_backend_to_automate_ha.md Downloads and executes the Habitat installer script directly from the habitat-sh GitHub repository using curl. This is the first step to get the 'hab' command-line tool, which is required to install and run Habitat packages like knife-ec-backup. ```sh curl https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh \ | sudo bash ``` -------------------------------- ### Clone Repository using Git (Powershell) Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/desktop-config/docs-chef-io/content/desktop/demonstration_setup.md This command clones the 'chef-desktop-quick-setup' repository from GitHub to your local machine. This repository contains the Terraform modules needed to set up the demonstration environment on AWS. Ensure Git is installed on your system before running this command. ```powershell git clone https://github.com/chef/chef-desktop-quick-setup ``` -------------------------------- ### Pruning Chef Automate Backups - Shell Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/automate/components/docs-chef-io/content/automate/ha_disaster_recovery_setup_AWS.md Provides a command pipeline example to clean up old backups in the configured object storage (S3), keeping only a specified number of the most recent ones (controlled by the `KEEP` variable). It uses `chef-automate backup list` with `jq` to parse the backup IDs and `xargs` to pass them to `chef-automate backup delete`. This requires `jq` and `hab` (Habitat) to be installed. ```Shell export KEEP=10; export HAB_LICENSE=accept-no-persist; chef-automate backup list --result-json backup.json > /dev/null && hab pkg exec core/jq-static jq "[.result.backups[].id] | sort | reverse | .[]" -rM backup.json | tail -n +$(($KEEP+1)) | xargs -L1 -i chef-automate backup delete --yes {} ``` -------------------------------- ### Example Chef Client Config Ruby Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/chef-workstation/docs-chef-io/content/workstation/getting_started.md This snippet shows an example of a `config.rb` file, typically found in the `.chef` directory of a Chef Starter Kit or generated by `knife configure`. It defines configuration options like log level, log location, node name, client key path, server URL, and cookbook path for `knife` and Chef Infra Client. ```ruby current_dir = File.dirname(__FILE__) log_level :info log_location STDOUT node_name "hshefu" client_key "#{current_dir}/hshefu.pem" chef_server_url "https://api.chef.io/organizations/4thcafe-web-team" cookbook_path ["#{current_dir}/../cookbooks"] ``` -------------------------------- ### Starting Chef Automate Service - Shell Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/automate/components/docs-chef-io/content/automate/ha_disaster_recovery_setup_AWS.md Starts the Chef Automate system service using `systemctl`. This command is executed on the disaster recovery cluster nodes as part of the failover procedure, making the DR cluster the active cluster ready to receive traffic. ```Shell systemctl start chef-automate ``` -------------------------------- ### Example: Test if Specific Hotfix is Not Installed (InSpec) Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/inspec/inspec/docs-chef-io/content/inspec/resources/windows_hotfix.md Illustrates how to use the `windows_hotfix` resource to verify that a specific hotfix, 'KB9999999' in this example, is *not* installed on the Windows system. It achieves this by using the `should_not` negator before the `be_installed` matcher. Requires InSpec installed on a Windows system. ```InSpec describe windows_hotfix('KB9999999') do it { should_not be_installed } end ``` -------------------------------- ### Loading Habitat Service Studio Bash Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/habitat-sh/habitat/components/docs-chef-io/content/habitat/get_started.md Enters the Habitat Studio environment (`hab studio enter`), which is necessary to run `hab` commands that interact with packages and services. It then loads the `sample-node-app` service from a specified origin (`ORIGIN_NAME`), configuring it to update immediately (`at-once`) when a new version is available. ```bash hab studio enter hab svc load ORIGIN_NAME/sample-node-app --strategy at-once ``` -------------------------------- ### Starting Habitat Supervisor with Authentication Token (bash) Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/habitat-sh/habitat/components/docs-chef-io/content/habitat/monitor_services.md Shows how to start the Habitat Supervisor with HTTP authentication enabled by setting the `HAB_SUP_GATEWAY_AUTH_TOKEN` environment variable before running `hab sup run`. This requires subsequent API requests to include the specified token. Requires the `hab` binary installed and configured. ```bash $ HAB_SUP_GATEWAY_AUTH_TOKEN="sekret" hab sup run hab-sup(MR): Supervisor Member-ID e89b6616d2c040c8a82f475b00ba8c69 hab-sup(MR): Starting gossip-listener on 0.0.0.0:9638 hab-sup(MR): Starting ctl-gateway on 0.0.0.0:9632 hab-sup(MR): Starting http-gateway on 0.0.0.0:9631 ``` -------------------------------- ### Example .chef/credentials File (TOML) Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/chef-workstation/docs-chef-io/content/workstation/knife_setup.md This example shows the structure of the `.chef/credentials` file using TOML format to define multiple Knife profiles. It includes profiles for connecting to different Chef Infra Servers or organizations, demonstrates how to include client keys inline, and shows a profile configured for target mode (e.g., connecting to a switch). ```TOML # Example .chef/credentials file [default] client_name = "barney" client_key = "barney_rubble.pem" chef_server_url = "https://api.chef.io/organizations/bedrock" # a 'config context' such as knife can be is configured as a separate table [default.knife] ssh_user = 'ubuntu' # this would have been knife[:ssh_user] in your config.rb aws_profile = 'engineering' use_sudo = true # a client_key may also be specified inline as in this example [dev] client_name = "admin" client_key = """ -----BEGIN RSA PRIVATE KEY----- MIICXAIBAKBgQCqGKukO1De7zhZj6EXAMPLEKEY ...ABC123= -----END RSA PRIVATE KEY----- """ validator_key = "test-validator.pem" chef_server_url = "https://api.chef-server.dev/organizations/test" ['web.preprod'] client_name = "brubble" client_key = "preprod-brubble.pem" chef_server_url = "https://preprod.chef-server.dev/organizations/preprod" ['switch.example.org'] user = "cisco" password = "cisco" enable_password = "cisco" ``` -------------------------------- ### Load Local License Service Habitat Package (sh) Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/license-service/docs-chef-io/content/licensing/local_license_service/install.md Instructs the Habitat Supervisor to load and start the `local-license-service` package from the `chef-private` origin. The supervisor manages the service lifecycle. ```sh sudo hab svc load chef-private/local-license-service ``` -------------------------------- ### Example: Test if Specific Hotfix is Installed (InSpec) Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/inspec/inspec/docs-chef-io/content/inspec/resources/windows_hotfix.md Provides a concrete example of using the `windows_hotfix` resource to test whether a specific hotfix, identified by 'KB4012213', is installed on the target Windows system. It uses the `be_installed` matcher for the assertion. Requires InSpec installed on a Windows system. ```InSpec describe windows_hotfix('KB4012213') do it { should be_installed } end ``` -------------------------------- ### Entering the Chef Habitat Studio Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/habitat-sh/habitat/components/docs-chef-io/content/habitat/get_started.md These commands launch the Chef Habitat Studio, a minimal environment used for developing, building, and testing Habitat packages. The Linux version requires the `-D` flag for Docker-based studios, while macOS typically uses a local studio. This is where package build and service testing occurs. ```Bash hab studio enter ``` ```Bash hab studio enter -D ``` -------------------------------- ### Fetching Munki Tools with AutoPkg | AutoPkg | Bash Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/desktop-config/docs-chef-io/content/desktop/zero_touch/macOS/application_management.md Adds the standard 'recipes' repository to AutoPkg and then runs a specific recipe (`Munkitools4.Munki`) to fetch the necessary Munki client tools. The tools are then imported into the local Munki repository, making them available for deployment to client nodes. ```bash autopkg repo-add recipes ``` ```bash autopkg run -k MUNKI_REPO=/Users/Shared/Munki_repo Munkitools4.Munki ``` -------------------------------- ### Starting the Chef Habitat Supervisor Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/habitat-sh/habitat/components/docs-chef-io/content/habitat/builder_origin_packages.md This command initializes and starts the Chef Habitat Supervisor on the host machine. The supervisor manages running services and can fetch packages from Chef Habitat Builder if not found locally. ```bash $ hab sup run ``` -------------------------------- ### Verifying Chef SSL Configuration Source: https://github.com/chef/chef-web-docs/blob/main/content/saas/get_started.md This command checks the SSL certificate of the Chef Infra Server for the configured organization using `knife`. It helps identify potential certificate issues that could prevent successful communication between Chef Workstation and the server. ```Shell knife ssl check ``` -------------------------------- ### Example Configuration File (Ruby) Source: https://github.com/chef/chef-web-docs/blob/main/content/config_rb_manage.md An example of the `manage.rb` configuration file showing several common settings configured. It demonstrates the syntax for various types of values (strings, booleans, numbers, hashes) and includes comments explaining the Redis URL derivation and webapp listen setting. ```Ruby chef_documentation_url '' disable_sign_up false events.port 11001 logging.chef_log_level 'info' logging.log_level 'info' nginx_addon_prefix 30 platform.user 'pivotal' public_port 443 redis.host 'localhost' redis.port 11002 # redis.url derived from redis.host and redis.port runit_timeout 30 services['opscode-manage-events'].enable true services['opscode-manage-webapp'].enable true services['opscode-manage-worker'].enable true support_email_address 'support@chef.io' support_site_url 'http://chef.io/support' support_tickets_url 'https://chef.io/support/tickets' webapp.backlog 1024 # webapp.listen derived from webapp.port webapp.port 9462 webapp.tcp_nodelay true webapp.worker_processes 2 webapp.worker_timeout 3600 ``` -------------------------------- ### Bash pkg_deps Example Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/habitat-sh/habitat/components/docs-chef-io/content/habitat/plan_helpers.md An example from a `plan.sh` file showing the `pkg_deps` array, which lists the build-time and run-time dependencies for a Chef Habitat package. This context is relevant for the `pkgPathFor` helper. ```Bash pkg_deps=("core/jre8") ``` -------------------------------- ### GET All Recipe Names JSON Response (JSON) Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/chef-server/docs-chef-io/content/server/api_chef_server.md Example JSON response structure for the GET /organizations/NAME/cookbooks/_recipes endpoint. It is expected to return a hash containing the names of all recipes found in the latest cookbook versions. The example provided is an empty hash, suggesting it might return an empty object if no recipes are found or as a minimal example. ```json { } ``` -------------------------------- ### Downloading and Preparing Chef Automate Installer - Shell Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/automate/components/docs-chef-io/content/automate/on_prem_builder.md This command downloads the latest Chef Automate CLI zip file for Linux AMD64, unzips it, extracts the `chef-automate` binary, and makes it executable. It is the first step in obtaining the necessary tool for installation and deployment. ```shell curl https://packages.chef.io/files/current/latest/chef-automate-cli/chef-automate_linux_amd64.zip | gunzip - > chef-automate && chmod +x chef-automate ``` -------------------------------- ### Implementing Example Chef Site Resource (Ruby) Source: https://github.com/chef/chef-web-docs/blob/main/content/custom_resources.md Provides a complete example of a functional Chef custom resource named `site`. It defines a `homepage` property with a default value and includes `:create` and `:delete` actions. The actions utilize built-in `package`, `service`, and `file` resources to manage an HTTP web site, demonstrating how to integrate existing resources. ```ruby provides :site property :homepage, String, default: '

Hello world!

' action :create do package 'httpd' service 'httpd' do action [:enable, :start] end file '/var/www/html/index.html' do content new_resource.homepage end end action :delete do package 'httpd' do action :remove end file '/var/www/html/index.html' do action :delete end end ``` -------------------------------- ### Reconfiguring Chef Infra Server (Post-Install) - Bash Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/chef-server/docs-chef-io/content/server/install_server.md Runs the `chef-server-ctl reconfigure` command as a superuser to initialize and start all components of the Chef Infra Server after the package installation is complete. This command ensures that all services are properly configured and running, which may take several minutes. ```bash sudo chef-server-ctl reconfigure ``` -------------------------------- ### Example: Checking VLC Installation using oneget (InSpec) Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/inspec/inspec/docs-chef-io/content/inspec/resources/oneget.md This is a practical example demonstrating how to use the `oneget` InSpec resource to check if the 'VLC' package is installed on a Windows system via Oneget. It uses the standard `describe` block and the `be_installed` matcher. ```InSpec describe oneget('VLC') do it { should be_installed } end ``` -------------------------------- ### Configuring OpenSearch S3 Backup in Chef Automate - TOML Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/automate/components/docs-chef-io/content/automate/install.md Sets up Chef Automate to use an externally deployed OpenSearch cluster with AWS S3 backups. Requires installing the `repository-s3` plugin on OpenSearch nodes and configuring S3 client settings there. Specifies the S3 bucket name, optional base path, and the OpenSearch S3 client name to use. Includes commented-out example settings for the S3 repository and snapshots. ```toml [global.v1.external.opensearch.backup] enable = true location = "s3" [global.v1.external.opensearch.backup.s3] # bucket (required): The name of the bucket bucket = "" # base_path (optional): The path within the bucket where backups should be stored # If base_path is not set, backups will be stored at the root of the bucket. base_path = "" # name of an s3 client configuration you create in your opensearch.yml # for full documentation on how to configure client settings on your # OpenSearch nodes client = "" [global.v1.external.opensearch.backup.s3.settings] ## The meaning of these settings is documented in the S3 Repository Plugin ## documentation. ## Backup repo settings # compress = false # server_side_encryption = false # buffer_size = "100mb" # canned_acl = "private" # storage_class = "standard" ## Snapshot settings # max_snapshot_bytes_per_sec = "40mb" # max_restore_bytes_per_sec = "40mb" # chunk_size = "null" ## S3 client settings # read_timeout = "50s" # max_retries = 3 # use_throttle_retries = true # protocol = "https" ``` -------------------------------- ### Create Admin Client with Key File (Example) Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/chef-workstation/docs-chef-io/content/workstation/knife_client.md An example demonstrating how to create a Chef Infra Client configured as an administrator (`-a`) with the name "exampleorg". The `-f` option is used to save the generated private key to the specified file path. ```bash knife client create exampleorg -a -f "/etc/chef/client.pem" ``` -------------------------------- ### Example Short Path on macOS/Linux - Filesystem Source: https://github.com/chef/chef-web-docs/blob/main/content/reusable/md/windows_top_level_directory_names.md Illustrates the use of a short top-level directory like /opt/ for installing software, similar to how Chef Workstation is installed on macOS. This practice helps avoid potential path length issues common in other operating systems. ```filesystem /opt/ ``` -------------------------------- ### Creating a Chef Organization Source: https://github.com/chef/chef-web-docs/blob/main/content/saas/get_started.md This command creates a new organization on the Chef Infra Server using `knife`. Organizations are used for role-based access control. It requires both a short organization name and a full name. The command outputs the private key for the organization's validator client. ```Shell knife org create "" ``` -------------------------------- ### Example Output of list-profiles Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/chef-workstation/docs-chef-io/content/workstation/knife_setup.md This snippet shows the expected output format when running the `knife config list-profiles` command. It lists the profile name, client name, key path, and server URL for each profile, indicating the currently selected profile with an asterisk. ```Output ## Profile Client Key Server default barney ~/.chef/barney_rubble.pem https://api.chef.io/organizations/bedrock dev admin ~/.chef/admin.pem https://api.chef-server.dev/organizations/test web.preprod brubble ~/.chef/preprod-brubble.pem https://preprod.chef-server.dev/organizations/preprod switch.example.org btm ~/.chef/btm.pem https://localhost:443 ``` -------------------------------- ### Define Container Startup and Upload Script (bash) Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/license-service/docs-chef-io/content/licensing/local_license_service/install.md Bash script executed as the Docker container's entrypoint. It starts the `license-service` in the background, repeatedly checks its health, and uploads all license files found in a specified folder to the service's upload endpoint. ```bash #!/bin/bash if [ $# -eq 0 ]; then echo "No arguments supplied" echo "Usage: licenseFolderPath http://localhost:8000" exit 1 fi declare -r folderPath="$1" declare -r serviceUrl="$2" IFS=$'\n' nohup /bin/license-service localService --config /tmp/local-license/config.yaml > /tmp/local-license/license-service.log & serviceHealth () { healthCheckRes=$(curl --write-out %{http_code} --silent --output /dev/null $serviceUrl/health-check) return $healthCheckRes }; checkAndUpload () { listOfFiles=(`ls $folderPath`) for file in "${listOfFiles[@]}"; do filePath="$folderPath$file" if [[ -f $filePath ]]; then echo $file serviceHealth if [[ $? -eq 200 ]]; then loadReqURL="$serviceUrl/v1/uploadLicense" echo $loadReqURL echo $filePath curl -XPOST $loadReqURL --header 'Content-Type: application/json' -d @$filePath fi fi done }; count=1 while [ true ]; do serviceHealth if [[ $? == 200 ]]; then echo "Service is up" if [[ $count == 1 ]]; then checkAndUpload count=$((count+1)) fi else echo "Local license service is not up!" if [[ $count > 5 ]]; then exit 1 fi count=$((count+1)) fi sleep 10 done ``` -------------------------------- ### Example FQDN Configuration TOML Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/automate/components/docs-chef-io/content/automate/airgapped_installation.md Snippet from the 'config.toml' file illustrating where to configure the Fully Qualified Domain Name (FQDN) for the Chef Automate instance. This is the URL used to access the application via a browser. ```toml # This is a default Chef Automate configuration file. You can run # 'chef-automate deploy' with this config file and it should # successfully create a new Chef Automate instance with default settings. [global.v1] # The external fully qualified domain name. # When the application is deployed you should be able to access 'https:///' # to login. fqdn = "<_Public DNS_name_>" ``` -------------------------------- ### Installing Nginx on CentOS/RHEL for 4-LB Setup Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/automate/components/docs-chef-io/content/automate/loadbalancer_configuration.md Installs the Nginx web server package on CentOS or Red Hat systems, repeated for the 4 Load Balancer setup scenario. It first adds the EPEL repository, then updates, and finally installs Nginx using the yum package manager. Requires root privileges and internet access. ```bash sudo yum install epel-release sudo yum update sudo yum install nginx ``` -------------------------------- ### Example Simple Test Kitchen kitchen.yml YAML Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/chef-workstation/docs-chef-io/content/workstation/reusable/md/test_kitchen_yml_syntax.md Provides a concrete example of a simple kitchen.yml configuration. It demonstrates setting a Vagrant driver, chef-zero provisioner, defining specific platforms, and configuring a default test suite with a specific run list and platform exclusions. ```yaml driver: name: vagrant provisioner: name: chef_zero platforms: - name: ubuntu-20.04 - name: centos-8 - name: debian-10 suites: - name: default run_list: - recipe[apache::httpd] excludes: - debian-10 ``` -------------------------------- ### Configuring OpenSearch GCS Backup in Chef Automate - TOML Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/automate/components/docs-chef-io/content/automate/install.md Configures Chef Automate to use an externally deployed OpenSearch cluster with Google Cloud Storage (GCS) backups. Requires installing the `repository-gcs` plugin on OpenSearch nodes and setting up a GCS bucket and service account. Specifies the GCS bucket name and the OpenSearch GCS client name. Includes commented-out examples for OpenSearch node configuration, including basic authentication. ```toml [global.v1.external.opensearch] enable = true nodes = ["https://my-es.cluster"] ## If multiple # nodes = ["https://my-es.node-1", "https://my-es.node-2", "etc..."] ## The following settings are required if you have OpenSearch setup with basic auth #[global.v1.external.opensearch.auth] # scheme = "basic_auth" # #[global.v1.external.opensearch.auth.basic_auth] # username = "everyuser" # password = "pass123" [global.v1.external.opensearch.backup] enable = true location = "gcs" [global.v1.external.opensearch.backup.gcs] bucket = "" # Client name is normally default, but can be set here if you have generated service # account credentials with a different client name client = "default" ## GCS Bucket Settings: # type = nearline # access control = uniform ``` -------------------------------- ### Adding Autopkg Recipes and Running Munki Tools Recipe (Bash) Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/desktop-config/docs-chef-io/content/desktop/zero_touch/windows/application_management.md These bash commands use `autopkg` to add the default recipes repository and then run a specific recipe (`munkitools4.munki`) to pull the necessary Munki client tools into the repository for deployment to client macOS nodes. ```bash autopkg repo-add recipes autopkg run -k MUNKI_REPO=/Users/Shared/munki_repo munkitools4.munki ``` -------------------------------- ### Bulk Uploading Packages to On-prem Builder (Example) - Shell Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/automate/components/docs-chef-io/content/automate/on_prem_builder.md Provides a specific example of using `hab pkg bulkupload` to upload packages from the `builder_bootstrap/` directory to the `stable` channel on the on-premises Builder instance, identified by its API URL. The `--auto-create-origins` flag is used, and the command is authenticated via `HAB_AUTH_TOKEN`. ```shell HAB_AUTH_TOKEN= hab pkg bulkupload --url https://{{< example_fqdn "automate" >}}/bldr/v1 --channel stable builder_bootstrap/ --auto-create-origins ``` -------------------------------- ### Installing Nginx on Debian/Ubuntu for 4-LB Setup Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/automate/components/docs-chef-io/content/automate/loadbalancer_configuration.md Installs the Nginx web server package using the apt-get package manager on Debian or Ubuntu systems, repeated for the 4 Load Balancer setup scenario. Requires root privileges and internet access. ```bash sudo apt-get update sudo apt-get install nginx ``` -------------------------------- ### Example testing multiple basic Postfix settings with InSpec Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/inspec/inspec/docs-chef-io/content/inspec/resources/postfix_conf.md Provides a concrete example of how to use the `postfix_conf` resource to test multiple common settings (`myorigin`, `myhostname`, `mynetworks`) in the default main.cf file against their expected values using chained `its` matchers. ```ruby describe postfix_conf do its('myorigin') { should cmp '$myhostname' } its('myhostname') { should cmp 'host.local.domain' } its('mynetworks') { should cmp '127.0.0.0/8' } end ``` -------------------------------- ### GET Search Cookbooks Success Response - Chef Supermarket API - Javascript Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/supermarket/docs-chef-io/content/supermarket/supermarket_api.md This snippet provides an example of the JSON response returned by the Supermarket API for a successful search query. It includes the total number of results, the starting point of the current batch (if specified), and a list of cookbook items with their name, description, URL, and maintainer. ```javascript { "total": 2, "start": 0, "items": [ { "cookbook_name": "apache", "cookbook_description": "installs a web server.", "cookbook": "http://supermarket.chef.io/api/v1/cookbooks/apache", "cookbook_maintainer": "jtimberman" }, { "cookbook_name": "webserver", "cookbook_description": "installs apache.", "cookbook": "http://supermarket.chef.io/api/v1/cookbooks/webserver", "cookbook_maintainer": "raxmus" } ] } ``` -------------------------------- ### Example Munki Catalog Entry (XML) Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/desktop-config/docs-chef-io/content/desktop/zero_touch/windows/application_management.md This XML snippet shows a portion of a Munki catalog file. It contains metadata for a specific package (VSCode), including its name, display name, size, hash, location, versions, and installation options like `unattended_install` and `uninstallable`. Catalogs are automatically generated or updated by tools like `munkiimport` and `makecatalogs`. ```xml autoremove catalogs mycatalog display_name VSCode installed_size 1285143 installer_item_hash b9a5b90ff2b0bb733a9b719fe2afea5d5dc02875dc96b969a9fcf8b9de9214a6 installer_item_location VSCode.pkg installer_item_size 513821 minimum_os_version 10.5.0 name VSCode receipts installed_size 1285143 packageid com.microsoft.visual-studio version 8.5.2 unattended_install uninstall_method removepackages uninstallable version 1.45.1 ``` -------------------------------- ### Updating Munki Catalogs (Bash) Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/desktop-config/docs-chef-io/content/desktop/zero_touch/windows/application_management.md This bash command runs the `makecatalogs` tool. This tool processes the package information (`.pkgsinfo` files) in the Munki repository to update the catalog files, which list available software and their metadata. ```bash makecatalogs ``` -------------------------------- ### Testing Telnetd Not Installed with InSpec (Package) Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/inspec/inspec/docs-chef-io/content/inspec/resources/package.md A concrete example demonstrating how to check that the 'telnetd' package is not installed on the system using the `should_not be_installed` matcher. ```inspec describe package('telnetd') do it { should_not be_installed } end ``` -------------------------------- ### Installing Chef Manage from Specific Path (Bash) Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/chef-server/docs-chef-io/content/server/reusable/md/ctl_chef_server_install_features_manual.md This snippet provides a concrete example of installing the `chef-manage` add-on. It uses the `chef-server-ctl install` command with `chef-manage` as the package name and `/root/packages` as the path to search for the package file. The command requires `sudo` privileges. ```bash sudo chef-server-ctl install chef-manage --path /root/packages ``` -------------------------------- ### Using Example Email Addresses Source: https://github.com/chef/chef-web-docs/blob/main/content/style/chef_house.md Lists standard fictional email addresses based on the recommended example names and the Chef Technical Documentation team's contact, used to protect personal information in examples. ```Text akoch@4thcafe.com ``` ```Text tbucatar@4thcafe.com ``` ```Text dgotvach@4thcafe.com ``` ```Text lchushi@4thcafe.com ``` ```Text hshefu@4thcafe.com ``` ```Text byolisa@4thcafe.com ``` ```Text kbaavarchee@4thcafe.com ``` ```Text stagaluto@4thcafe.com ``` ```Text chef-docs@progress.com ``` -------------------------------- ### TOML Table Example for Configuration Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/habitat-sh/habitat/components/docs-chef-io/content/habitat/plan_helpers.md Provides an example of defining configuration variables using TOML tables (sections) in `default.toml` or a user-provided configuration file. Tables help organize related configuration settings. ```TOML [repl] backlog-size = 200 backlog-ttl = 100 disable-tcp-nodelay = no ``` -------------------------------- ### Checking NGINX Installation and Version with InSpec Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/inspec/inspec/docs-chef-io/content/inspec/resources/package.md Provides a complete example of using the `package` resource to verify both the installation status and the exact version ('1.9.5') of the 'nginx' package. ```inspec describe package('nginx') do it { should be_installed } its('version') { should eq '1.9.5' } end ``` -------------------------------- ### Starting Hugo Server with Local Theme Workspace - Shell Source: https://github.com/chef/chef-web-docs/blob/main/README.md Runs a make command that sets up the Hugo workspace configuration to use the local theme directory and then starts the Hugo development server to preview changes. ```Shell make test_theme ``` -------------------------------- ### Using Fictional Company Examples Source: https://github.com/chef/chef-web-docs/blob/main/content/style/chef_house.md Provides examples of how the fictional company "Fourth Cafe, Inc." is represented in documentation, including email addresses and file names. These examples ensure consistency across documentation. ```Text admin@4thcafe.com ``` ```Text 4thcafe.pem ``` -------------------------------- ### Updating Packages and Installing PostgreSQL Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/chef-server/docs-chef-io/content/server/upgrades.md These commands update the package lists and install a specific version of PostgreSQL on the external database machine using apt-get. The example shows installing PostgreSQL version 13, but the version should be adjusted based on requirements. ```bash sudo apt-get update sudo apt-get install postgresql-13 ``` -------------------------------- ### Creating Test Kitchen Instances (PowerShell) Source: https://github.com/chef/chef-web-docs/blob/main/_vendor/github.com/chef/desktop-config/docs-chef-io/content/desktop/cookbook_repository.md Initializes the virtual machines or containers defined in the `.kitchen.yml` file using the `kitchen create` command. This command prepares the testing environment before running Chef code. Requires Test Kitchen and a configured driver (e.g., Hyper-V, VirtualBox, Docker). Output is running test instances. ```powershell kitchen create ```