gekmihesg/ansible-openwrt

why is option required in named sections?

atemp opened this issue · 1 comments

atemp commented

When using named sections option is required, but i am not sure why.

This playbook snippet

- name: test_section
  uci:
    command: section
    config: test_section
    type: the_type
    name: the_name
    value:
      val1: value one
      val2: value two

will give the following ansible error:

fatal: [192.168.1.1]: FAILED! => {"changed": false, "command": "section", "config": "test_section", "msg": "config, type and option required for section"}

But if i add an option

- name: test_section
  uci:
    command: section
    config: test_section
    type: the_type
    name: the_name
    value:
      val1: value one
      val2: value two
    option: the_option

it works and creates this on the openwrt host:

root@OpenWrt:/etc/config# cat test_section 

config the_type 'the_name'
	option val2 'value two'
	option val1 'value one'

root@OpenWrt:/etc/config# 

It seems the_option is unrelevant to the result.

I did some debugging and it seems the following uci commands are done:

/sbin/uci add test_section the_type
/sbin/uci rename test_section.cfg013b47=the_name
/sbin/uci set test_section.the_name.the_option=
/sbin/uci set test_section.the_name.val2=value two
/sbin/uci set test_section.the_name.val1=value one

So the_option is used, but it does not seem to do anything at all. Launched manually the uci commands do the same w/o the the_option line.

Is there any deeper sense in that or would it be possible to allow named sections w/o option?

Thanks, should work without option now.