dj-wasabi / ansible-telegraf

Installing and configuring Telegraf via Ansible for RedHat/Debian/Ubuntu/Windows/Suse.
MIT License
134 stars 116 forks source link

Fix comparison #115 #118

Closed jgeusebroek closed 4 years ago

jgeusebroek commented 4 years ago

Fixes the version comparison when not using a integer.

jgeusebroek commented 4 years ago

This works, however it defaults to config file < 0.10. There should be a better check in place to check the installed version.

jgeusebroek commented 4 years ago

A workaround could be if not a version (ie. alpine, or latest) then it's > 0.10 for sure. If it is a version compare the version number.

Any thoughts?

dj-wasabi commented 4 years ago

Hi @jgeusebroek I have no idea. Do you have a suggestion?

Puneeth-n commented 4 years ago

facing this issue as well

dj-wasabi commented 4 years ago

@Puneeth-n

Suggestion in how to continue with the issue @jgeusebroek mentinoned?

dj-wasabi commented 4 years ago

I have merged #135 which will work better, so I will be closing this PR.

jgeusebroek commented 4 years ago

135 does not fix the issue unfortunately, the error remains the same. int should be forced to prevent it from accuring.

fatal: [xxx.xxx]: FAILED! => {"msg": "The conditional check 'telegraf_agent_version is version('0.10.0', '<')' failed. The error was: Version comparison: '<' not supported between instances of 'str' and 'int'\n\nThe error appears to be in '/path/to/roles/dj-wasabi.telegraf/tasks/configure_linux.yml': line 24, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: \"Copy the template for versions < 0.10.0\"\n ^ here\n"}

dj-wasabi commented 4 years ago

Hi @jgeusebroek

I have used telegraf_agent_version: '0.2.4' this with Molecule as a test to see why it failes, but it workes in my case:

    TASK [ansible-telegraf : Retrieve all ec2 tags on the instance] ****************
    skipping: [telegraf-centos8]

    TASK [ansible-telegraf : Copy the template for versions < 0.10.0] **************
    changed: [telegraf-centos8]

    TASK [ansible-telegraf : Copy the template for versions >= 0.10.0] *************
    skipping: [telegraf-centos8]

How did you have configured the version?

Kind regards, Werner

jgeusebroek commented 4 years ago

Hi Werner, the problem occurs when using a non integer (named) version. Like "latest".

dj-wasabi commented 4 years ago

Hi @jgeusebroek

Ok, clear. The telegraf_agent_version should contain a specific version to be installed. It does not handle latest. If you want to make use of the actual latest version, then you'll have to set the property telegraf_agent_package_state: latest. Then it ignores the telegraf_agent_version property/value.

Kind regards, Werner

jgeusebroek commented 4 years ago

Thanks for the reply, but this will fail when using the docker image. Forcing an int, should solve the error. AFAIK it will not have any downsides.

telegraf_agent_version | int is version('0.10.0', '<')

dj-wasabi commented 4 years ago

@jgeusebroek

Yes, true indeed. I will create a PR after my lunch walk. Will let you know.