FastHandle - Automation Examples

FastHandle is fast operation tools for infrastructure configurations and tests.

User Tools

Site Tools


Top     SiteMap

Sidebar


Top     SiteMap

Manager Server

Target Server













.

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 auth.pro  nginx.install_yum


Fabric Temporary Run Call Examples

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

$ fab  -H $H auth.pro  -- sudo systemctl status nginx
$ fab  -H $H auth.pro  -- sudo systemctl restart nginx

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

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


nginx.py

$FHHOME/fabfile/nginx.py

import sys
from fabric.api import *
from fabric.contrib import files
 
#----------------------------------------------------------------------
# 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: 2018/02/21 23:50 by kurihara