[Up]常用資訊

[重點文章] 重點文章 [重點文章] 重點文章

2020年8月25日 星期二

[Debian] Debian 升級 ansible

[Debian] Debian 升級 ansible

 
#Step 01 – 更新 ansible


編輯“ /etc/apt/sources.list”並添加以下內容。包的來源在此文件中輸入。
	
deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main

如果出現錯誤

似乎有必要先添加“ GNU Privacy Guard”。

apt install gnupg2

安裝gnupg2並運行命令以再次添加密鑰。

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
Executing: /tmp/apt-key-gpghome.YHaULyMFz7/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
gpg: key 93C4A3FD7BB9C367: public key "Launchpad PPA for Ansible, Inc." imported
gpg: Total number processed: 1
gpg:               imported: 1


進行安裝

apt upgrade ansible

$ ansible --version
ansible 2.9.9

以防萬一,清理不必要的包裝。

apt autoremove

ansible-playbook -i hosts test-task.yml


這次,我從默認源軟件包安裝並更新了Ansible。首先設置源程序包,然後安裝它以獲取最新版本。

像這次的Ansible一樣,如果從默認源軟件包安裝,則該版本通常較舊。如果要使用最新版本,則需要參考官方網站上的文檔以及其他網站上的信息,然後進行相應安裝。

 
#Step 02 –jenkins 刪除 大量job

import jenkins.model.*

def matchedJobs = Jenkins.instance.items.findAll { job ->
    job.name =~ /033-1/
}
    
matchedJobs.each { job ->
    println job.name
    job.delete()
}
 
#Step 03 –建立node

#
# python create_node.py 10.1.1.4 10.1.10.10,10.1.10.11,10.1.10.12
#
from f5.bigip import ManagementRoot
import pprint
import argparse
pp = pprint.PrettyPrinter(indent=3)

parser = argparse.ArgumentParser(description='Script to create a pool on a BIG-IP device')
parser.add_argument("host", help="The IP/Hostname of the BIG-IP device")
#parser.add_argument("pool_name", help="The name of the pool")
parser.add_argument("node_adds", help="A comma seperated string in the format :[,:]")
parser.add_argument("-P", "--partition", help="The partition name", default="Common")
parser.add_argument("-u", "--username", help="The BIG-IP username", default="admin")
parser.add_argument("-p", "--password", help="The BIG-IP password", default="admin")
args = parser.parse_args()

mgmt = ManagementRoot(args.host, args.username, args.password)

#pool_path = "/%s/%s" % (args.partition, args.pool_name)

node_list = args.node_adds.split(',')

for node in node_list:
    nodes = mgmt.tm.ltm.nodes.node.create(name="node_%s" % node, address=node, partition='Common')
    print (" Added node %s" % node)

 
#Step 04 –

#
#
#  python create_pool.py 10.1.1.4 test_pool 10.1.10.10:80,10.1.10.11:80
#
#
from f5.bigip import ManagementRoot
import pprint
import argparse
pp = pprint.PrettyPrinter(indent=3)

parser = argparse.ArgumentParser(description='Script to create a pool on a BIG-IP device')
parser.add_argument("host", help="The IP/Hostname of the BIG-IP device")
parser.add_argument("pool_name", help="The name of the pool")
parser.add_argument("pool_members", help="A comma seperated string in the format :[,:]")
parser.add_argument("-P", "--partition", help="The partition name", default="Common")
parser.add_argument("-u", "--username", help="The BIG-IP username", default="admin")
parser.add_argument("-p", "--password", help="The BIG-IP password", default="admin")
args = parser.parse_args()

mgmt = ManagementRoot(args.host, args.username, args.password)

pool_path = "/%s/%s" % (args.partition, args.pool_name)

pool = mgmt.tm.ltm.pools.pool.create(partition=args.partition, name=args.pool_name)
print ("Created pool %s" % pool_path)

member_list = args.pool_members.split(',')

for member in member_list:
    pool_member = pool.members_s.members.create(partition=args.partition, name=member)
    print (" Added member %s" % member)


 
