Technical World: 2019

Thursday, September 12, 2019

Ansible Installation and basic commands

To install and setup Ansible on orable VM Box
sudo apt-get update
sudo apt-get install software-properties-common
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install ansible

/etc/ansible/hosts --> ansible host inventory and format
[group name 1]
ip address/hostname
[group name 2]
ip address/hostname

Basic commands
ansible all -m ping
ansible [group name] -m command -a "ls"  --> ping all hosts in group
ansible -i inventory all -m command -a 'iptables -F" --become--ask-become-pass   --> flush iptables rules for all hosts in inventory
ansible all -m setup  -->capture info of all hosts
ansible-doc setup  -->extract facts from documents setup

Monday, April 8, 2019

create f5 ltm virtual pool node using tmsh with input from csv

$inputCSV = "C:\path\ltm_input.csv"
$outputFile = "C:\path\ltm_output.txt"
$i=1
Import-Csv $inputCSV | ForEach-Object {

$policy = $_.policy
if ($i -eq 1)
{
 Add-Content -PassThru $outputFile -Value "modify ltm policy $policy create-draft"
 }
 $i++
}
Import-Csv $inputCSV | ForEach-Object {
 $vipportno = $_.vipportno
 $poolportno1 = $_.poolportno1
 $poolportno2 = $_.poolportno2
 $poolportno3 = $_.poolportno3
 $appname = $_.appname
 $nodeip1 = $_.nodeip1
 $nodeip2 = $_.nodeip2
 $nodeip3 = $_.nodeip3
 $vipip = $_.vipip
 $poolmember1 = $_.nodeip1 + ":"+ $_.poolportno1
 $poolmember2 = $_.nodeip2 + ":"+ $_.poolportno2
 $poolmember3 = $_.nodeip3 + ":"+ $_.poolportno3
 $fullappname = $_.vipip + ":" + $_.vipportno
 $vsname = $_.appname + "-" + $_.vipportno
 $url = $_.url
 $monitor = $_.monitor
 $persistance = $_.persistance
 $policy = $_.policy

 Add-Content -Path $outputFile -Value "create ltm node $nodeip1 fqdn { autopopulate enabled interval ttl name $nodeip1.company.com }"
 Add-Content -Path $outputFile -Value "create ltm node $nodeip2 fqdn { autopopulate enabled interval ttl name $nodeip2.company.com }"
 Add-Content -Path $outputFile -Value "create ltm node $nodeip3 fqdn { autopopulate enabled interval ttl name $nodeip3.company.com }"
 Add-Content -Path $outputFile -Value "create ltm pool pl-$appname members add { $poolmember1 $poolmember2 $poolmember3 } monitor $monitor"
 Add-Content -Path $outputFile -Value "create ltm virtual vs-$vsname destination $fullappname profiles add { wilcard-company company-program-http serverssl-insecure-compatible } pool pl-$appname description $url source-address-translation { pool Internal_SNAT } translate-address enabled vlans-enabled vlans add { External } persist replace-all-with { $persistance } source-address-translation { type snat }"
 Add-Content -Path $outputFile -Value "modify ltm policy /Common/Drafts/$policy rules add { rl-$appname { actions add { 0 { forward select virtual /Common/vs-$vsname } } conditions add { 0 { http-host host values {$url} } } description $url } }"
  }
 Add-Content -PassThru $outputFile -Value "publish ltm policy /Common/Drafts/$policy"
 Add-Content -PassThru $outputFile -Value "save sys config"
create a csv file named ltm-input.csv with columns as per the variables called
vipportno
appname
nodeip1
nodeip2
nodeip3
vipip
poolportno1
poolportno2
poolportno3
policy
persistance
monitor
url




















Thursday, March 28, 2019

create f5 vip pool node from tmsh shell


port-no
app-name
nodeip

rl-app-name                 app-name.company.com

create ltm node nodeip fqdn { autopopulate enabled interval ttl name nodeip }

create ltm pool pl-app-name members add { nodeip:443 } monitor mn-https

create ltm virtual vs-app-name-port-no destination 10.10.10.10:port-no profiles add { wilcard-company company-http serverssl-insecure-compatible } pool pl-app-name description app-name.company.com source-address-translation { pool Internal_SNAT } translate-address enabled vlans-enabled vlans add { External } persist replace-all-with { company-nisp-cookie } source-address-translation { type snat }

TIP: user find/replace to customize the command replacing the bold keywords