provisioning-local icon indicating copy to clipboard operation
provisioning-local copied to clipboard

suggestion for datatype parameter

Open joba12 opened this issue 8 years ago • 1 comments

Hey Joseph,

any possiblity to change the type implementation in your gconftool2 module?

I've got a big list of key value pairs with along with the data type

For example a snippet of my guake variables:

gconf:
  - path: "/apps/guake/style"
    config:
      - key: "cursor_shape"
        value: "0"
        type: "int"
  - path: "/apps/guake/style/background"
    config:
      - key: "color"
        value: "#000000000000"
        type: "string"
  - path: "/apps/guake/style/font"
    config:
      - key: "allow_bold"
        value: "true"
        type: "bool"

to use this with the module i made one task for each data type, as the parameter name cannot be a variable:

- name: configure gconf string parameters
  gconftool2:
    key: "{{ item.0.path }}/{{ item.1.key }}"
    string: "{{ item.1.value }}"
  when: "'{{ item.1.type }}' == 'string'"
  with_subelements:
    - gconf
    - config

- name: configure gconf int parameters
  gconftool2:
    key: "{{ item.0.path }}/{{ item.1.key }}"
    int: "{{ item.1.value }}"
  when: "'{{ item.1.type }}' == 'int'"
  with_subelements:
    - gconf
    - config

- name: configure gconf bool parameters
  gconftool2:
    key: "{{ item.0.path }}/{{ item.1.key }}"
    bool: "{{ item.1.value }}"
  when: "'{{ item.1.type }}' == 'bool'"
  with_subelements:
    - gconf
    - config

I think it would be a lot more flexible if the datatype is defined via one parameter

i.e.:

- name: configure gconf parameters
  gconftool2:
    key: "{{ item.0.path }}/{{ item.1.key }}"
    value: "{{ item.1.value }}"
    type: "{{ item.1.type }}"
  with_subelements:
    - gconf
    - config

joba12 avatar Aug 22 '16 14:08 joba12

I don't see a reason not to change that. I didn't need that kind of flexibility so I didn't start with it. I'll take a look at the code when I have a moment, but seems like a reasonable change.

JBKahn avatar Aug 23 '16 02:08 JBKahn