#Step 05 – 同時建立node 並加入 pool

#
#  python create_pool.py 10.1.1.4 test_pool 10.1.10.10,10.1.10.11 80
# python create_node_pool1.py 10.1.1.4 test_pool_333 192.168.33.11,192.168.33.12,192.168.33.13,192.168.33.14,192.168.33.15 80
#
#
from f5.bigip import ManagementRoot
import pprint
import argparse
pp = pprint.PrettyPrinter(indent=3)

parser = argparse.ArgumentParser(description='Script to create a pool on a BIG-IP device')
parser.add_argument("host", help="The IP/Hostname of the BIG-IP device")
parser.add_argument("pool_name", help="The name of the pool")
parser.add_argument("node_adds", help="A comma seperated string in the format :[,:]")
parser.add_argument("service", help="Pool port service :[,:]")
parser.add_argument("-P", "--partition", help="The partition name", default="Common")
parser.add_argument("-u", "--username", help="The BIG-IP username", default="admin")
parser.add_argument("-p", "--password", help="The BIG-IP password", default="admin")
args = parser.parse_args()

mgmt = ManagementRoot(args.host, args.username, args.password)

#pool_path = "/%s/%s" % (args.partition, args.pool_name)
pool_path = "/%s/%s" % (args.partition, args.pool_name)

pool = mgmt.tm.ltm.pools.pool.create(partition=args.partition, name=args.pool_name)
print ("Created pool %s" % pool_path)

node_list = args.node_adds.split(',')

for node in node_list:
    nodes = mgmt.tm.ltm.nodes.node.create(name="node_%s" % node, address=node, partition='Common')
    print (" Added node %s" % node)

#
print ("\nCreated pool member %s" % pool_path)
for member in node_list:
    pool_member = pool.members_s.members.create(partition=args.partition, name="node_%s:%s" % (member, args.service))
    print(" Added member %s:%s" % (member, args.service))


 
#Step 06 –同時建立node 並加入 pool 含 LB 模式和監控

#
#  python create_pool.py 10.1.1.4 test_pool 10.1.10.10,10.1.10.11 80
# python create_node_pool1.py 10.1.1.4 test_pool_333 192.168.33.11,192.168.33.12,192.168.33.13,192.168.33.14,192.168.33.15 80
#
#
from f5.bigip import ManagementRoot
import pprint
import argparse
import time
pp = pprint.PrettyPrinter(indent=3)

parser = argparse.ArgumentParser(description='Script to create a pool on a BIG-IP device')
parser.add_argument("host", help="The IP/Hostname of the BIG-IP device")
parser.add_argument("pool_name", help="The name of the pool")
parser.add_argument("node_adds", help="A comma seperated string in the format :[,:]")
parser.add_argument("service", help="Pool port service :[,:]")
parser.add_argument("-P", "--partition", help="The partition name", default="Common")
parser.add_argument("-u", "--username", help="The BIG-IP username", default="admin")
parser.add_argument("-p", "--password", help="The BIG-IP password", default="admin")
args = parser.parse_args()

mgmt = ManagementRoot(args.host, args.username, args.password)
print ("Start : %s" % time.ctime())
#pool_path = "/%s/%s" % (args.partition, args.pool_name)
pool_path = "/%s/%s" % (args.partition, args.pool_name)

pool = mgmt.tm.ltm.pools.pool.create(partition=args.partition, name=args.pool_name)
#
print ("Created pool %s" % pool_path)
#
#pool_a = mgmt.tm.ltm.pools.pool.load(partition=args.partition, name=args.pool_name)
#pool_a.loadBalancingMode = "least-connections-member"
#pool_a.minUpMembers = 1
#pool_a.description = "New description"
#pool_a.update()

#print ("Created pool LB")

node_list = args.node_adds.split(',')
#
print ("\nCreated node For %s Pool" % pool_path)
#
for node in node_list:
    nodes = mgmt.tm.ltm.nodes.node.create(name="node_%s" % node, address=node, partition='Common')
    print (" Create node %s" % node)

