I have two state files:
php/init.slsphp-fpm.slsphp/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)
You are correctly including the php sls file. You just need to set your require like this:
- pkg: php
Here's an example that should work:
php-fpm:
pkg:
- name: php53u-fpm
- installed
- require:
- pkg: php
service:
- running
- enable: True
- watch:
- pkg: php53u-fpm
- pkg: php
Notice that I also added the require to the pkg stanza to make sure that the php package is installed before the php53u-fpm package.
I also changed the "require" under the service stanza to a "watch". A "watch" acts as a "require", but also will restart the service if the "watched" pkg changes. So if there's a package upgrade it will restart the service automatically.
It's perfectly normal, in the require list, you need to use ID Declaration (http://docs.saltstack.com/ref/states/highstate.html#term-id-declaration).
The module php/init.sls contains only one ID Declaration : {pkg: php53u}. ID Declaration is composed of state name (pkg) and component name (php53u).
You can't require an entire module in salt, but in the last versions, modules will be executed in order of declaration, so the php module should be executed before the php-fm one. Salt will respect require requisite references in any cases.
Vocabulary in salt-stack could be a little difficult for beginners, here is a page which can helps you : http://docs.saltstack.com/ref/states/highstate.html.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With