码迷,mamicode.com
首页 > 其他好文 > 详细

SaltStack 配置管理-状态间关系

时间:2016-05-13 11:42:56      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:

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

 

SaltStack 配置管理-状态间关系

标签:

原文地址:http://www.cnblogs.com/python-study/p/5486492.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!