Set a grains value in the grains config file key The grain key to be set. val The value to set the grain key to. destructive If an operation results in a key being removed, delete the key, too. Defaults to False. refresh_pillar Whether
(key, val, destructive=False, refresh_pillar=True)
| 298 | |
| 299 | |
| 300 | def setval(key, val, destructive=False, refresh_pillar=True): |
| 301 | """ |
| 302 | Set a grains value in the grains config file |
| 303 | |
| 304 | key |
| 305 | The grain key to be set. |
| 306 | |
| 307 | val |
| 308 | The value to set the grain key to. |
| 309 | |
| 310 | destructive |
| 311 | If an operation results in a key being removed, delete the key, too. |
| 312 | Defaults to False. |
| 313 | |
| 314 | refresh_pillar |
| 315 | Whether pillar will be refreshed. |
| 316 | Defaults to True. |
| 317 | |
| 318 | CLI Example: |
| 319 | |
| 320 | .. code-block:: bash |
| 321 | |
| 322 | salt '*' grains.setval key val |
| 323 | salt '*' grains.setval key "{'sub-key': 'val', 'sub-key2': 'val2'}" |
| 324 | """ |
| 325 | return setvals({key: val}, destructive, refresh_pillar=refresh_pillar) |
| 326 | |
| 327 | |
| 328 | def append(key, val, convert=False, delimiter=DEFAULT_TARGET_DELIM): |