Skip to content

Playbook Variables

🌰 In a Nutshell

Sum-up

  • CONTEXT Variables: Auto-filled during playbook execution.

  • SHARED Variables: Stored in the database, shared across playbooks, can be overridden.

  • MANUAL Variables: Manually entered before execution.

  • Adding Variables:

    • Use the configuration tab and + icon in the playbook.
    • Select the type, enter new or existing variable name, and provide values if needed.

Variable Types

SSM introduces three types of variables to include in your playbooks:

VariableDescription
CONTEXTA variable that is automatically filled by SSM during the run of the playbook.
SHAREDA variable stored in the database, available across playbooks and sharing the same value. It can be overridden for a process by entering a custom value. You can also change the saved value globally by clicking the Overwrite button in dedicated places.
MANUALThis variable is filled manually before each execution or can be defined when creating an automation.

Adding a Variable to a Playbook

You can add and share ExtraVars across playbooks. When a playbook is opened, click on the configuration tab above it, then click on the + icon on the top right side. playbooks2

Select a type, then enter a new name or select the name of an existing ExtraVar. Depending on the type of variable, you may need to enter a value. playbooks3

Variable Options

VariableValueDetails
CONTEXT🔴Automatically filled by SSM at runtime
SHARED🟠Not required if the variable already exists. Can be overridden for all playbooks
MANUAL🟠Will be entered before running a playbook

Setting a variable as required will make the variable mandatory before running a playbook. Ansible playbook execution will fail if a required variable is not defined, unless you set a default value:

yaml
- name: Uninstall agent on targeted device
  vars:
    agent_log_path: "{{ _ssm_agentLogPath | default(omit) }}"

CONTEXT Variables

VariableDescription
_ssm_deviceIdInternal SSM UUID of the device
_ssm_deviceIPThe device's last known IP address
_ssm_agentLogPathThe path of the agent log directory

To understand more about variables, see the official Ansible documentation.

Made with love