salt.states.ini_manage#
Manage ini files#
- maintainer:
- maturity:
new
- depends:
re
- platform:
all
- salt.states.ini_manage.options_absent(name, sections=None, separator='=', encoding=None)#
Remove a key/value pair from an ini file. Key/value pairs present in the ini file and not specified in sections dict will be untouched.
- Parameters:
name (str) -- The path to the ini file
sections (dict) -- A dictionary of sections and key/value pairs that will be removed from the ini file. Other key/value pairs in the ini file will be untouched.
separator (str) -- The character used to separate keys and values. Standard ini files use the "=" character. The default is
=.encoding (str) --
A string value representing encoding of the target ini file. If
Noneis passed, it uses the system default which is likelyutf-8. Default isNoneNew in version 3006.10.
- Returns:
A dictionary containing list of changes made
- Return type:
Example:
/home/saltminion/api-paste.ini: ini.options_absent: - separator: '=' - sections: test: - testkey - secondoption test1: - testkey1
- salt.states.ini_manage.options_present(name, sections=None, separator='=', strict=False, encoding=None, no_spaces=False)#
Set or create a key/value pair in an
inifile. Options present in the ini file and not specified in the sections dict will be untouched, unless thestrict: Trueflag is used.Sections that do not exist will be created.
- Parameters:
name (str) -- The path to the ini file
sections (dict) -- A dictionary of sections and key/value pairs that will be used to update the ini file. Other sections and key/value pairs in the ini file will be untouched unless
strict: Trueis passed.separator (str) -- The character used to separate keys and values. Standard ini files use the "=" character. The default is
=.strict (bool) -- A boolean value that specifies that the
sectionsdictionary contains all settings in the ini file.Truewill create an ini file with only the values specified insections.Falsewill append or update values in an existing ini file and leave the rest untouched.encoding (str) --
A string value representing encoding of the target ini file. If
Noneis passed, it uses the system default which is likelyutf-8. Default isNoneNew in version 3006.10.
no_spaces (bool) --
A bool value that specifies that the key/value separator will be wrapped with spaces. This parameter was added to have the ability to not wrap the separator with spaces. Default is
False, which maintains backwards compatibility.Warning
This will affect all key/value pairs in the ini file, not just the specific value being set.
New in version 3006.10.
- Returns:
A dictionary containing list of changes made
- Return type:
Example:
/home/saltminion/api-paste.ini: ini.options_present: - separator: '=' - strict: True - sections: test: testkey: 'testval' secondoption: 'secondvalue' test1: testkey1: 'testval121'
- salt.states.ini_manage.sections_absent(name, sections=None, separator='=', encoding=None)#
Remove sections from the ini file. All key/value pairs in the section will also be removed.
- Parameters:
name (str) -- The path to the ini file
sections (dict) -- A dictionary of sections and key/value pairs that will be used to update the ini file. Other sections and key/value pairs in the ini file will be untouched unless
strict: Trueis passed.separator (str) -- The character used to separate keys and values. Standard ini files use the "=" character. The default is
=.encoding (str) --
A string value representing encoding of the target ini file. If
Noneis passed, it uses the system default which is likelyutf-8. Default isNoneNew in version 3006.6.
- Returns:
A dictionary containing list of changes made
- Return type:
Example:
/home/saltminion/api-paste.ini: ini.sections_absent: - separator: '=' - sections: - test - test1
- salt.states.ini_manage.sections_present(name, sections=None, separator='=', encoding=None)#
Add sections to an ini file. This will only create empty sections. To also create key/value pairs, use options_present state.
- Parameters:
name (str) -- The path to the ini file
sections (dict) -- A dictionary of sections and key/value pairs that will be used to update the ini file. Only the sections portion is used, key/value pairs are ignored. To also set key/value pairs, use the options_present state.
separator (str) -- The character used to separate keys and values. Standard ini files use the "=" character. The default is
=.encoding (str) --
A string value representing encoding of the target ini file. If
Noneis passed, it uses the system default which is likelyutf-8. Default isNoneNew in version 3006.10.
- Returns:
A dictionary containing list of changes made
- Return type:
Example:
/home/saltminion/api-paste.ini: ini.sections_present: - separator: '=' - sections: - section_one - section_two