$FHHOME/fabfile/nginx.py
$ fab -l |grep nginx
$ H=test-server-1,test-server-2 $ fab -H $H nginx.install_yum
$ 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"
$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/")