Skip to content
Graham Pugh edited this page Jun 3, 2021 · 2 revisions

Policy

Policies are generated on the fly by supplying the JSSImporter with a policy template. This is a simplified XML document-essentially an empty policy object from the API. The JSSImporter will handle substituting in the scope, category, and package information as specified in the other parts of the recipe. You may, if you wish, also include elements directly. Any groups mentioned in the input variables to the recipe, for example, would get added to the scoping groups hardcoded into the supplied policy template.

When adding a package to a policy, the policy_action_type input variable is used to determine the type of package action to perform. The default is Install. Valid arguments also include Cache and Install Cached.

Indeed, the only input variables for policies are policy_category, discussed earlier, and policy_template, which should be a path to a policy template, an example of which is included with this project. Again, you can experiment with values in the web interface, and then get the XML data from either an API lookup through the API documentation for your server, https://yourcasperserver:8443/api/, or if you're feeling spicy, through jss_helper or through the python-jss wrapper.

If the policy_category value is set, it will be used to create a category, even if the policy template doesn't template that value into the policy's category spot using the %POLICY_CATEGORY% replacement variable. Likewise, if you set input variable policy_category, it will be used in the policy template even if it doesn't use the replacemement tag or doesn't have a category tag to begin with. If you make a mistake and specify policy_category and hardcode a category into the policy template, only the policy_category will be created, and the policy will use it, e.g. policy_category wins.

See the "Template" section for a list of all of the string replacement variables.

You can skip policy creation by leaving out the policy_template key, or specifying an empty value for the policy_template. I.e.:

<key>policy_template</key>
<string></string>