#
print ("\nCreated pool member %s" % pool_path)
for member in node_list:
    pool_member = pool.members_s.members.create(partition=args.partition, name="node_%s:%s" % (member, args.service))
    print(" Added member %s:%s" % (member, args.service))

#
time.sleep( 5 )
#
pool_a = mgmt.tm.ltm.pools.pool.load(partition=args.partition, name=args.pool_name)
pool_a.loadBalancingMode = "least-connections-member"
pool_a.monitor = "http"
pool_a.minUpMembers = 1
pool_a.description = "New description"
pool_a.update()
print ("\n設定 負載平衡方式 : least-connections-members")
print ("End : %s" % time.ctime())

 
#Step 07 –建立 Standard Virtual server

#
#  python create_pool.py 10.1.1.4 test_pool 10.1.10.10,10.1.10.11 80
# python create_node_pool1.py 10.1.1.4 test_pool_333 192.168.33.11,192.168.33.12,192.168.33.13,192.168.33.14,192.168.33.15 80
#
# python create_node_pool1.py 10.1.1.4 test_pool_333 192.168.33.11,192.168.33.12,192.168.33.13,192.168.33.14,192.168.33.15 80
#
# 建立 Standard Virtual server
# python create_node_pool_vs1_Standard.py 10.1.1.4 10.100.10.10 192.168.33.11,192.168.33.12,192.168.33.13,192.168.33.14,192.168.33.15 80
#
from f5.bigip import ManagementRoot
import pprint
import argparse
import time
pp = pprint.PrettyPrinter(indent=3)

parser = argparse.ArgumentParser(description='Script to create a pool on a BIG-IP device')
parser.add_argument("host", help="The IP/Hostname of the BIG-IP device")
parser.add_argument("VIP_name", help="The name of the VIP")
#parser.add_argument("pool_name", help="The name of the pool")
parser.add_argument("node_adds", help="A comma seperated string in the format :[,:]")
parser.add_argument("service", help="Pool port service :[,:]")
parser.add_argument("-P", "--partition", help="The partition name", default="Common")
parser.add_argument("-u", "--username", help="The BIG-IP username", default="admin")
parser.add_argument("-p", "--password", help="The BIG-IP password", default="admin")
args = parser.parse_args()

mgmt = ManagementRoot(args.host, args.username, args.password)
print ("Start : %s" % time.ctime())
#pool_path = "/%s/%s" % (args.partition, args.pool_name)
VIP_vs_n = "vs_%s" % args.VIP_name
Pool_vs_n = "pool_%s_%s" % (args.service, args.VIP_name)
#
#pool_path = "/%s/%s" % (args.partition, args.pool_name)
pool_path = "/%s/%s" % (args.partition, Pool_vs_n)

#pool = mgmt.tm.ltm.pools.pool.create(partition=args.partition, name=args.pool_name)
pool = mgmt.tm.ltm.pools.pool.create(partition=args.partition, name=Pool_vs_n)
#
print ("Created pool %s" % pool_path)
#

#print ("Created pool LB")

node_list = args.node_adds.split(',')
#
print ("\nCreated node For %s Pool" % pool_path)
#
for node in node_list:
    nodes = mgmt.tm.ltm.nodes.node.create(name="node_%s" % node, address=node, partition='Common')
    print (" Create node %s" % node)

#
print ("\nCreated pool member %s" % pool_path)
for member in node_list:
    pool_member = pool.members_s.members.create(partition=args.partition, name="node_%s:%s" % (member, args.service))
    print(" Added member %s:%s" % (member, args.service))

#
time.sleep( 5 )
#
pool_a = mgmt.tm.ltm.pools.pool.load(partition=args.partition, name=Pool_vs_n)
pool_a.loadBalancingMode = "least-connections-member"
pool_a.monitor = "http"
pool_a.minUpMembers = 1
pool_a.description = "New description"
pool_a.update()
print ("\n設定 負載平衡方式 : least-connections-members")
print ("End : %s" % time.ctime())
###############################################################
#
################################################################
params = {'name': "vs_%s_%s" % (args.VIP_name, args.service),
          'partition': 'Common',
          'destination': "%s:%s" % (args.VIP_name, args.service),
          'mask': '255.255.255.255',
          'source': '0.0.0.0/0',
          'pool': Pool_vs_n,
          'profiles': [
              {'name': 'http'},
              {'name': 'tcp'}
          ]
}

try:
    vs = mgmt.tm.ltm.virtuals.virtual.create(**params)
    print(vs.raw)
except Exception as e:
    print(params['name'] + ' failed. ' + str(e))

 
#Step 08 – 建立 performance-l4 Virtual server

#
#  python create_pool.py 10.1.1.4 test_pool 10.1.10.10,10.1.10.11 80
# python create_node_pool1.py 10.1.1.4 test_pool_333 192.168.33.11,192.168.33.12,192.168.33.13,192.168.33.14,192.168.33.15 80
#
# 建立 performance-l4 Virtual server
# python create_node_pool_vs1_L4.py 10.1.1.4 10.100.10.10 192.168.33.11,192.168.33.12,192.168.33.13,192.168.33.14,192.168.33.15 80
#
#
from f5.bigip import ManagementRoot
import pprint
import argparse
import time
pp = pprint.PrettyPrinter(indent=3)

parser = argparse.ArgumentParser(description='Script to create a pool on a BIG-IP device')
parser.add_argument("host", help="The IP/Hostname of the BIG-IP device")
parser.add_argument("VIP_name", help="The name of the VIP")
#parser.add_argument("pool_name", help="The name of the pool")
parser.add_argument("node_adds", help="A comma seperated string in the format :[,:]")
parser.add_argument("service", help="Pool port service :[,:]")
parser.add_argument("-P", "--partition", help="The partition name", default="Common")
parser.add_argument("-u", "--username", help="The BIG-IP username", default="admin")
parser.add_argument("-p", "--password", help="The BIG-IP password", default="admin")
args = parser.parse_args()

mgmt = ManagementRoot(args.host, args.username, args.password)
print ("Start : %s" % time.ctime())
#pool_path = "/%s/%s" % (args.partition, args.pool_name)
VIP_vs_n = "vs_%s" % args.VIP_name
Pool_vs_n = "pool_%s_%s" % (args.service, args.VIP_name)
#
#pool_path = "/%s/%s" % (args.partition, args.pool_name)
pool_path = "/%s/%s" % (args.partition, Pool_vs_n)

#pool = mgmt.tm.ltm.pools.pool.create(partition=args.partition, name=args.pool_name)
pool = mgmt.tm.ltm.pools.pool.create(partition=args.partition, name=Pool_vs_n)
#
print ("Created pool %s" % pool_path)
#

#print ("Created pool LB")

node_list = args.node_adds.split(',')
#
print ("\nCreated node For %s Pool" % pool_path)
#
for node in node_list:
    nodes = mgmt.tm.ltm.nodes.node.create(name="node_%s" % node, address=node, partition='Common')
    print (" Create node %s" % node)

#
print ("\nCreated pool member %s" % pool_path)
for member in node_list:
    pool_member = pool.members_s.members.create(partition=args.partition, name="node_%s:%s" % (member, args.service))
    print(" Added member %s:%s" % (member, args.service))

#
time.sleep( 5 )
#
pool_a = mgmt.tm.ltm.pools.pool.load(partition=args.partition, name=Pool_vs_n)
pool_a.loadBalancingMode = "least-connections-member"
pool_a.monitor = "http"
pool_a.minUpMembers = 1
pool_a.description = "New description"
pool_a.update()
print ("\n設定 負載平衡方式 : least-connections-members")
print ("End : %s" % time.ctime())
###############################################################
#
################################################################
params = {'name': "vs_%s_%s" % (args.VIP_name, args.service),
          'partition': 'Common',
          'destination': "%s:%s" % (args.VIP_name, args.service),
          'mask': '255.255.255.255',
          'source': '0.0.0.0/0',
          'pool': Pool_vs_n,
          'profiles': [
              {'name': 'fastL4'}
          ],
          'ipProtocol': 'tcp',
          'vlansEnabled': True,
          'vlans': ['/Common/MGMT']
}

