ini.options_present uses DEFAULT_IMPLICIT as a literal section name
Description of Issue/Question
With 2016.6.3, ini.options_present doesn't work as expected when DEFAULT_IMPLICIT is used as section name.
Setup
The following code used to work:
test:
ini.options_present:
- name: /tmp/test
- sections:
DEFAULT_IMPLICIT:
TEST: 'AAA'
and created a file with
TEST = AAA
Now the file is created as
[DEFAULT_IMPLICIT]
TEST = AAA
Removing DEFAULT_IMPLICIT as section makes it work again
test:
ini.options_present:
- name: /tmp/test
- sections:
TEST: 'AAA'
@giannello looks like this was changed on purpose according to this issue: #16294
Looks liek it would be useful to update the documentation though. I'll add it as a documentation bug.
Got hit by this too (is the +1 from github taken into account?)
Oh, and I get the following bug in test=True
Function: ini.options_present
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1733, in call
**cdata['kwargs'])
File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1653, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/salt/states/ini_manage.py", line 53, in options_present
cur_value = __salt__['ini.get_option'](name, section, key)
File "/usr/lib/python2.7/dist-packages/salt/modules/ini_manage.py", line 99, in get_option
return inifile.get(section, {}).get(option, None)
AttributeError: 'str' object has no attribute 'get'
Started: 16:59:09.469528
Duration: 4.075 ms
Changes:
ping @Akilesh1597
I suspect that this is because the get_option function doesn't handle the "no sections" case:
https://github.com/Akilesh1597/salt/blob/develop/salt/modules/ini_manage.py#L79
It looks like other functions there may also fail to cope with this.
This should have been fixed by 479c8dee