包安装模块、文件维护模块、服务模块
zabbix_agent:
pkg.installed:
- name: zabbix22-agent
file.managed:
- name: /etc/zabbix_agentd.conf
- source: satl://init/file/zabbix_agentd.conf
- user: root
- group: root
- mode: 644
- template: jinja \\指定模板类型
- defaults:
Zabbix_Server: {{pillar['zabbix-agent']['Zabbix_Server']}} \\取Zabbix_Server的值
Zabbix_Server: 10.0.0.1 \\不使用pillar 直接指定值
'''
需要有一个pillar的sls文件
zabbix_agent:
Zabbix_Server: 10.0.0.1 指定Zabbix_Server的值
vim zabbix_agentd.conf
Server={{Zabbix_Server}} '''
service.running:
- name: zabbix-agentd \\服务名
- ebable: True \\开启自启
- reload: True \\注意检查是否支持重载
- watch:
- file: zabbix_agent \\如果这个文件变化则重载
PHP编译安装
pkg.init:
pkg.installed:
- names:
- lrzsz
- mtr
- nmap
- gcc
- bison
- bison-devel
- zlib-devel
- libmcrypt-devel
- mcrypt
- mhash-devel
- openssl-devel
- libxml2-devel
- libcurl-devel
- bzip2-devel
- readline-devel
- libedit-devel
include:
- init.pkg
www-user-group:
group.present:
- name: www
- gid: 1000
user.present:
- name: www
- fullname: www
- shell: /sbin/nologin
- uid: 1000
- gid: 1000
php-install:
file.managed:
- name: /usr/local/src/php-5.5.38.tar.gz
- source: salt://php/files/php-5.5.38.tar.gz
- user: root
- group: root
- mode: 644
cmd.run:
- name: cd /usr/local/src && tar zxf php-5.5.38.tar.gz && cd php-5.5.38 && ./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-opcache --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gettext --enable-mbstring --with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap --with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-zlib --enable-zip --with-bz2 --with-readline --without-sqlite3 --without-pdo-sqlite --with-pear && make && make install
- unless: test -d /usr/local/php
php-set:
cmd.run:
- name: cp -rf /usr/local/src/php-5.5.38/php.ini-development /etc/php.ini && cp -rf /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf && cp -rf /usr/local/src/php-5.5.38/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm && chmod +x /etc/init.d/php-fpm && echo '/etc/init.d/php-fpm start' >> /etc/rc.local && ln -fs /usr/local/php/sbin/php-fpm /sbin && ln -fs /usr/local/php/bin/* /bin/ && /etc/init.d/php-fpm start ##遇到错误最好把命令拆分执行,以便排错