Edit ini files
maintainer: | <akilesh1597@gmail.com> |
---|---|
maturity: | new |
depends: | re |
platform: | all |
Use section as DEFAULT_IMPLICIT if your ini file does not have any section (for example /etc/sysctl.conf)
Get value of a key from a section in an ini file. Returns None if no matching key was found.
API Example:
import salt
sc = salt.client.get_local_client()
sc.cmd('target', 'ini.get_option',
[path_to_ini_file, section_name, option])
CLI Example:
salt '*' ini.get_option /path/to/ini section_name option_name
Retrieve a section from an ini file. Returns the section as dictionary. If the section is not found, an empty dictionary is returned.
API Example:
import salt
sc = salt.client.get_local_client()
sc.cmd('target', 'ini.get_section',
[path_to_ini_file, section_name])
CLI Example:
salt '*' ini.get_section /path/to/ini section_name
Remove a key/value pair from a section in an ini file. Returns the value of the removed key, or None if nothing was removed.
API Example:
import salt
sc = salt.client.get_local_client()
sc.cmd('target', 'ini.remove_option',
[path_to_ini_file, section_name, option])
CLI Example:
salt '*' ini.remove_option /path/to/ini section_name option_name
Remove a section in an ini file. Returns the removed section as dictionary, or None if nothing was removed.
API Example:
import salt
sc = salt.client.get_local_client()
sc.cmd('target', 'ini.remove_section',
[path_to_ini_file, section_name])
CLI Example:
salt '*' ini.remove_section /path/to/ini section_name
Edit an ini file, replacing one or more sections. Returns a dictionary containing the changes made.
Set summary=False if return data need not have previous option value
API Example:
import salt
sc = salt.client.get_local_client()
sc.cmd('target', 'ini.set_option',
['path_to_ini_file', '{"section_to_change": {"key": "value"}}'])
CLI Example:
salt '*' ini.set_option /path/to/ini '{section_foo: {key: value}}'
Docs for previous releases are available on salt.rtfd.org.
Latest Salt release: 2014.1.13
Try the shiny new release candidate of Salt, v2014.7.0rc6! More info here.
22.16.84. salt.modules.introspect
Upcoming SaltStack events, webinars and local meet ups and user groups.