随笔 - 118  文章 - 33 评论 - 1 阅读 - 64397
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

require依赖

复制代码
lamp-pkg-install:
  pkg.installed:
    - names:
      - php
      - php-cli
      - php-common
      - mysql
      - php-mysql
      - php-pdo

apache-service:
  pkg.installed:
    - name: httpd
  file.managed:
    - name: /etc/httpd/conf/httpd.conf
    - source: salt://files/httpd.conf
    - user: root
    - group: root
    - mode: 644
    - require:
      - pkg: apache-service   #文件管理依赖于pkg包的安装
  service.running:
    - name: httpd
    - enable: True

mysql-service:
  pkg.installed:
    - name: mysql-server
  file.managed:
    - name: /etc/my.cnf
    - source: salt://files/my.cnf
    - user: root
    - group: root
    - mode: 644
  service.running:
    - name: mysqld
    - enable: True
复制代码

require_in依赖

复制代码
lamp-pkg-install:
  pkg.installed:
    - names:
      - php
      - php-cli
      - php-common
      - mysql
      - php-mysql
      - php-pdo

apache-service:
  pkg.installed:
    - name: httpd
  file.managed:
    - name: /etc/httpd/conf/httpd.conf
    - source: salt://files/httpd.conf
    - user: root
    - group: root
    - mode: 644
    - require:
      - pkg: apache-service
  service.running:
    - name: httpd
    - enable: True

mysql-service:
  pkg.installed:
    - name: mysql-server
    - require_in:
      -file: mysql-service   #pkg这个包需要被文件管理模块所使用
  file.managed:
    - name: /etc/my.cnf
    - source: salt://files/my.cnf
    - user: root
    - group: root
    - mode: 644
  service.running:
    - name: mysqld
    - enable: True
复制代码

watch依赖

复制代码
lamp-pkg-install:
  pkg.installed:
    - names:
      - php
      - php-cli
      - php-common
      - mysql
      - php-mysql
      - php-pdo

apache-service:
  pkg.installed:
    - name: httpd
  file.managed:
    - name: /etc/httpd/conf/httpd.conf
    - source: salt://files/httpd.conf
    - user: root
    - group: root
    - mode: 644
    - require:
      - pkg: apache-service
  service.running:
    - name: httpd
    - enable: True
    - reload: True
    - watch:
      - file: apache-service   #每当file的文件修改,服务重新reload

mysql-service:
  pkg.installed:
    - name: mysql-server
    - require_in:
      - file: mysql-service
  file.managed:
    - name: /etc/my.cnf
    - source: salt://files/my.cnf
    - user: root
    - group: root
    - mode: 644
  service.running:
    - name: mysqld
    - enable: True
复制代码

watch_in依赖

复制代码
lamp-pkg-install:
  pkg.installed:
    - names:
      - php
      - php-cli
      - php-common
      - mysql
      - php-mysql
      - php-pdo

apache-service:
  pkg.installed:
    - name: httpd
  file.managed:
    - name: /etc/httpd/conf/httpd.conf
    - source: salt://files/httpd.conf
    - user: root
    - group: root
    - mode: 644
    - require:
      - pkg: apache-service
  service.running:
    - name: httpd
    - enable: True
    - reload: True
    - watch:
      - file: apache-service

mysql-service:
  pkg.installed:
    - name: mysql-server
    - require_in:
      - file: mysql-service
  file.managed:
    - name: /etc/my.cnf
    - source: salt://files/my.cnf
    - user: root
    - group: root
    - mode: 644
    - watch_in:
      - service: mysql-service   #文件file被watch_in监控,编辑后重启
  service.running:
    - name: mysqld
    - enable: True
复制代码

 watch_in也可以用于监控软件包的变化,如果安装的软件包有版本更新,也会导致服务的相应动作。

复制代码
lamp-pkg-install:
  pkg.installed:
    - names:
      - php
      - php-cli
      - php-common
      - mysql
      - php-mysql
      - php-pdo

apache-service:
  pkg.installed:
    - name: httpd
    - watch_in:
      - service: apache-service
  file.managed:
    - name: /etc/httpd/conf/httpd.conf
    - source: salt://files/httpd.conf
    - user: root
    - group: root
    - mode: 644
    - require:
      - pkg: apache-service
  service.running:
    - name: httpd
    - enable: True
    - reload: True
    - watch:
      - file: apache-service

mysql-service:
  pkg.installed:
    - name: mysql-server
    - require_in:
      - file: mysql-service
  file.managed:
    - name: /etc/my.cnf
    - source: salt://files/my.cnf
    - user: root
    - group: root
    - mode: 644
    - watch_in:
      - service: mysql-service
  service.running:
    - name: mysqld
    - enable: True
复制代码

 

posted on   Alex0425  阅读(454)  评论(0编辑  收藏  举报
编辑推荐:
· dotnet 源代码生成器分析器入门
· ASP.NET Core 模型验证消息的本地化新姿势
· 对象命名为何需要避免'-er'和'-or'后缀
· SQL Server如何跟踪自动统计信息更新?
· AI与.NET技术实操系列:使用Catalyst进行自然语言处理
阅读排行:
· dotnet 源代码生成器分析器入门
· 官方的 MCP C# SDK:csharp-sdk
· 一款 .NET 开源、功能强大的远程连接管理工具,支持 RDP、VNC、SSH 等多种主流协议!
· 一步一步教你部署ktransformers,大内存单显卡用上Deepseek-R1
· 一次Java后端服务间歇性响应慢的问题排查记录
点击右上角即可分享
微信分享提示