chefrun

Parameters

Name Type Constraints Default Definition
roles list of strings required   Compute roles the action will be run on.
runList list of strings required   List of Chef recipes or roles to apply to the computes.
jattrs map   {} Specifies node attributes for recipes that will be run in the run list.
endpoint string required if not isSolo   URL to the Chef server API endpoint.
validatorIdentity string required if not isSolo   Chef validator identity that will be used to create new client certificates and node objects on the Chef server.
validatorCredential pem     Chef validator key must be in a strictly specific format: written in a single line and all new lines must be clearly indicated with \n.
chefState map     Sets Chef attributes for the nodes corresponding to the computes in the role.
isSolo bool required false Switches modes between Chef Client and Chef Solo.
debugMode bool optional false Enables the full command line printing into the activity log and the exec.info file on target VMs.

Solo Mode

These parameters are applicable when the isSolo parameter is set to true.

Name Type Constraints Default Definition
recipeUrl string required if isSolo   URL of the archive containing Chef recipes.
chefState map     Sets Chef attributes for the nodes corresponding to the computes in the role for this run only.
version string   10.16.2 Chef version to install. If the node already has Chef installed, this parameter is ignored.

Return Values

Name Type Definition
chefState map Chef attributes at the time of step finish.

Example Usage

  • chef-client mode:

    xwiki.install:
            action: chefrun
            phase: deployxwiki
            precedingPhases: [ deploydb ]
            parameters:
                roles: [ xwikinode ]
                runList: ["recipe[xwiki::app]"]
                jattrs:
                    tomcat:
                       java_options: "-Xms256M -Xmx512M -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true"
    
                endpoint: $chefEndpoint
                validatorIdentity: $chefValidatorIdentity
                validatorCredential: $chefValidatorCredential
            output:
                 state_var: chefState
    
  • chef-solo mode:

    mysql.install:
      action: chefrun
      phase: deploydb
      precedingPhases: [ provision ]
      parameters:
           roles: [ dbnode ]
           runList: ["recipe[mysql::server]"]
           isSolo: true
           recipeUrl: "https://s3.amazonaws.com/adp-chef/cookbooks-v0.0.2.tar.gz"
    

Using with compute.Instance

Note

A set of components that will be called by this step is defined using the same rules, as during a commandCall step execution with parameter multi set to true. Please refer to the “Calling multiple peers” section of the commandCall step documentation.

To use chefrun with Compute Instance components, a corresponding interface should be declared on Workflow Instance component. Full compute.Instance interface is available in the documentation, but for chefrun at least exec, put-file and get-file commands should be available. Also, an optional networks signal can be declared, to make ip addresses appear in error messages instead of peer ids.

Example interfaces declaration is as follows:

myworkflow:
  type: workflow.Instance
  interfaces:
    mycompute:
      networks:        consume-signal(map<string, map<string, string>>)
      exec:            send-command(string command, int timeout => string stdOut, string stdErr => string stdOut, string stdErr, int exitCode)
      put-file:        send-command(string filename, bytes payload)
      get-file:        send-command(string filename => bytes payload)

After that, interface name can be used as a role name during chefun or chefsolo calls. Note that roles, manipulated with provisionVms step, can not be intermixed with interface names in the same step. All other usage is the same:

mysql.install:
  action: chefrun
  phase: deploydb
  precedingPhases: [ provision ]
  parameters:
       roles: [ mycompute ]
       runList: ["recipe[mysql::server]"]
       isSolo: true
       recipeUrl: "https://s3.amazonaws.com/adp-chef/cookbooks-v0.0.2.tar.gz"