Skip to main content

Create scripts and run jobs with Chef Opsmith

Use this guide to generate a script from a plain-language description of an operational task, test it in a sandbox, and run it as a job on nodes enrolled in Chef 360 Platform.

Generate a script

You can use the Chef Opsmith chat interface to turn a plain-language description of a task into a tested Bash or PowerShell script.

To generate a script, follow these steps:

  1. In the chat box, describe the task you want to automate. For example, enter “I want to install nginx on my Linux machines.”

  2. Select a sandbox type to test the generated script against:

    • Containers: Linux based
    • Virtual Machines: Linux and Windows based
  3. Optional: Toggle Auto approval to let Opsmith execute its plan without waiting for your approval at each stage.

  4. Submit the prompt.

    Opsmith moves through the following stages, and waits for your approval at each one unless you turned on Auto approval:

    • Implementation plan: Opsmith generates a plan for completing the task.
    • Script generation: Opsmith creates the script that carries out the plan.
    • Sandbox creation: Opsmith creates the container or virtual machine you selected.
    • Script execution: Opsmith runs the generated script in the sandbox.
    • Execution status: Opsmith verifies whether the script performed the task successfully.
  5. Optional: Select any stage on the right side of the chat interface to expand it and view full details.

  6. If the script doesn’t meet your needs, continue the conversation in the same chat window to refine the prompt. Track the number of refinements using the version number displayed at the top of the page.

Create and run a job from a script

After you’ve created and tested a script, you can run the script as a job on nodes enrolled with Chef 360 Platform.

To run a job from your script on enrolled nodes, follow these steps:

  1. After Opsmith successfully executes and validates the script in the sandbox, select Run as job.

  2. Enter a name and description for the job.

    Use a name and description specific enough to help you find the job later in the list of jobs.

  3. Select one or more target nodes from the list of nodes enrolled in Chef 360 Platform.

  4. Configure the job schedule using one of the following options:

    • Run now: Send the job to the nodes immediately. Nodes process the job only after completing any job already running.
    • Run once: Send the job to the nodes at a specific date and time in the future. The date and time use the time zone the server is configured to use.
    • Recurring: Run the job repeatedly at a specified frequency. Configure the recurrence to repeat indefinitely or to end after a specific number of repetitions.
  5. Optional: Track the job after it’s created.

    Opsmith assigns a unique job ID so you can follow its progress. To track the job, select the job ID link to open the job details and view its status.

View and resume previous chat conversations

You can view previous conversations and resume any of them from the chat history.

Note

Each chat conversation has its own separate context. Information in one conversation isn’t available in another, so switching to a different chat won’t carry over details from the current one.

To view and resume a chat, follow these steps:

  1. In the left navigation panel, select Chat history.
  2. Select a chat from the list, sorted from most recent to oldest, and resume it where you left off.

See also

Thank you for your feedback!

×