Forum Discussion
Lee_Sutcliffe
Oct 17, 2018Nacreous
The REST API doesn't permit 'bulk imports' So whilst the suggestions buy Tiziano and Youseff are correct, you would need to repeat the process as REST API uses an imperative model - think of it as multiple remote tmsh commands that need to be executed in a given order.
The easiest way to bulk import would be to consider Ansible, whilst the SDK under the hood will send multiple commands - it appears more declarative in nature.
---
- name: Setup
hosts: f5
connection: local
gather_facts: True
vars:
f5Provider:
server: "{{inventory_hostname}}"
user: "{{f5User}}"
password: "{{f5Pass}}"
validate_certs: no
transport: rest
nodelist:
- {name: 'test01', address: '8.8.8.8', priority_group: 1, state: 'present'}
- {name: 'test02', address: '8.8.4.4', priority_group: 1, state: 'present'}
environment:
F5_SERVER: "{{ inventory_hostname }}"
F5_USER: "{{ f5Provider.user }}"
F5_PASSWORD: "{{ f5Provider.password }}"
F5_VALIDATE_CERTS: "{{ f5Provider.validate_certs }}"
F5_SERVER_PORT: "{{ f5Provider.server_port }}"
tasks:
- name: Add pool 'test_pool'
bigip_pool:
lb_method: least-connections-member
name: test_pool
monitor_type: single
monitors:
- /Common/gateway_icmp
priority_group_activation: 0
delegate_to: localhost
notify: Save configuration
- name: Add nodes
bigip_node:
address: "{{ item.address }}"
name: "{{ item.name }}"
loop: "{{ nodelist }}"
delegate_to: localhost
notify: Save configuration
- name: Add pool members to Pool 'test_pool'
bigip_pool_member:
pool: test_pool
address: "{{ item.address }}"
name: "{{ item.name }}"
port: 53
priority_group: "{{ item.priority_group }}"
state: "{{ item.state }}"
loop: "{{ nodelist }}"
delegate_to: localhost
notify: Save configuration