FastHandle - IT Operations Examples

FastHandle is fast operation tools for infrastructure configurations and tests.

User Tools

Site Tools


Sidebar


Top     SiteMap

Manager Server

Target Server

$FHHOME/bin/xxx.sh | xxxx.exp













.

middleware:nginx:index.html



Top#Middleware Management

Nginx (nginx.py)

Operation

$ fab -l |grep nginx

$ H=test-server-1,test-server-2
$ fab  -H $H   nginx.install_yum


Fabric Temporary Run Call Examples

$ H=test-server-1,test-server-2

$ fab  -H $H   -- sudo systemctl status nginx
$ fab  -H $H   -- sudo systemctl restart nginx

$ fab  -H $H   -- "nginx -t"
$ fab  -H $H   -- "nginx -t -c /etc/nginx/nginx.conf"

$ fab  -H $H   -- "ps aux |grep nginx"
$ fab  -H $H   -- "netstat -an |grep 80"


nginx.py

$FHHOME/fabfile/nginx.py

import sys
from fabric.api import *
from fabric.contrib import files
from datetime import datetime
 
#----------------------------------------------------------------------
# Installing Nginx
#----------------------------------------------------------------------
# nginx.install_yum
@task
def install_yum():
    sudo("rpm -q nginx        > /dev/null 2>&1 || yum -y install nginx")

# nginx.install_apt
@task
def install_apt():
    sudo("dpkg -l |grep nginx > /dev/null 2>&1 || apt update && apt install -y nginx")



#----------------------------------------------------------------------
# Check Configuration Files
#----------------------------------------------------------------------
# nginx.check_files_etc_nginx
@task
def check_nginx.conf():
    '''nginx -t'''
    sudo("nginx -t")

# nginx.check_files_etc_nginx
@task
def check_files_etc_nginx():
    '''tree -Dpuga  /etc/nginx'''
    run("tree -Dpuga  /etc/nginx")



#----------------------------------------------------------------------
# Check Header
#----------------------------------------------------------------------
@task
def check_header():
    '''curl -I http://localhost/'''
    run("curl -I http://localhost/")



Nginx Configuration Examples



middleware/nginx/index.html.txt ยท Last modified: 2019/02/11 00:45 by kurihara