Forum Discussion
adams8907_36321
Oct 17, 2018Historic F5 Account
How to add nodes in bulk using RestAPI?
I am trying to generate add multiple nodes using RestAPI, but I have not been able.
Wondering if this is possible, if so, can you give me an example?
Lee_Sutcliffe
Nacreous
Oct 17, 2018The 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
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects
