fix(agent): don't load subnet from cache if not present

!1
This commit is contained in:
2024-02-20 15:34:51 +09:30
parent 68f43bf70f
commit 11a4701a63
2 changed files with 10 additions and 1 deletions

View File

@ -43,6 +43,7 @@
- "epoch: {{ (epoch | int + nfc_c_epoch_time_offset | int) | int }} [{{ nfc_c_cache_expire_time }}]" - "epoch: {{ (epoch | int + nfc_c_epoch_time_offset | int) | int }} [{{ nfc_c_cache_expire_time }}]"
- "epoch: {{ epoch }}" - "epoch: {{ epoch }}"
- "expired: {{ expired }}" - "expired: {{ expired }}"
when: cache_files.stat.exists
- name: Expire Cache - name: Expire Cache
ansible.builtin.file: ansible.builtin.file:
@ -69,8 +70,9 @@
return_content: true return_content: true
status_code: status_code:
- 200 - 200
- 404
validate_certs: false validate_certs: false
changed_when: "{{ api_call.json | length | int > 0 }}" changed_when: api_call.json | length | int > 0
no_log: true no_log: true
register: api_call register: api_call
when: > when: >
@ -89,6 +91,8 @@
state: directory state: directory
when: > when: >
'/' in api_path '/' in api_path
and
api_call.status | default(0) | int != 404
- name: Cache Data - name: Cache Data
@ -103,3 +107,5 @@
) )
or or
not cache_files.stat.exists not cache_files.stat.exists
and
api_call.status | default(0) | int != 404

View File

@ -19,6 +19,9 @@
ansible.builtin.set_fact: ansible.builtin.set_fact:
cached_subnet: "{{ lookup('file', cache_filepath) }}" cached_subnet: "{{ lookup('file', cache_filepath) }}"
cacheable: false cacheable: false
no_log: true
when: >
api_call.status | default(0) | int != 404
- name: Process Scan Results - name: Process Scan Results