IBM-Security / isam-ansible-roles

Ansible Custom Modules, Handlers and Tasks for ISAM. Requires "ibmsecurity" python package.
Apache License 2.0
24 stars 43 forks source link

delete_certdb_personal_cert DEBUG enable issue #169

Closed rfransix closed 4 years ago

rfransix commented 4 years ago

Hi, uncommenting the debug lines causes a missing quote somewhere and the play fails immediately. Let me know if you see the fix. Thank you. The goal is to use debug to output the kdb id on failure.

cat main.yml main.yml

- name: Output

debug:

msg="{{ kdb2_id }} {{ item['id'] }} {{ item['notafter_epoch'] }}"

with_items:

- "{{certdbs_personallist_ret_obj['data']}}"

when: ({{ item['notafter_epoch'] }} < {{ ansible_date_time.epoch }})

rfransix commented 4 years ago

Using yamllint, i change the debug statement to this:

And the play returns...any ideas, why? TASK [delete_certdb_personal_cert : Output] ** [WARNING]: conditional statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found: ({{ item['notafter_epoch'] }} < {{ ansible_date_time.epoch }})

rfransix commented 4 years ago

Trying this approach did not output the kdb id :

rfransix commented 4 years ago

Valid YAML! --- checked in www.yamllint.com too.

rfransix commented 4 years ago

This is working with the above change on success only. Any idea on how to get it to work on failure or FATAL ?

ram-ibm commented 4 years ago

[WARNING]: conditional statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found: ({{ item['notafter_epoch'] }} < {{ ansible_date_time.epoch }})

The key is the above warning. You do not need curly braces in the when clause. Something like this should work better (not tested): when: item['notafter_epoch'] < ansible_date_time.epoch

I would also recommend dumping the entire variable in a debug statement first before iterating through lists.

- name: Output
  debug: "{{certdbs_personallist_ret_obj['data']}}"

Start like above and then add what you need.

rfransix commented 4 years ago

Hi, that’s right. I removed the braces and got rid of that error.

After that, deleting both signers and personals processed without errors.

From: Ram Sreerangam [mailto:notifications@github.com] Sent: Friday, December 13, 2019 2:06 PM To: IBM-Security/isam-ansible-roles Cc: rfransix; Author Subject: Re: [IBM-Security/isam-ansible-roles] delete_certdb_personal_cert DEBUG enable issue (#169)

[WARNING]: conditional statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found: ({{ item['notafter_epoch'] }} < {{ ansible_date_time.epoch }})

The key is the above warning. You do not need curly braces in the when clause. Something like this should work better (not tested): when: item['notafter_epoch'] < ansible_date_time.epoch

I would also recommend dumping the entire variable in a debug statement first before iterating through lists.

Start like above and then add what you need.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/IBM-Security/isam-ansible-roles/issues/169?email_source=notifications&email_token=AKFUPRDQW3NHEPI7R5DGQFDQYPTIVA5CNFSM4JZTJW32YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG3DMYA#issuecomment-565589600 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AKFUPRFO47TZ3SRGRZF5J6DQYPTIVANCNFSM4JZTJW3Q . https://github.com/notifications/beacon/AKFUPRBFRI4LDWIFHSGSF6LQYPTIVA5CNFSM4JZTJW32YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG3DMYA.gif