From d14b686e5e8cac96223f34f5a15628f84c85146c Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Thu, 21 Aug 2014 12:22:20 +0200 Subject: [PATCH] Added mongo extension via pecl and use ppa for php --- README.rst | 7 ++++++- php/dev.sls | 6 ++++++ php/init.sls | 15 +++++++++++++++ php/map.jinja | 8 ++++++++ php/mongo.sls | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 php/dev.sls create mode 100644 php/mongo.sls diff --git a/README.rst b/README.rst index a5c482d..b40f3cc 100644 --- a/README.rst +++ b/README.rst @@ -58,7 +58,7 @@ Installs the php-fpm package, starts the service, and enables it. Installs the php-gd package. ``php.intl`` ----------- +------------ Installs the php-intl package. @@ -134,6 +134,11 @@ Installs the php-soap package. Installs the php-suhosin package. +``php.mongo`` +------------- + +Installs the php-mongo package. + ``php.xml`` ----------- diff --git a/php/dev.sls b/php/dev.sls new file mode 100644 index 0000000..d9fe114 --- /dev/null +++ b/php/dev.sls @@ -0,0 +1,6 @@ +{% from "php/map.jinja" import php with context %} + +php-dev: + pkg: + - installed + - name: {{ php.dev_pkg }} diff --git a/php/init.sls b/php/init.sls index 67812c9..bc05041 100644 --- a/php/init.sls +++ b/php/init.sls @@ -1,5 +1,20 @@ {% from "php/map.jinja" import php with context %} +{% if grains['os_family']=="Debian" %} +{% if use_ppa is not none %} + +{% set use_ppa = salt['pillar.get']('php:use_ppa', none) %} +{% set ppa_name = salt['pillar.get']('php:ppa_name', 'ondrej/php5') %} + +php54: + pkgrepo.managed: + - ppa: {{ ppa_name }} + pkg.latest: + - name: php5 + - refresh: True +{% endif %} +{% endif %} + php: pkg: - installed diff --git a/php/map.jinja b/php/map.jinja index baf4ae2..7699b83 100644 --- a/php/map.jinja +++ b/php/map.jinja @@ -26,6 +26,10 @@ 'pgsql_pkg': 'php5-pgsql', 'ldap_pkg': 'php5-ldap', 'php_ini': '/etc/php5/apache2/php.ini', + 'dev_pkg': 'php5-dev', + 'mongo_pecl': 'mongo', + 'mongo_ext': 'mongo.so', + 'ext_conf_path': '/etc/php5/mods-available', }, 'RedHat': { 'php_pkg': 'php', @@ -54,5 +58,9 @@ 'pgsql_pkg': 'php-pgsql', 'ldap_pkg': 'php-ldap', 'php_ini': '/etc/php.ini', + 'dev_pkg': 'php-dev', + 'mongo_pecl': 'mongo', + 'mongo_ext': 'mongo.so', + 'ext_conf_path': '/etc/php5/conf.d', }, }, merge=salt['pillar.get']('php:lookup')) %} diff --git a/php/mongo.sls b/php/mongo.sls new file mode 100644 index 0000000..5cabc06 --- /dev/null +++ b/php/mongo.sls @@ -0,0 +1,32 @@ +{% from "php/map.jinja" import php with context %} + +{% set version = salt['pillar.get']('php:mongo_version', none) %} + +include: + - php + - php.dev + - php.pear + +php-mongo: + pecl.installed: + - name: {{ php.mongo_pecl }} + - require: + - pkg: {{ php.pear_pkg }} + - defaults: True +{% if version is not none %} + - version: {{ version }} +{% endif %} + +php-mongo-conf: + file.managed: + - name: {{ php.ext_conf_path }}/mongo.ini + - contents: | + extension={{ php.mongo_ext }} + - require: + - pkg: {{ php.php_pkg }} + +php-mongo-enable: + cmd.run: + - name: php5enmod mongo + - require: + - file: php-mongo-conf