iojsioi 发表于 2018-8-1 09:08:08

saltstack使用之二(完成部署编译nginx以及部分cp模块的使用)

# vim nginx.sls  
还是要注意格式
  
pcre-devel:                      #pcre-devel 我的从节点第一次安装出现了缺包的提示
  
    pkg.installed               #pkg.installed模块确保pcre-devel安装成功它要的是installed的状态
  
nginx_source:                  # nginx的源位置
  
file.managed:
  
    - name: /tmp/nginx-1.6.2.tar.gz          # 这个位置是我在主节点放置nginx的tar包的位置
  
    - unless: test -e /tmp/nginx-1.6.2.tar.gz   #为测试提供
  
    - source: salt://nginx/nginx-1.6.2.tar.gz      #这里注意相对路径是相对于你在主配置文件/srv/salt的位置源目录文件的位置
  
    - user: root
  
    - group: root
  
    - mode: 644
  
cmd.run:                                                            #cmd.run运行命令的模块为了运行下列的命令提供入口
  
    - cwd: /tmp       # 类似cdcd到/tmp目录下
  
    - name: tar zxvf nginx-1.6.2.tar.gz && cd /tmp/nginx-1.6.2 && ./configure --prefix=/usr/local/nginx --error-log-path=/home/wwwlogs/nginx/error.log --http-log-path=/home/wwwlogs/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_spdy_module --with-http_gzip_static_module --with-http_stub_status_module --http-client-body-temp-path=/usr/local/nginx/client/ --http-proxy-temp-path=/usr/local/nginx/proxy/ --http-fastcgi-temp-path=/usr/local/nginx/fcgi/ --http-uwsgi-temp-path=/usr/local/nginx/uwsgi --http-scgi-temp-path=/usr/local/nginx/scgi --with-pcre && make && cd /tmp/nginx-1.6.2 && make install                      #编译安装nginx
  
    - unless: test -d /tmp/nginx-1.6.2.tar.gz         # 如果使用cmd时候最好加上unless这个模块。
  
    - require:          # require 模块
  
      - file: nginx_source         # 需要nginx_source
  
nginx-conf:         #nginx-conf这个类
  
file.managed:         #管理文件需要
  
    - name: /usr/local/nginx/conf/nginx.conf      # 主配置文件
  
    - source: salt://nginx/nginx.conf                     #主节点nginx的主配置文件位置相对路径还是相对于/srv/salt
  
    - user: root
  
    - group: root
  
    - mode: 644
  
nginx-init:
  
file.managed:
  
    - name: /etc/init.d/nginx
  
    - source: salt://nginx/nginx-init.sh
  
    - user: root
  
    - group: root
  
    - mode: 755
页: [1]
查看完整版本: saltstack使用之二(完成部署编译nginx以及部分cp模块的使用)