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

Fix backfill result conditional #9

Closed
DrPsychick opened this issue Feb 25, 2020 · 2 comments
Closed

Fix backfill result conditional #9

DrPsychick opened this issue Feb 25, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@DrPsychick
Copy link
Owner

When backfill is complete and all elements are ok (so it seems), the condition fails.

Assumption:

  • a check if attribute='skipped' exists should help
  • check for other occurences and fix them as well
TASK [ansible_influx_downsampling : compact telegraf/influxdb_database - Backfilling measurement] **********************
ok: [localhost] => (item=7)
ok: [localhost] => (item=6)
ok: [localhost] => (item=5)
ok: [localhost] => (item=4)
ok: [localhost] => (item=3)
ok: [localhost] => (item=2)
ok: [localhost] => (item=1)

TASK [ansible_influx_downsampling : compact telegraf/influxdb_database - Print result from backfill] *******************
fatal: [localhost]: FAILED! => {"msg": "The conditional check '(ansible_influx_mm_backfill is succeeded and ansible_influx_mm_backfill is not changed and ansible_influx_mm_backfill is not skipped and (ansible_influx_mm_backfill.results|map(attribute='skipped')|flatten|default([])|unique != [ true ]) and (ansible_influx_mm_backfill.results|map(attribute='succeeded')|flatten|default([])|unique != [ true ]) ) or ansible_influx_mm_backfill is failed' failed. The error was: error while evaluating conditional ((ansible_influx_mm_backfill is succeeded and ansible_influx_mm_backfill is not changed and ansible_influx_mm_backfill is not skipped and (ansible_influx_mm_backfill.results|map(attribute='skipped')|flatten|default([])|unique != [ true ]) and (ansible_influx_mm_backfill.results|map(attribute='succeeded')|flatten|default([])|unique != [ true ]) ) or ansible_influx_mm_backfill is failed): 'dict object' has no attribute 'skipped'\n\nThe error appears to be in '/Users/muc/work/git/ansible-roles/ansible_influx_downsampling/tasks/influxdb_measurement.yml': line 129, 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: '{{ mm_prefix }} Print result from backfill'\n  ^ here\nWe could be wrong, but this one looks like it might be an issue with\nmissing quotes. Always quote template expression brackets when they\nstart a value. For instance:\n\n    with_items:\n      - {{ foo }}\n\nShould be written as:\n\n    with_items:\n      - \"{{ foo }}\"\n"}
@DrPsychick DrPsychick added the bug Something isn't working label Feb 25, 2020
@DrPsychick
Copy link
Owner Author

try this as solution: ansible/ansible#24338 (comment)

DrPsychick added a commit that referenced this issue Sep 6, 2020
@DrPsychick
Copy link
Owner Author

DrPsychick commented Sep 6, 2020

Solution:

# |selectattr('attribute', 'default')|map(attribute='attribute')
ansible localhost -m command -a "echo {{ [ { 'values': 'foo' }, { 'name': 'bar' } ] |selectattr('foo', 'defined')|map(attribute='foo')|flatten()|default([])|list  }}"

or

# |map(attribute='attribute')|reject('undefined')
ansible localhost -m command -a "echo {{ [ { 'values': 'foo' }, { 'name': 'bar' } ] |map(attribute='foo')|reject('undefined')|flatten()|default([])|list  }}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant