阿尔哦覅和 发表于 2018-7-31 12:35:27

利用saltstack批量安装php

#注意:执行过程中可能会出现某个依赖包yum找不到的情况  
# salt 'node2.enzhi.com' state.sls php5.phpconfig
  
node2.enzhi.com:
  
----------
  
ID: php5installed
  
Function: pkg.installed
  
Name: freetype-devel
  
Result: True
  
Comment: Package freetype-devel is already installed.
  
Started: 17:40:51.398777
  
Duration: 866.709 ms
  
Changes:
  
----------
  
ID: php5installed
  
Function: pkg.installed
  
Name: freetds-devel
  
Result: True
  
Comment: Package freetds-devel is already installed.
  
Started: 17:40:52.265671
  
Duration: 0.596 ms
  
Changes:
  
----------
  
ID: php5installed
  
Function: pkg.installed
  
Name: libxml
  
Result: False
  
Comment: The following package(s) were not found, and no possible matches were found in the package db: libxml
  
Started: 17:40:52.266356
  
Duration: 4081.753 ms
  
Changes:
  
----------
  
ID: php5installed
  
Function: pkg.installed
  
Name: gd
  
Result: True
  
Comment: Package gd is already installed.
  
Started: 17:40:56.348335
  
Duration: 0.776 ms
  
Changes:
  
----------
  
ID: php5installed
  
Function: pkg.installed
  
Name: curl
  
Result: True
  
Comment: Package curl is already installed.
  
Started: 17:40:56.349210
  
Duration: 0.423 ms
  
Changes:
  
----------
  
ID: php5installed
  
Function: pkg.installed
  
Name: bzip2
  
Result: True
  
Comment: Package bzip2 is already installed.
  
Started: 17:40:56.349721
  
Duration: 0.429 ms
  
Changes:
  
----------
  
ID: php5installed
  
Function: pkg.installed
  
Name: bzip2-devel
  
Result: True
  
Comment: Package bzip2-devel is already installed.
  
Started: 17:40:56.350236
  
Duration: 0.451 ms
  
Changes:
  
----------
  
ID: php5installed
  
Function: pkg.installed
  
Name: openssl-devel
  
Result: True
  
Comment: Package openssl-devel is already installed.
  
Started: 17:40:56.350774
  
Duration: 0.423 ms
  
Changes:
  
----------
  
ID: php5installed
  
Function: pkg.installed
  
Name: libpng
  
Result: True
  
Comment: Package libpng is already installed.
  
Started: 17:40:56.351277
  
Duration: 0.422 ms
  
Changes:
  
----------
  
ID: php5installed
  
Function: pkg.installed
  
Name: freetds
  
Result: True
  
Comment: Package freetds is already installed.
  
Started: 17:40:56.351788
  
Duration: 0.418 ms
  
Changes:
  
----------
  
ID: php5installed
  
Function: pkg.installed
  
Name: libmcrypt-devel
  
Result: True
  
Comment: Package libmcrypt-devel is already installed.
  
Started: 17:40:56.352298
  
Duration: 0.449 ms
  
Changes:
  
----------
  
ID: php5installed
  
Function: pkg.installed
  
Name: freetype
  
Result: True
  
Comment: Package freetype is already installed.
  
Started: 17:40:56.352828
  
Duration: 0.629 ms
  
Changes:
  
----------
  
ID: php5installed
  
Function: pkg.installed
  
Name: gd-devel
  
Result: True
  
Comment: Package gd-devel is already installed.
  
Started: 17:40:56.353584
  
Duration: 0.423 ms
  
Changes:
  
----------
  
ID: php5installed
  
Function: pkg.installed
  
Name: libxslt-devel
  
Result: True
  
Comment: Package libxslt-devel is already installed.
  
Started: 17:40:56.354170
  
Duration: 0.442 ms
  
Changes:
  
----------
  
ID: php5installed
  
Function: pkg.installed
  
Name: curl-devel
  
Result: False
  
Comment: Package 'curl-devel' not found (possible matches: libcurl-devel, libcurl-devel.i686)
  
Started: 17:40:56.354712
  
Duration: 3452.342 ms
  
Changes:
  
----------
  
ID: php5installed
  
Function: pkg.installed
  
Name: zlib-devel
  
Result: True
  
Comment: Package zlib-devel is already installed.
  
Started: 17:40:59.807254
  
Duration: 0.687 ms
  
Changes:
  
----------
  
ID: php5installed
  
Function: pkg.installed
  
Name: libjpeg-devel
  
Result: False
  
Comment: Package 'libjpeg-devel' not found (possible matches: libjpeg-turbo-devel, libjpeg-turbo-devel.i686)
  
Started: 17:40:59.808032
  
Duration: 816.712 ms
  
Changes:
  
----------
  
ID: php5installed
  
Function: pkg.installed
  
Name: libjpeg
  
Result: False
  
Comment: Package 'libjpeg' not found (possible matches: libjpeg-turbo, libjpeg-turbo.i686)
  
Started: 17:41:00.624993
  
Duration: 1262.685 ms
  
