# salt.states.ini_manage

## Manage ini files

maintainer:

  <akilesh1597@gmail.com>

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 `None` is passed, it uses the system default which is likely `utf-8`. Default is `None`

      Added in version 3006.10.

  Returns:

    A dictionary containing list of changes made

  Return type:

    dict

  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 `ini` file. Options present in the ini file and not specified in the sections dict will be untouched, unless the `strict: True` flag 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: True` is 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 `sections` dictionary contains all settings in the ini file. `True` will create an ini file with only the values specified in `sections`. `False` will 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 `None` is passed, it uses the system default which is likely `utf-8`. Default is `None`

      Added 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.

      Added in version 3006.10.

  Returns:

    A dictionary containing list of changes made

  Return type:

    dict

  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: True` is 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 `None` is passed, it uses the system default which is likely `utf-8`. Default is `None`

      Added in version 3006.6.

  Returns:

    A dictionary containing list of changes made

  Return type:

    dict

  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 `None` is passed, it uses the system default which is likely `utf-8`. Default is `None`

      Added in version 3006.10.

  Returns:

    A dictionary containing list of changes made

  Return type:

    dict

  Example:

      /home/saltminion/api-paste.ini:
        ini.sections_present:
          - separator: '='
          - sections:
              - section_one
              - section_two