diff --git a/_vendor/github.com/chef/license-service/docs-chef-io/content/licensing/local_license_service/install.md b/_vendor/github.com/chef/license-service/docs-chef-io/content/licensing/local_license_service/install.md index b81697b17f..9fe75c4fb1 100644 --- a/_vendor/github.com/chef/license-service/docs-chef-io/content/licensing/local_license_service/install.md +++ b/_vendor/github.com/chef/license-service/docs-chef-io/content/licensing/local_license_service/install.md @@ -19,27 +19,31 @@ Before installing the Chef Local License Service: - Download the `local-license-service` Habitat package on an internet-connected workstation. Contact [Chef Support](https://community.progress.com/s/products/chef) to get access. -Chef Local License Service requires: +- If you're deploying Chef Local License Service in an **airgapped environment** or in a **container**, download the license data from Chef's licensing server using an internet-connected workstation: -- A machine running Linux with kernel 2.6.32 or later on an x86-64 processor -- On your machine, open port 8000 for inbound traffic. + ```sh + curl --location 'https://services.chef.io/licensing/download?licenseId=&version=2' -o + ``` -### Airgapped environment + Replace: -If you're deploying Local License Service in an **airgapped environment**, download the license data from the Chef licensing server on an internet-connected workstation. + - `` with your license ID. You can get this from [Chef Support](https://community.progress.com/s/products/chef). + - `` with a JSON filename to save the data locally. -```sh -curl --location 'https://services.chef.io/licensing/download?licenseId=&version=2' -o .json -``` +## System requirements -Replace: +Chef Local License Service requires: + +- A machine running Linux with kernel 2.6.32 or later on an x86-64 processor +- On your machine, open port 8000 for inbound traffic. -- `` with your license ID. You can get this from [Chef Support](https://community.progress.com/s/products/chef). -- `` with a filename to save the data locally. +## Deploy Chef Local License Service -## Deploy the service +You can deploy Chef Local License Service on the server filesystem or in a Docker container. -This procedure will start up the Chef Local License Service from a Chef Habitat package on a server in an airgapped environment. +### Run on the server filesystem + +To install and run Chef Local License Service from a Chef Habitat package on a server, follow these steps: 1. Unzip and untar the `chef-private-local-license-service` package. @@ -70,17 +74,17 @@ This procedure will start up the Chef Local License Service from a Chef Habitat EOT systemctl daemon-reload systemctl start hab-sup - systemctl enable 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 + sleep 1 done ``` 1. Grant permissions to the script. ```sh - chmod u+x FILENAME.sh + chmod u+x ``` 1. Symlink the hab location. @@ -92,7 +96,7 @@ This procedure will start up the Chef Local License Service from a Chef Habitat 1. Execute the shell script. ```sh - sudo ./FILENAME.sh + sudo ./ ``` 1. Verify that the Chef Habitat Supervisor is running. @@ -110,7 +114,7 @@ This procedure will start up the Chef Local License Service from a Chef Habitat sudo useradd -g hab hab ``` -1. Load Local License Service package. +1. Load the Local License Service package. ```sh sudo hab svc load chef-private/local-license-service @@ -129,6 +133,153 @@ This procedure will start up the Chef Local License Service from a Chef Habitat chef-private/local-license-service/0.1.0/20230622141749 standalone up up 58 3047 local-license-service.default ``` +### Run from a Docker container + +This procedure will guide you on how to create a Dockerfile and start the Chef Local license service in a container. + +{{< note >}} + +You can run Chef Local License Service from a container in an airgapped environment, but the Docker image must be built in an internet-connected environment. + +{{< /note >}} + +#### Create a Dockerfile, shell script, and config file + +1. Create a YAML file with the name `config.yaml` and paste the following content: + + ```yaml + listen: "0.0.0.0:" + air_gap: + db_path: "/data/chef/local-license-service/db" + file_path: "/data/chef/local-license-service/file" + logger: "debug" + external_url: "https://services.chef.io/License/" + ``` + + Replace: + + - `` with the port that you want to use for the service. For example, `8000`. + - `` with `true` if you're deploying in an airgapped environment and `false` if in an internet-connected environment. + +1. Create a Dockerfile that runs Chef Local License Service: + + ```docker + FROM alpine:latest + + ENV LOCAL_LICENSE_URL="" + ENV HAB_LICENSE="accept-no-persist" + + WORKDIR /tmp/local-license + RUN apk --no-cache add curl + + RUN curl $LOCAL_LICENSE_URL -o "local-license-service.tar.gz" + RUN tar -xvf local-license-service.tar.gz + RUN mv hab / + + COPY ./ + COPY /. /data/chef/local-license-service/GLS/. + COPY startLicenseService.sh ./startLicenseService.sh + + RUN chmod ugo+x startLicenseService.sh + RUN TMP=$(/hab/bin/hab pkg path chef-private/local-license-service) && ln -s "${TMP}/bin/license-service" /bin/license-service + + EXPOSE + + RUN apk --no-cache add bash + + ENTRYPOINT /bin/bash ./startLicenseService.sh /data/chef/local-license-service/GLS/ http://localhost: + ``` + + Replace: + + - `` with your Chef Local License service download URL. + - `` with the absolute path of the `config.yaml` file created in the previous step. + - `` with the absolute path of the folder where your license files are kept. + - `` with the port configured in the `config.yaml` file created in the previous step. For example: `8000`. + +1. Create a shell file and paste the following content: + + ```sh + #!/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 + ``` + + Replace `` with the name of the shell file. + +#### Build the image and run the container + +1. Build the image from the DockerFile: + + ```sh + docker build -t "local-license-service" . + ``` + +1. Run the Chef Local license service container: + + ```sh + docker run --name="" -p : --volume=:/data/chef/local-license-service/db -d local-license-service:latest + ``` + + Replace: + + - `` with the container name for local license service. + - `` with the port that you want to use for accessing the service. + - `` with the service port that you configured in the `config.yaml` file. + - `` with the path of the directory on the host where you want to persist the data. + ## Load license data You can load license data depending on whether your service is running in an airgapped environment or a non-airgapped environment. @@ -138,33 +289,40 @@ You can load license data depending on whether your service is running in an air In an **airgapped environment**, use the `v1/uploadLicense` endpoint to load your licensing data. ```sh -curl --location --request POST 'http://:8000/v1/uploadLicense' --header 'Content-Type: application/json' -d @.json +curl --location --request POST 'http://:/v1/uploadLicense' --header 'Content-Type: application/json' -d @.json ``` Replace: -- `` with your Local Licensing Service IP address -- `` with the path and filename of your license data +- `` with your Local Licensing Service IP address. +- `` with your Local Licensing Service port. Default value is `8000`. +- `` with the path and filename of your license data. ### Non-airgapped environment In a **non-airgapped environment**, use the `v1/loadLicense` endpoint to load your licensing data directly from the Chef's licensing server. ```sh -curl --location 'http://:8000>/v1/loadLicense' --header 'Content-Type: application/json' --data '{"LicenseId": ""}' +curl --location 'http://:/v1/loadLicense' --header 'Content-Type: application/json' --data '{"LicenseId": ""}' ``` Replace: -- `` with your Local Licensing Service IP address +- `` with your Local Licensing Service IP address. +- `` with your Local Licensing Service port. Default value is `8000`. - `` with your license ID. ## Verify license data -To verify your licenses have loaded, use the `/v1/listLicenses` endpoint to list license data loaded on Local License Service. +To verify your licenses have loaded, use the `/v1/listLicenses` endpoint to list license data loaded on Chef Local License Service. ```sh -curl --location --request GET 'http://:8000/v1/listLicenses' +curl --location --request GET 'http://:/v1/listLicenses' ``` -After you upload the license data, you can set your Local License Service IP address or URL in your Chef applications using the `CHEF_LICENSE_SERVER` environment setting or `--chef-license-server` CLI option. +Replace: + +- `` with your Local Licensing Service IP address. +- `` with your Local Licensing Service port. Default value is `8000`. + +After you upload the license data, you can set your Chef Local License Service IP address or URL in your Chef applications using the `CHEF_LICENSE_SERVER` environment setting or `--chef-license-server` CLI option. diff --git a/_vendor/modules.txt b/_vendor/modules.txt index 90ee7f1b55..dbf7413f98 100644 --- a/_vendor/modules.txt +++ b/_vendor/modules.txt @@ -13,7 +13,7 @@ # github.com/chef/effortless/docs-chef-io v0.0.0-20230711123605-c8beb79aba4f # github.com/chef/compliance-profiles/docs-chef-io v0.0.0-20241211025148-fb9cb1f3e2bc # github.com/chef/compliance-remediation-2022/docs-chef-io v0.0.0-20240313054833-ebbc45209efa -# github.com/chef/license-service/docs-chef-io v0.0.0-20231117105514-d3f3d53ba2dd +# github.com/chef/license-service/docs-chef-io v0.0.0-20250120051510-ae1de80f4621 # github.com/chef/chef-docs-theme v0.0.0-20241206202643-d5ef90c514a1 # github.com/FortAwesome/Font-Awesome v0.0.0-20240108205627-a1232e345536 # github.com/cowboy/jquery-hashchange v0.0.0-20100902193700-0310f3847f90 diff --git a/go.mod b/go.mod index 544bde8d83..a304d74808 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/chef/compliance-remediation-2022/docs-chef-io v0.0.0-20240313054833-ebbc45209efa // indirect github.com/chef/desktop-config/docs-chef-io v0.0.0-20240814044820-5af667d41a43 // indirect github.com/chef/effortless/docs-chef-io v0.0.0-20230711123605-c8beb79aba4f // indirect - github.com/chef/license-service/docs-chef-io v0.0.0-20231117105514-d3f3d53ba2dd // indirect + github.com/chef/license-service/docs-chef-io v0.0.0-20250120051510-ae1de80f4621 // indirect github.com/chef/supermarket/docs-chef-io v0.0.0-20241105172430-a362eded8f72 // indirect github.com/cowboy/jquery-hashchange v0.0.0-20100902193700-0310f3847f90 // indirect github.com/habitat-sh/habitat/components/docs-chef-io v0.0.0-20241227173243-de19b906a228 // indirect diff --git a/go.sum b/go.sum index 7e532bea75..03178222cf 100644 --- a/go.sum +++ b/go.sum @@ -14,8 +14,8 @@ github.com/chef/desktop-config/docs-chef-io v0.0.0-20240814044820-5af667d41a43 h github.com/chef/desktop-config/docs-chef-io v0.0.0-20240814044820-5af667d41a43/go.mod h1:90xAx6sIfgSL50M2KzeBmx7V7s7dlhQU3xpUkJO0qW0= github.com/chef/effortless/docs-chef-io v0.0.0-20230711123605-c8beb79aba4f h1:6+VjBykE1b9LGfJEBstSKLAGJySrhu6NY162gz+cnxo= github.com/chef/effortless/docs-chef-io v0.0.0-20230711123605-c8beb79aba4f/go.mod h1:Lfq+HjwAQwUJ41EPTO/8qbI1oJb2i415fR28d2Ig9kc= -github.com/chef/license-service/docs-chef-io v0.0.0-20231117105514-d3f3d53ba2dd h1:I4Rgzposq3E5Dd+swVEry+rs3zvEKSN29NS3noKRcTY= -github.com/chef/license-service/docs-chef-io v0.0.0-20231117105514-d3f3d53ba2dd/go.mod h1:leNCF0KadV7zjm7YpVegNnbmWYUFXgaPKHP4tTDacos= +github.com/chef/license-service/docs-chef-io v0.0.0-20250120051510-ae1de80f4621 h1:xhFjMLTM/newy2E4YVEZPE8Pfr7Z1yJOkby7BRDlbA8= +github.com/chef/license-service/docs-chef-io v0.0.0-20250120051510-ae1de80f4621/go.mod h1:leNCF0KadV7zjm7YpVegNnbmWYUFXgaPKHP4tTDacos= github.com/chef/supermarket/docs-chef-io v0.0.0-20241105172430-a362eded8f72 h1:mGnH8fxL69YfwoLP+mJP5fodAukQVf0A5lmF+7Cq/64= github.com/chef/supermarket/docs-chef-io v0.0.0-20241105172430-a362eded8f72/go.mod h1:D+9mmEZxCwpdhZ8LrEODBWMwMufmJUubSt5NlU/lLB4= github.com/cowboy/jquery-hashchange v0.0.0-20100902193700-0310f3847f90 h1:p/a5iSATj0OjrqJLX/YKxYdGXhZzW58yyyNIC4JY4S0=