Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hash, Array entries in config to python plugin ? #819

Closed
traylenator opened this issue Jun 13, 2018 · 1 comment
Closed

Hash, Array entries in config to python plugin ? #819

traylenator opened this issue Jun 13, 2018 · 1 comment
Labels
enhancement New feature or request

Comments

@traylenator
Copy link
Contributor

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: all
  • Ruby: all
  • Distribution: all
  • Module version: 9.0.2-rc0

How to reproduce (e.g Puppet code you use)

collectd::plugin::python{'extreme':
  modules => { 'extreme' => { 'config' => [{'Verbose' => true,
                                                                  'Array' => ['a', 'b', 'c'],
                                                                  'Hash' => {'d' => 'e', 'f' => 'g' },
                                                                }],
                                              }
                       }
}

What are you seeing

python-config.conf contains

Import "extreme"

<Module "extreme">
    Array "a"
    Array "b"
    Array "c"
    Hash d "e"
    Hash f "g"
    Verbose true
</Module>

What behaviour did you expect instead

The action is not documented so it is not obvious especially what the Hash should do.

If I had to guess.

<Module "extreme">
    Array "a" "b" "c"
    <Hash>
      d "e"
      f  "g"
    </Hash>
    Verbose true
</Module>

Any additional information you'd like to impart

Certainly the hash value I don't understand, I guess no one uses it or I am missing
the use case.
For the array value collectd modules are normally happy with either option but I would
suggest the 2nd is more natural.

Checking before contemplating .epp.

@traylenator
Copy link
Contributor Author

Proceed with the proposal to render arrays and hashes as above.

traylenator added a commit to traylenator/puppet-collectd that referenced this issue Jun 20, 2018
Covert templates for `collectd::module::python` to `epp`

Example

```puppet
collectd::plugin::python::module{'example':
  config => [{'Verbose' => true,
              'Values'  => ['abc',def'],
              'Name     => 'My Name',
              'Limit    => 3.4
             },
            ],
  }
}
```

This will now render as

```apache
Import "example"
<Module "example">
  Verbose true
  Values "abc" "def"
  Name "My Name"
  Limit 3.4
</Module>
```

Specifying a hash in the configuration will now result in a type
failure. Previously it would add nonsense to the configuration file.
e.g

```puppet
collectd::plugin::python::module{'example':
  config => [{'Values' => {'abc' => 'def'}}],
}
```
will now give a type error.

To specify a list of quoted strings use an array. Previously
the following could be used.

```puppet
collectd::plugin::python::module{'example':
  config => [{'Values' => '"abc" "def"',
              'Name'   => '"My Name"',
            }],
}
```

to acheive the same result use

```puppet
collectd::plugin::python::module{'example':
  config => [{'Values' => ['abc','def'],
              'Name'   => 'My Name',
            }],
}
```

to render

```apacheconf
Import "example"
<Module "example">
  Values "abc" "def"
  Name "My Name"
</Module>

Fixes voxpupuli#819
traylenator added a commit to traylenator/puppet-collectd that referenced this issue Jun 20, 2018
Convert templates for `collectd::module::python` to `epp`

Example

```puppet
collectd::plugin::python::module{'example':
  config => [{'Verbose' => true,
              'Values'  => ['abc',def'],
              'Name     => 'My Name',
              'Limit    => 3.4
             },
            ],
  }
}
```

This will now render as

```apache
Import "example"
<Module "example">
  Verbose true
  Values "abc" "def"
  Name "My Name"
  Limit 3.4
</Module>
```

Specifying a hash value in the `config` paramater will now result in a type
failure. Previously it would add nonsense to the configuration file.
e.g

```puppet
collectd::plugin::python::module{'example':
  config => [{'Values' => {'abc' => 'def'}}],
}
```
will now give a type error.

To specify a list of quoted strings use an array. Previously
the following could be used.

```puppet
collectd::plugin::python::module{'example':
  config => [{'Values' => '"abc" "def"',
              'Name'   => '"My Name"',
            }],
}
```

to acheive the same result use

```puppet
collectd::plugin::python::module{'example':
  config => [{'Values' => ['abc','def'],
              'Name'   => 'My Name',
            }],
}
```

to render

```apacheconf
Import "example"
<Module "example">
  Values "abc" "def"
  Name "My Name"
</Module>

It is now possible to specify multiple instances of single python
module by using `collectd::plugin::python::module` twice. e.g.

```puppet
collectd::plugin::python::module{'exampleA':
  module => 'example,
  config => [{'Values' => 'abc'],}
}
collectd::plugin::python::module{'exampleB':
  module => 'example,
  config => [{'Values' => 'def'],}
}
```

Fixes voxpupuli#819
traylenator added a commit to traylenator/puppet-collectd that referenced this issue Jun 20, 2018
Convert templates for `collectd::module::python` to `epp`

Example

```puppet
collectd::plugin::python::module{'example':
  config => [{'Verbose' => true,
              'Values'  => ['abc',def'],
              'Name     => 'My Name',
              'Limit    => 3.4
             },
            ],
  }
}
```

This will now render as

```apache
Import "example"
<Module "example">
  Verbose true
  Values "abc" "def"
  Name "My Name"
  Limit 3.4
</Module>
```

Specifying a hash value in the `config` paramater will now result in a type
failure. Previously it would add nonsense to the configuration file.
e.g

```puppet
collectd::plugin::python::module{'example':
  config => [{'Values' => {'abc' => 'def'}}],
}
```
will now give a type error.

To specify a list of quoted strings use an array. Previously
the following could be used.

```puppet
collectd::plugin::python::module{'example':
  config => [{'Values' => '"abc" "def"',
              'Name'   => '"My Name"',
            }],
}
```

to acheive the same result use

```puppet
collectd::plugin::python::module{'example':
  config => [{'Values' => ['abc','def'],
              'Name'   => 'My Name',
            }],
}
```

to render

```apacheconf
Import "example"
<Module "example">
  Values "abc" "def"
  Name "My Name"
</Module>

It is now possible to specify multiple instances of single python
module by using `collectd::plugin::python::module` twice. e.g.

```puppet
collectd::plugin::python::module{'exampleA':
  module => 'example,
  config => [{'Values' => 'abc'],}
}
collectd::plugin::python::module{'exampleB':
  module => 'example,
  config => [{'Values' => 'def'],}
}
```

Fixes voxpupuli#819
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant