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)
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.