Closed rfransix closed 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 }})
Trying this approach did not output the kdb id :
when: "( item['notafter_epoch'] < ansible_date_time.epoch )"
Valid YAML! --- checked in www.yamllint.com too.
This is working with the above change on success only. Any idea on how to get it to work on failure or FATAL ?
[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.
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
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: Set Fact set_fact: kdb2_id: "{{ cert_db_id }}"
name: Get list of Personal Certificates in Keystore isam: appliance: "{{ inventory_hostname }}" username: "{{ username }}" password: "{{ password }}" lmi_port: "{{ lmi_port }}" log: "{{ log_level }}" force: "{{ force }}" action: ibmsecurity.isam.base.ssl_certificates.personal_certificate.get_all isamapi: kdb_id: "{{ cert_db_id }}" register: ret_obj
name: Set variable for use by rest of playbook set_fact: certdbs_personallist_ret_obj: "{{ ret_obj }}"
- 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 }})