Changes:
  
----------
  
ID: php5installed
  
Function: pkg.installed
  
Name: libxml2-devel
  
Result: True
  
Comment: Package libxml2-devel is already installed.
  
Started: 17:41:01.887927
  
Duration: 0.662 ms
  
Changes:
  
----------
  
ID: php5installed
  
Function: pkg.installed
  
Name: zlib
  
Result: True
  
Comment: Package zlib is already installed.
  
Started: 17:41:01.888682
  
Duration: 0.532 ms
  
Changes:
  
----------
  
ID: php5installed
  
Function: pkg.installed
  
Name: libiconv
  
Result: False
  
Comment: The following package(s) were not found, and no possible matches were found in the package db: libiconv
  
Started: 17:41:01.889304
  
Duration: 945.379 ms
  
Changes:
  
----------
  
ID: php5installed
  
Function: pkg.installed
  
Name: libmcrypt
  
Result: True
  
Comment: Package libmcrypt is already installed.
  
Started: 17:41:02.834894
  
Duration: 0.755 ms
  
Changes:
  
----------
  
ID: php5installed
  
Function: pkg.installed
  
Name: php-mssql
  
Result: True
  
Comment: Package php-mssql is already installed.
  
Started: 17:41:02.835757
  
Duration: 0.437 ms
  
Changes:
  
----------
  
ID: php5installed
  
Function: pkg.installed
  
Name: libpng-devel
  
Result: True
  
Comment: Package libpng-devel is already installed.
  
Started: 17:41:02.836280
  
Duration: 0.425 ms
  
Changes:
  
----------
  
ID: phpinstalled
  
Function: file.managed
  
Name: /home/wangenzhi/tools/php-5.6.21.tar.xz
  
Result: True
  
Comment: File /home/wangenzhi/tools/php-5.6.21.tar.xz is in the correct state
  
Started: 17:41:02.839835
  
Duration: 72.475 ms
  
Changes:
  
----------
  
ID: phpinstalled
  
Function: cmd.run
  
Name: cd /home/wangenzhi/tools/ && tar xf php-5.6.21.tar.xz && cd php-5.6.21/ && ./configure --prefix=/usr/local/php --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml--enable-sockets --enable-zip --enable-soap --enable-short-tags --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization--enable-fpm --with-mcrypt--with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2--with-gd --enable-gd-native-ttf --enable-maintainer-zts && make && make install
  
Result: True
  
Comment: unless execution succeeded
  
Started: 17:41:02.913239
  
Duration: 7.166 ms
  
Changes:
  
----------
  
ID: phpini
  
Function: file.managed
  
Name: /etc/php.ini
  
Result: True
  
Comment: File /etc/php.ini updated
  
Started: 17:41:02.921572
  
Duration: 27.204 ms
  
Changes:
  
----------
  
diff:
  
---
  
+++
  
@@ -5,10 +5,6 @@
  
   ;;;;;;;;;;;;;;;;;;;
  
   ; PHP's initialization file, generally called php.ini, is responsible for
  
   ; configuring many of the aspects of PHP's behavior.
  
-; hehe
  
-; hehe
  
-; haha
  
-; hehe
  

  
   ; PHP attempts to find and load this configuration from a number of locations.
  
   ; The following is a summary of its search order:
  
----------
  
ID: phpfpmconf
  
Function: file.managed
  
Name: /usr/local/php/etc/php-fpm.conf
  
Result: True
  
Comment: File /usr/local/php/etc/php-fpm.conf is in the correct state
  
Started: 17:41:02.948910
  
Duration: 3.481 ms
  
Changes:
  
----------
  
ID: php-fpm
  
Function: file.managed
  
Name: /etc/rc.d/init.d/php-fpm
  
Result: True
  
Comment: File /etc/rc.d/init.d/php-fpm is in the correct state
  
Started: 17:41:02.952524
  
Duration: 4.373 ms
  
Changes:
  
----------
  
ID: php-fpm
  
Function: cmd.run
  
Name: chkconfig --add php-fpm && chkconfig php-fpm on
  
Result: True
  
Comment: unless execution succeeded
  
Started: 17:41:02.957028
  
Duration: 25.414 ms
  
Changes:
  
----------
  
ID: php-service
  
Function: cmd.run
  
Name: /etc/init.d/php-fpm restart
  
Result: True
  
Comment: Command "/etc/init.d/php-fpm restart" run
  
Started: 17:41:02.982731
  
Duration: 1075.021 ms
  
Changes:
  
----------
  
pid:
  
73614
  
retcode:
  
0
  
stderr:
  
stdout:
  
Gracefully shutting down php-fpm . done   #可以看到重启php-fpm
  
Starting php-fpmdone
  

  
Summary
  
-------------
  
Succeeded: 26 (changed=2)
  
Failed: 5
  
-------------
  
Total states run: 31
  
#在minion端查看php-fpm端口是否在监听
  
# ss -tnl
  
LISTEN      0      16384                            127.0.0.1:9000
页: [1]
查看完整版本: 利用saltstack批量安装php