try:
    vs = mgmt.tm.ltm.virtuals.virtual.create(**params)
    print(vs.raw)
except Exception as e:
    print(params['name'] + ' failed. ' + str(e))

 
#Step 09 –

[[inputs.snmp]]
  name_prefix = "exec1_"
  agents = [ "xxx.xxx.xxx.xxx", "xxx.xxx.xxx.xxx", "xxx.xxx.xxx.xxx", "xxx.xxx.xxx.xxx" , "xxx.xxx.xxx.xxx" , "xxx.xxx.xxx.xxx" ]
  version = 2
  community = "public"
  interval = "60s"
  timeout = "10s"
  retries = 3
  name = "F5_system"

  [[inputs.snmp.field]]
    name = "hostname"
    oid = "RFC1213-MIB::sysName.0"
    is_tag = true
  [[inputs.snmp.field]]
    name = "F5_uptime"
    oid = "1.3.6.1.4.1.3375.2.1.6.6.0"
  [[inputs.snmp.field]]
    name = "F5_httpRequests"
    oid = "1.3.6.1.4.1.3375.2.1.1.2.1.56.0"
  [[inputs.snmp.field]]
    name = "F5_client_connections"
    oid = "1.3.6.1.4.1.3375.2.1.1.2.1.8.0"
  [[inputs.snmp.field]]
    name = "F5_client_bytes_in"
    oid = "1.3.6.1.4.1.3375.2.1.1.2.1.60.0"
  [[inputs.snmp.field]]
    name = "F5_Total_Connections"
    oid = "1.3.6.1.4.1.3375.2.1.1.2.1.8.0"
  [[inputs.snmp.field]]
    name = "F5_New_Connects"
    oid = "1.3.6.1.4.1.3375.2.1.1.2.12.8.0"
  [[inputs.snmp.field]]
    name = "F5_New_Accepts"
    oid = "1.3.6.1.4.1.3375.2.1.1.2.12.6.0"

  [[inputs.snmp.field]]
    name = "F5_Device_status"
    oid = "F5-BIGIP-SYSTEM-MIB::sysCmFailoverStatusId.0"

 [[inputs.snmp.field]]
    name = "F5_Synchronization_status_color"
    oid = "F5-BIGIP-SYSTEM-MIB::sysCmSyncStatusColor.0"

 [[inputs.snmp.table]]
    name = "F5_CPU"
    oid = "F5-BIGIP-SYSTEM-MIB::sysMultiHostCpuTable"
    inherit_tags = [ "hostname" ]

 [[inputs.snmp.table]]
    name = "F5_Memory_Usage"
    oid = "F5-BIGIP-SYSTEM-MIB::sysMultiHostTable"
    inherit_tags = [ "hostname" ]

 [[inputs.snmp.table]]
   name = "F5_PoolStatus"
   oid = "F5-BIGIP-LOCAL-MIB::ltmPoolStatTable"
   inherit_tags = [ "hostname" ]

 [[inputs.snmp.table]]
   name = "F5_ClientSSLStatus"
   oid = "F5-BIGIP-LOCAL-MIB::ltmClientSslStatTable"
   inherit_tags = [ "hostname" ]

 [[inputs.snmp.table]]
   name = "F5_Fan"
   oid = "F5-BIGIP-SYSTEM-MIB::sysChassisFanTable"
   inherit_tags = [ "hostname" ]

 [[inputs.snmp.table]]
   name = "F5_Temperature"
   oid = "F5-BIGIP-SYSTEM-MIB::sysChassisTempTable"
   inherit_tags = [ "hostname" ]

 [[inputs.snmp.table]]
   name = "F5_VirtualStatus"
   oid = "F5-BIGIP-LOCAL-MIB::ltmVirtualServStatTable"
   inherit_tags = [ "hostname" ]

 [[inputs.snmp.table]]
    name = "F5_Nodes_Status"
    oid =  "F5-BIGIP-LOCAL-MIB::ltmNodeAddrStatTable"
    inherit_tags = [ "hostname" ]

 [[inputs.snmp.table]]
    name = "F5_Vlan_Status"
    oid =  "F5-BIGIP-SYSTEM-MIB::sysVlanStatTable"
    inherit_tags = [ "hostname" ]

 [[inputs.snmp.table]]
    name = "F5_DiskTable_Status"
    oid =  "F5-BIGIP-SYSTEM-MIB:sysHostDiskTable"
    inherit_tags = [ "hostname" ]

 [[inputs.snmp.table]]
    name = "F5_PoolMembers_Status"
    oid =  "F5-BIGIP-LOCAL-MIB::ltmPoolMemberStatTable"
    inherit_tags = [ "hostname" ]

 [[inputs.snmp.table]]
    name = "F5_PoolUpDowm_Status"
    oid =  "F5-BIGIP-LOCAL-MIB::ltmPoolMemberTable"
    inherit_tags = [ "hostname" ]

