! Load factory default cofig
tmsh load /sys config default
! Run management interface setup utility
config# config
! Load factory default cofig
tmsh load /sys config default
! Run management interface setup utility
config# config
See here for more info:
https://github.com/F5Networks/f5-ansible/blob/devel/examples/0000-getting-started/playbook.yaml
Directory structure looks like this:
├── inventory
│ └── hosts
└── playbook.yaml
<save the below to playbook.yaml>
---
- name: Create a VIP, pool and pool members
hosts: all
connection: local
vars:
provider:
password: admin
server: 192.168.1.245
user: admin
validate_certs: no
server_port: 443
tasks:
- name: Create a pool
bigip_pool:
provider: "{{ provider }}"
lb_method: ratio-member
name: web
slow_ramp_time: 120
delegate_to: localhost
- name: Add members to pool
bigip_pool_member:
provider: "{{ provider }}"
description: "webserver {{ item.name }}"
host: "{{ item.host }}"
name: "{{ item.name }}"
pool: web
port: 80
with_items:
- host: 10.10.10.10
name: web01
- host: 10.10.10.20
name: web02
delegate_to: localhost
- name: Create a VIP
bigip_virtual_server:
provider: "{{ provider }}"
description: foo-vip
destination: 172.16.10.108
name: vip-1
pool: web
port: 80
snat: Automap
profiles:
- http
- clientssl
delegate_to: localhost
name = "Martin"machine = "Hal"print ("Nice to meet you {0}. I am {1}".format(name,machine))
Boolean and None
python_course = True
int (python_course) == 1
If Statements
number = 5
if number == 5:
print ("Number is 5")
else:
print ("Number is NOT 5")
Lists (mutable, ordered)
student_names = ["John", "Paul", "George","Ringo"]
student_names[0] == "John"! List values start at 1student_names[-1] == "Ringo"
! Minus sign reads values from the right of the list
len(student_names) == 4
del student_names[2]
! Remove George from list
Dictionaries (mutable, associative array)
Device = {"hostname":"router1","OS":"v15.5,"location":"London")
Tuple (sequence of immutable objects)
Credentials = ("hostname","username","password")
Sets (unordered collection of unique and immutable objects)
Loops
for name in student_names
print ("Student name is {0}" .format(name))
For Loop
student_names = ["John", "Paul", "George","Ringo"]
for name in student_names:
if name == "John":
print("Found him! " + name)
break
Challenges:
Challenge 1:
#!/usr/bin/env python2.7
def devices():
routers = ["router1","router2","router3"]
print routers
def security():
credentials = {"router1":"passw0rd1","router2":"passw0rd1","router3":"passw0rd1"}
print credentials
def combined():
devices()
security()
if __name__ == "__main__":
print "The routers are:"
devices()
print "The credentials are:"
security()
print "All data is:"
combined()
| Connected interface | 0 |
| Static route | 1 |
| Enhanced Interior Gateway Routing Protocol (EIGRP) summary route | 5 |
| External Border Gateway Protocol (BGP) | 20 |
| Internal EIGRP | 90 |
| IGRP | 100 |
| OSPF | 110 |
| Intermediate System-to-Intermediate System (IS-IS) | 115 |
| Routing Information Protocol (RIP) | 120 |
| Exterior Gateway Protocol (EGP) | 140 |
| On Demand Routing (ODR) | 160 |
| External EIGRP | 170 |
| Internal BGP | 200 |
| Unknown* | 255 |