3

I have two state files:

  • php/init.sls
  • php-fpm.sls

php/init.sls installs the package php53u

I'm trying to get php-fpm.sls to require php as that is how I declare it inside php/init.sls, however it only works if I require the pkg: php53u and not sls: php

Contents of php/init.sh:

php:
  pkg:
    - name: php53u
    - installed

Contents of php-fpm.sls (using pkg where it works):

include:
  - nginx
  - php

php-fpm:
  pkg:
    - name: php53u-fpm
    - installed
  service:
    - running
    - enable: True
    - require:
      - pkg: php53u-fpm
      - pkg: php53u

extend:
  nginx:
    file:
      - name: /etc/nginx/php-fpm
      - source: salt://nginx/src/etc/nginx/php-fpm
      - managed
      - template: jinja

(note that this has extra stuff about nginx that currently isn't a require though it should be)

4

2 回答 2

3

您正确地包含了 php sls 文件。你只需要像这样设置你的要求:

- pkg: php

这是一个应该有效的示例:

php-fpm:
  pkg:
    - name: php53u-fpm
    - installed
    - require:
      - pkg: php
  service:
    - running
    - enable: True
    - watch:
      - pkg: php53u-fpm
      - pkg: php

请注意,我还在 pkg 节中添加了 require 以确保在 php53u-fpm 包之前安装 php 包。

我还将服务节下的“要求”更改为“手表”。“watch”充当“require”,但如果“watched” pkg 更改,也会重新启动服务。因此,如果有软件包升级,它将自动重新启动服务。

于 2013-11-25T18:19:18.547 回答
1

这是完全正常的,在要求列表中,您需要使用 ID 声明(http://docs.saltstack.com/ref/states/highstate.html#term-id-declaration)。

模块 php/init.sls 仅包含一个 ID 声明:{pkg: php53u}。ID 声明由状态名称(pkg)和组件名称(php53u)组成。

你不能在 salt 中要求整个模块,但在最后的版本中,模块将按照声明的顺序执行,因此 php 模块应该在 php-fm 之前执行。在任何情况下,Salt 都会尊重需要的必要参考资料。

salt-stack 中的词汇对于初学者来说可能有点困难,这里有一个可以帮助你的页面:http: //docs.saltstack.com/ref/states/highstate.html

于 2013-11-24T12:24:20.360 回答