Inject variables into specified hosts for use by subsequent tasks.
| Parameter | Description | Type | Required | Default |
|---|---|---|---|---|
| hosts | Target hosts, host name or group name | string or string array | No | - |
| vars | Variables to set | map | No | - |
1. Set string variable
- name: set string
add_hostvars:
hosts: all
vars:
c: d2. Set nested variable
- name: set map
add_hostvars:
hosts: all
vars:
a:
b: c