Created
March 27, 2017 17:52
-
-
Save dcolebatch/8782cbe68b9c9653dcdc74053e793fe8 to your computer and use it in GitHub Desktop.
Example of an ansible playbook for replacing an NLB cluster
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: CREATE NODES,POOL,VIRTUAL SERVER FOR MyNLBcluster | |
hosts: f5 | |
connection: local | |
gather_facts: false | |
vars: | |
default_partition: "_NLB_Partition" | |
pool_name: "POOL-PROD_MyNLBcluster" | |
vip_basename: "VIP_PROD_MyNLBcluster" | |
ports: | |
- 80 | |
- 443 | |
nodes: | |
- { ip: "10.6.1.11", fqdn: "server_1.mycompany.com", node_name: "/Common/server_1", name: "server_1", description: "PROD-WEB", env: "PROD" } | |
- { ip: "10.6.1.12", fqdn: "server_2.mycompany.com", node_name: "/Common/server_2", name: "server_2", description: "PROD-WEB", env: "PROD" } | |
- { ip: "10.6.1.13", fqdn: "server_3.mycompany.com", node_name: "/Common/server_3", name: "server_3", description: "PROD-WEB", env: "PROD" } | |
- { ip: "10.6.1.14", fqdn: "server_4.mycompany.com", node_name: "/Common/server_4", name: "server_4", description: "PROD-WEB", env: "PROD" } | |
tasks: | |
- name: Add nodes | |
bigip_node: | |
server: "10.1.1.10" | |
validate_certs: false | |
user: "{{ my_login }}" | |
password: "{{ my_password }}" | |
state: "present" | |
partition: "Common" | |
address: "{{ item.ip }}" | |
name: "{{ item.node_name }}" | |
description: "{{ item.description }}" | |
monitors: | |
- "/Common/_NODE-internal-default_{{ item.env }}_ICMP" | |
with_items: "{{ nodes }}" | |
- name: "Add pools: {{ pool_name }}" | |
bigip_pool: | |
server: "10.1.1.10" | |
validate_certs: false | |
user: "{{ my_login }}" | |
password: "{{ my_password }}" | |
state: "present" | |
partition: "{{ default_partition }}" | |
lb_method: "least_connection_node_address" | |
name: "{{ pool_name }}-{{ item }}" | |
monitors: | |
- "/Common/_POOL_{{ item }}_GenericTCP" | |
with_items: "{{ ports }}" | |
- name: Add <nodes>:80 to pool | |
bigip_pool_member: | |
server: "10.1.1.10" | |
validate_certs: false | |
user: "{{ my_login }}" | |
password: "{{ my_password }}" | |
state: "present" | |
partition: "{{ default_partition }}" | |
pool: "{{ pool_name }}-80" | |
host: "{{ item.ip }}" | |
port: 80 | |
description: "{{ item.description }}" | |
name: "{{ item.node_name }}" | |
connection_limit: 0 | |
monitor_state: enabled | |
preserve_node: false | |
rate_limit: 0 | |
ratio: 1 | |
session_state: enabled | |
with_items: "{{ nodes }}" | |
- name: Add <nodes>:443 to pool | |
bigip_pool_member: | |
server: "10.1.1.10" | |
validate_certs: false | |
user: "{{ my_login }}" | |
password: "{{ my_password }}" | |
state: "present" | |
partition: "{{ default_partition }}" | |
pool: "{{ pool_name }}-443" | |
host: "{{ item.ip }}" | |
port: 443 | |
description: "{{ item.description }}" | |
name: "{{ item.node_name }}" | |
connection_limit: 0 | |
monitor_state: enabled | |
preserve_node: false | |
rate_limit: 0 | |
ratio: 1 | |
session_state: enabled | |
with_items: "{{ nodes }}" | |
- name: Add Virtual Servers for MyNLBcluster (sticky) | |
bigip_virtual_server: | |
server: "10.1.1.10" | |
validate_certs: false | |
user: "{{ my_login }}" | |
password: "{{ my_password }}" | |
state: "present" | |
partition: "{{ default_partition }}" | |
name: "{{ vip_basename }}_{{ item }}_Int" | |
destination: "10.6.1.178" | |
port: "{{ item }}" | |
snat: Automap | |
default_persistence_profile: "/Common/source_addr" | |
pool: "{{ pool_name }}-{{ item }}" | |
with_items: "{{ ports }}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment