Skip to content

Instantly share code, notes, and snippets.

@sapphirelin
Last active March 18, 2022 08:51
Show Gist options
  • Save sapphirelin/44f34388a5800ed82b215b7fe7c66171 to your computer and use it in GitHub Desktop.
Save sapphirelin/44f34388a5800ed82b215b7fe7c66171 to your computer and use it in GitHub Desktop.
# # Step 0: 定義連接到 Avi Controller的方法 #
- hosts: localhost
vars:
avi_credentials:
controller: "172.16.6.214"
username: "admin"
password: "XXXXXXXXXX"
api_version: "18.2.5"
connection: local
roles:
- role: avinetworks.avisdk
tasks:
# # Step 1: 建立展示的 AVI-Pool #
- name: Create AVI-Pool
avi_pool:
avi_credentials: "{{avi_credentials}}"
state: present
name: ansible-demo-pool
lb_algorithm: "LB_ALGORITHM_ROUND_ROBIN"
servers:
- ip:
addr: "172.16.16.211"
type: "V4"
- ip:
addr: "172.16.16.212"
type: "V4"
- ip:
addr: "172.16.16.213"
type: "V4"
- ip:
addr: "172.16.22.214"
type: "V4"
# # Step 2: 建立對應的 Virtual IP #
- name: Create Virtual IP
avi_vsvip:
avi_credentials: "{{avi_credentials}}"
state: present
name: ansible-demo-vip
vip: - enabled: true
ip_address:
addr: "172.16.21.248"
type: "V4"
# # Step 3: 建立展示的 Virtual Service #
- name: Create the Demo Virtual Service
avi_virtualservice:
avi_credentials: "{{avi_credentials}}"
state: present
name: ansible-demo-vs
services:
- port: "80"
pool_ref: '/api/pool?name=ansible-demo-pool'
vsvip_ref: '/api/vsvip/?name=ansible-demo-vip'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment