• SaltStack 配置管理-状态间关系


    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
  • 相关阅读:
    display
    盒子模型
    css样式
    修改页面标题前的图标
    form表单
    html中列表
    代码书写格式
    dw中的超链接
    硬盘的访问,程序重定位和加载
    Bochs调试指令
  • 原文地址:https://www.cnblogs.com/python-study/p/5486492.html
Copyright © 2020-2023  润新知