feat(agent): Fetch subnets that match agents ID

!1
This commit is contained in:
2024-02-19 03:39:13 +09:30
parent fc7d816ab1
commit 805c50cd7e
2 changed files with 33 additions and 0 deletions

View File

@ -15,7 +15,12 @@
file: tasks/agent_id.yaml
- name: Subnets
ansible.builtin.include_tasks:
file: tasks/subnets.yaml
vars: # ToDo: remove the below t4est vars
api_subnets: subnets
api_scanagents: tools/scanagents
nfc_c_path_cache: "{{ playbook_dir }}/../cache"
nfc_c_cache_expire_time: 1800

View File

@ -0,0 +1,28 @@
---
- name: Reset Subnet List
ansible.builtin.set_fact:
nfc_c_scan_agent_subnets: []
- name: Get subnets to Scan
ansible.builtin.include_tasks:
file: tasks/api_call.yaml
vars:
api_client_name: "{{ client_name }}"
api_token: "{{ client_token }}"
api_path: "{{ api_subnets }}"
api_query_string: "filter_by=scanAgent&filter_value={{ nfc_c_scan_agent_id }}"
- name: Update Subnets List
ansible.builtin.set_fact:
nfc_c_scan_agent_subnets: "{{ nfc_c_scan_agent_subnets + [{
'id': network.id,
'address': network.subnet + '/' + network.mask
}] }}"
loop: "{{ data | default ([]) }}"
loop_control:
loop_var: network
vars:
data: "{{ lookup('file', cache_filepath) }}"