######################################################################################
# interface and vlan config Start
######################################################################################
  # IF-MIB::ifTable contains counters on input and output traffic as well as errors and discards.
  [[inputs.snmp.table]]
    name = "interface"
    inherit_tags = [ "hostname" ]
    oid = "IF-MIB::ifTable"

    # Interface tag - used to identify interface in metrics database
    [[inputs.snmp.table.field]]
      name = "ifDescr"
      oid = "IF-MIB::ifDescr"
      is_tag = true

  # IF-MIB::ifXTable contains newer High Capacity (HC) counters that do not overflow as fast for a few of the ifTable counters
  [[inputs.snmp.table]]
    name = "interface"
    inherit_tags = [ "hostname" ]
    oid = "IF-MIB::ifXTable"

    # Interface tag - used to identify interface in metrics database
    [[inputs.snmp.table.field]]
      name = "ifDescr"
      oid = "IF-MIB::ifDescr"
      is_tag = true

  # EtherLike-MIB::dot3StatsTable contains detailed ethernet-level information about what kind of errors have been logged on an interface (such as FCS error, frame too long, etc)
  [[inputs.snmp.table]]
    name = "interface"
    inherit_tags = [ "hostname" ]
    oid = "EtherLike-MIB::dot3StatsTable"

    # Interface tag - used to identify interface in metrics database
    [[inputs.snmp.table.field]]
      name = "ifDescr"
      oid = "IF-MIB::ifDescr"
      is_tag = true

######################################################################################
# interface and vlan config end
######################################################################################

# Output Plugin InfluxDB
[[outputs.influxdb]]
    namepass = ["exec1_*"]
    database = "telegraf01"
    urls = [ "http://127.0.0.1:8086" ]
    username = "admin01"
    password = "influxdb41yf3"
    retention_policy = ""

 
#Step 10 –

#!/usr/bin/python
#
#  python create_pool.py 10.1.1.4 test_pool 10.1.10.10,10.1.10.11 80
# python create_node_pool1.py 10.1.1.4 test_pool_333 192.168.33.11,192.168.33.12,192.168.33.13,192.168.33.14,192.168.33.15 80
#
# 建立 performance-l4 Virtual server
# python create_node_pool_vs1_L4.py 10.1.1.4 10.100.10.10 192.168.33.11,192.168.33.12,192.168.33.13,192.168.33.14,192.168.33.15 80,443,21,9988,8080 Tick_numbers
#
#
from f5.bigip import ManagementRoot
import pprint
import argparse
import time
pp = pprint.PrettyPrinter(indent=3)

parser = argparse.ArgumentParser(description='Script to create a pool on a BIG-IP device')
parser.add_argument("host", help="The IP/Hostname of the BIG-IP device")
parser.add_argument("VIP_name", help="The name of the VIP")
#parser.add_argument("pool_name", help="The name of the pool")
parser.add_argument("node_adds", help="A comma seperated string in the format :[,:]")
parser.add_argument("service", help="Pool port service :[,:]")
parser.add_argument("order_tick_num", help="order_tick_nmuber")
parser.add_argument("-P", "--partition", help="The partition name", default="Common")
parser.add_argument("-u", "--username", help="The BIG-IP username", default="admin")
parser.add_argument("-p", "--password", help="The BIG-IP password", default="admin")
args = parser.parse_args()

