$FHHOME/fabfile/php.py
$ fab -l |grep -F php.
$ fab -H $H php.install_yum
$ H=test-server-1,test-server-2 $ fab -H $H -- "php -v"
$FHHOME/fabfile/php.py
import sys from fabric.api import * from fabric.contrib import files #---------------------------------------------------------------------- # Check PHP #---------------------------------------------------------------------- # php.check_php_rpm @task def check_php_rpm(): '''rpm -q php''' run("rpm -q php") run("php --version") #---------------------------------------------------------------------- # Installing PHP #---------------------------------------------------------------------- # php.install_yum @task def install_yum(): sudo("rpm -q php > /dev/null 2>&1 || yum -y install php") sudo("rpm -q php-mbstrig > /dev/null 2>&1 || yum -y install php-mbstrig") # php.install_phpfpm_yum @task def install_phpfpm_yum(): sudo("yum -y install php-cli php-mbstring php-fpm") ## CentOS7 ## @task def install_php5.6_centos7(): sudo("rpm -q remi-release-7 > /dev/null 2>&1 || rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm") sudo("yum install --enablerepo=remi,remi-php56 php php-devel php-mbstring php-pdo php-gd php-xml php-mcrypt") @task def install_php7.0_centos7(): sudo("rpm -q remi-release-7 > /dev/null 2>&1 || rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm") sudo("yum install --enablerepo=remi,remi-php70 php php-devel php-mbstring php-pdo php-gd php-xml php-mcrypt") @task def install_php7.1_centos7(): sudo("rpm -q remi-release-7 > /dev/null 2>&1 || rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm") sudo("yum install --enablerepo=remi,remi-php71 php php-devel php-mbstring php-pdo php-gd php-xml php-mcrypt") run("rpm -q php") run("php --version") ## CentOS6 ## @task def install_php5.6_centos6(): sudo("rpm -q remi-release-6 > /dev/null 2>&1 || rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm") sudo("yum install --enablerepo=remi,remi-php56 php php-devel php-mbstring php-pdo php-gd php-xml php-mcrypt") @task def install_php7.0_centos6(): sudo("rpm -q remi-release-6 > /dev/null 2>&1 || rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm") sudo("yum install --enablerepo=remi,remi-php70 php php-devel php-mbstring php-pdo php-gd php-xml php-mcrypt") @task def install_php7.1_centos6(): sudo("rpm -q remi-release-6 > /dev/null 2>&1 || rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm") sudo("yum install --enablerepo=remi,remi-php71 php php-devel php-mbstring php-pdo php-gd php-xml php-mcrypt") run("rpm -q php") run("php --version") #---------------------------------------------------------------------- # Installing composer #---------------------------------------------------------------------- @task def install_composer(): sudo("curl -sS https://getcomposer.org/installer | php") sudo("mv composer.phar /usr/local/bin/composer")