• SaltStack 实践课程二 PHP+NGINX


    1.查看file_roots

    file_roots:
      base:
        - /srv/salt/
      dev:
        - /srv/salt/dev/
      prod:
        - /srv/salt/prod/

    2.目录结构如下

    [root@saltstack1 prod]# pwd
    /srv/salt/prod
    [root@saltstack1 prod]# tree 
    .
    |-- nginx
    |   `-- files
    |       `-- nginx-1.9.15.tar.gz
    |-- pcre
    |   |-- files
    |   |   `-- pcre-8.38.tar.gz
    |   `-- install.sls
    `-- php
        `-- files
            `-- php-7.0.6.tar.gz

    3.在/srv/salt/prod/pcre/目录下面新建文件install.sls

    pcre-source-install:
      file.managed:
        - name: /usr/local/src/pcre-8.38.tar.gz
        - source: salt://pcre/files/pcre-8.38.tar.gz
        - user: root
        - group: root
        - mode: 755
      cmd.run:
        - name: cd /usr/local/src && tar zxf pcre-8.38.tar.gz && cd pcre-8.38 && ./configure --prefix=/usr/local/pcre && make && make install
        - unless: test -d /usr/local/pcre 
        - require:
          - file: pcre-source-install

    4.执行安装命令

    [root@saltstack1 pcre]# salt 'saltstack1' state.sls pcre.install env=prod
    saltstack1:
    ----------
              ID: pcre-source-install
        Function: file.managed
            Name: /usr/local/src/pcre-8.38.tar.gz
          Result: True
         Comment: File /usr/local/src/pcre-8.38.tar.gz is in the correct state
         Started: 16:10:24.148959
        Duration: 41.8 ms
         Changes:   
    ----------
              ID: pcre-source-install
        Function: cmd.run
            Name: cd /usr/local/src && tar zxf pcre-8.38.tar.gz && cd pcre-8.38 && ./configure --prefix=/usr/local/pcre && make && make install
          Result: True
         Comment: unless execution succeeded
         Started: 16:10:24.192646
        Duration: 8.637 ms
         Changes:   
    
    Summary for saltstack1
    ------------
    Succeeded: 2
    Failed:    0
    ------------
    Total states run:     2

     5.安装nginx源码,在/srv/salt/prod/nginx/目录下新建install.sls文件

    include:
    - pcre.install
    nginx-source-install:
    file.managed:
    - name: /usr/local/src/nginx-1.9.15.tar.gz
    - source: salt://nginx/files/nginx-1.9.15.tar.gz
    - user: root
    - group: root
    - mode: 755
    cmd.run:
    - name: cd /usr/local/src/ && tar zxf nginx-1.9.15.tar.gz && cd nginx-1.9.15 && ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --with-file-aio --with-http_dav_module --with-pcre=/usr/local/src/pcre-8.38 && make && make install
    - unless: test -d /usr/local/nginx
    - require:
    - file: nginx-source-install
    - cmd: pcre-source-install

  • 相关阅读:
    第一章 经济基础知识
    105_实例
    SQL开窗函数
    Docker教程:Docker入门实践
    102_HDFS分布式文件系统
    [转]远程连接出现身份验证错误,要求的函数不受支持
    flutter创建工程指定iOS及Android开发语言
    架构师学习之路:康威定律
    智能识别客户收货地址信息
    深入理解Apache Dubbo与实战 pdf
  • 原文地址:https://www.cnblogs.com/python-study/p/5508813.html
Copyright © 2020-2023  润新知