php-formula/php/ng/installed.jinja
Zachary Softich 0aa92cbcc9 Only add ppa if it doesn't exist.
This comit is in addition to pull request #70. The add-apt-repository command
will only be run when the ppa has not yet been added.
2015-12-23 09:57:06 -06:00

64 lines
1.6 KiB
Django/Jinja

# Template for installing packages.
{% from "php/ng/map.jinja" import php with context %}
{% from "php/ng/macro.jinja" import sls_block %}
{% set pkginfo = php.lookup.pkgs.get(state) %}
{% set pkgs = [] %}
{% set specials = [] %}
{% if pkginfo is iterable and pkginfo is not string %}
{% for pkg in pkginfo %}
{% if pkg is mapping %}
{% do specials.append(pkg) %}
{% else %}
{% do pkgs.append(pkg) %}
{% endif %}
{% endfor %}
{% else %}
{% do pkgs.append(pkginfo) %}
{% endif %}
{% if grains['os_family']=="Debian" and (state == 'cli' or state == 'fpm' or state == 'php') %}
{% set use_ppa = salt['pillar.get']('php:use_ppa', False) %}
{% if use_ppa %}
{% set ppa_name = salt['pillar.get']('php:ppa_name', 'ondrej/php5') %}
php_ppa_env_{{ state }}:
cmd.run:
- name: apt-add-repository -y ppa:{{ ppa_name }}
- env:
- LC_ALL: C.UTF-8
- unless: test /etc/apt/sources.list.d/{{ ppa_name|replace('/', '-', 1) }}-trusty.list
php_ppa_{{ state }}:
pkgrepo.managed:
- ppa: {{ ppa_name }}
- require:
- cmd: php_ppa_env_{{ state }}
- require_in:
- pkg: php_install_{{ state }}
pkg.latest:
- name: {{ state }}
- pkgs: {{ pkgs|json() }}
- refresh: True
- onchanges:
- pkgrepo: php_ppa_{{ state }}
{% endif %}
{% endif %}
php_install_{{ state }}:
pkg.installed:
- name: {{ state }}
- pkgs: {{ pkgs|json() }}
{% for pkg in specials %}
php_install_{{ state }}_{{ pkg.get('name') }}:
pkg.installed:
{{ sls_block(pkg) }}
{% endfor %}