mgmt = ManagementRoot(args.host, args.username, args.password)
print ("Start : %s" % time.ctime())
#pool_path = "/%s/%s" % (args.partition, args.pool_name)
VIP_vs_n = "vs_%s" % args.VIP_name
################################################################
# 建立pool name
################################################################
service_list = args.service.split(',')
#
for serviceport in service_list:
    Pool_vs_n = "pool_%s_%s" % (serviceport, args.VIP_name)
    #
    #
    pool_path = "/%s/%s" % (args.partition, Pool_vs_n)
    #
    pool = mgmt.tm.ltm.pools.pool.create(partition=args.partition, name=Pool_vs_n)
    #
    print ("Created pool %s" % pool_path)
#

#print ("Created pool LB")

node_list = args.node_adds.split(',')
#
print ("\nCreated node For %s Pool" % pool_path)
#
for node in node_list:
    nodes = mgmt.tm.ltm.nodes.node.create(name="node_%s" % node, address=node, partition='Common')
    print (" Create node %s" % node)

#
################################################################
# 設定 pool 加入 poolmember
#################################################################
for serviceport2 in service_list:
    print ("\nCreated pool member /Common/pool_%s_%s" % (serviceport2, args.VIP_name))
    for member in node_list:
        poola = mgmt.tm.ltm.pools.pool.load(name="pool_%s_%s" % (serviceport2, args.VIP_name))
        pool_member = poola.members_s.members.create(partition=args.partition, name="node_%s:%s" % (member, serviceport2))
        #pool_member = pool.members_s.members.create(partition=args.partition, name="node_%s:%s" % (member, serviceport2))
        print(" Added member %s:%s" % (member, serviceport2))
#
#
#
################################################################
# 更新 pool 設定
#################################################################
#time.sleep( 5 )
for serviceport3 in service_list:
    print ("\n/Common/pool_%s_%s" % (serviceport3, args.VIP_name))
    pool_a = mgmt.tm.ltm.pools.pool.load(partition=args.partition, name="pool_%s_%s" % (serviceport3, args.VIP_name))
    pool_a.loadBalancingMode = "least-connections-member"
    pool_a.monitor = "http"
    pool_a.minUpMembers = 1
    pool_a.description = "%s" % (args.order_tick_num)
    pool_a.update()
    print ("\n設定 負載平衡方式 : least-connections-members")

#
print ("End 1: %s" % time.ctime())
################################################################
# 建立 Virtual Server 
#################################################################
for serviceport4 in service_list:
    pool_vs = "pool_%s_%s" % (serviceport4, args.VIP_name)
    params = {'name': "vs_%s_%s" % (args.VIP_name, serviceport4),
              'partition': 'Common',
              'destination': "%s:%s" % (args.VIP_name, serviceport4),
              'mask': '255.255.255.255',
              'description': args.order_tick_num,
              'source': '0.0.0.0/0',
              'pool': pool_vs,
              'profiles': [
                  {'name': 'fastL4'}
              ],
              'ipProtocol': 'tcp',
              'vlansEnabled': True,
              'vlans': ['/Common/MGMT']
    }

    try:
        vs = mgmt.tm.ltm.virtuals.virtual.create(**params)
        print(vs.raw)
    except Exception as e:
        print(params['name'] + ' failed. ' + str(e))
    #d
print ("End 2: %s" % time.ctime())
 
#Step 11 –

linux 對 windows 更新NTP 時間
If on Debian/Ubuntu:

sudo apt-get install rdate

then:

sudo rdate -n xx.xxx.xxx.xxx or domian 

Some people use ntpdate, but it seems to have trouble to sync with Windows based server.

沒有留言:

張貼留言