Skip to content

Commit

Permalink
feat(ng): promote NG formula
Browse files Browse the repository at this point in the history
  • Loading branch information
myii committed Aug 7, 2019
1 parent 39b4584 commit 7fbb40b
Show file tree
Hide file tree
Showing 200 changed files with 4,287 additions and 1,839 deletions.
411 changes: 103 additions & 308 deletions docs/README.rst

Large diffs are not rendered by default.

12 changes: 3 additions & 9 deletions php/adodb.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{%- from "php/map.jinja" import php with context %}
include:
- php.deprecated
- php
php-adodb:
pkg.installed:
- name: {{ php.adodb_pkg }}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set state = 'adodb' %}
{%- include tplroot ~ "/installed.jinja" %}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% from "php/ng/map.jinja" import php with context %}
{% from "php/ng/map.jinja" import phpng_version with context %}
{% set major = phpng_version.split('.')|first %}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import php with context %}
{%- from tplroot ~ "/map.jinja" import php_version with context %}
{%- set major = php_version.split('.')|first %}

LoadModule php{{ major }}_module /usr/local/libexec/{{ php.lookup.apache2.name }}/libphp{{ major }}.so

Expand Down
8 changes: 3 additions & 5 deletions php/ng/apache2/ini.sls → php/apache2/ini.sls
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# Manages the main Apache2 ini file
{% from "php/ng/map.jinja" import php with context %}
{% from "php/ng/ini.jinja" import php_ini %}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import php with context %}
{%- from tplroot ~ "/ini.jinja" import php_ini %}
{% set settings = php.ini.defaults %}
{% do settings.update(php.apache2.ini.settings) %}
include:
- php.ng.deprecated
php_apache2_ini:
{{ php_ini(php.lookup.apache2.ini, php.apache2.ini.opts, settings) }}
13 changes: 13 additions & 0 deletions php/apache2/init.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{%- if grains['os_family'] in ["Debian", "FreeBSD"] %}
include:
- php.apache2.install
{%- endif %} #END: os = Debian|FreeBSD
{%- if grains['os_family'] == "Debian" %}
- php.apache2.ini

extend:
php_apache2_ini:
file:
- require:
- sls: php.apache2.install
{%- endif %} #END: os = debian
19 changes: 19 additions & 0 deletions php/apache2/install.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import php with context %}
{%- set state = 'apache2' %}
{%- include tplroot ~ "/installed.jinja" %}
{%- if grains['os_family'] == "FreeBSD" %}
{{ php.lookup.apache2.module_config }}:
file.managed:
- source: salt://php/apache2/files/mod_php.conf.jinja
- template: jinja
{%- if salt['pillar.get']('php:use_apache_formula', True) %}
- makedirs: true
- require_in:
- sls: apache
- watch_in:
- module: apache-restart
{%- endif %} #END: use apache formula
{%- endif %} #END: os = debian
12 changes: 3 additions & 9 deletions php/apc.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{%- from "php/map.jinja" import php with context %}
include:
- php.deprecated
- php
php-apc:
pkg.installed:
- name: {{ php.apc_pkg }}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set state = 'apc' %}
{%- include tplroot ~ "/installed.jinja" %}
12 changes: 3 additions & 9 deletions php/apcu.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{%- from "php/map.jinja" import php with context %}
include:
- php.deprecated
- php
php-apcu:
pkg.installed:
- name: {{ php.apcu_pkg }}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set state = 'apcu' %}
{%- include tplroot ~ "/installed.jinja" %}
3 changes: 3 additions & 0 deletions php/auth-sasl.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- set tplroot = tpldir.split('/')[0] %}
{%- set state = 'auth-sasl' %}
{%- include tplroot ~ "/installed.jinja" %}
12 changes: 3 additions & 9 deletions php/bcmath.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{%- from "php/map.jinja" import php with context %}
include:
- php.deprecated
- php
php-bcmath:
pkg.installed:
- name: {{ php.bcmath_pkg }}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set state = 'bcmath' %}
{%- include tplroot ~ "/installed.jinja" %}
3 changes: 3 additions & 0 deletions php/bz2.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- set tplroot = tpldir.split('/')[0] %}
{%- set state = 'bz2' %}
{%- include tplroot ~ "/installed.jinja" %}
3 changes: 3 additions & 0 deletions php/cache-lite.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- set tplroot = tpldir.split('/')[0] %}
{%- set state = 'cache-lite' %}
{%- include tplroot ~ "/installed.jinja" %}
12 changes: 3 additions & 9 deletions php/cgi.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{%- from "php/map.jinja" import php with context %}
include:
- php.deprecated
- php
php-cgi:
pkg.installed:
- name: {{ php.cgi_pkg }}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set state = 'cgi' %}
{%- include tplroot ~ "/installed.jinja" %}
9 changes: 0 additions & 9 deletions php/cli.sls

This file was deleted.

27 changes: 27 additions & 0 deletions php/cli/ini.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Manages the php cli main ini file
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import php with context %}
{%- from tplroot ~ "/ini.jinja" import php_ini %}
{%- set settings = php.ini.defaults %}
{%- for key, value in php.cli.ini.settings.items() %}
{%- if settings[key] is defined %}
{%- do settings[key].update(value) %}
{%- else %}
{%- do settings.update({key: value}) %}
{%- endif %}
{%- endfor %}
{% set pillar_php_version = salt['pillar.get']('php:version', '7.0') %}
{% if pillar_php_version is iterable and pillar_php_version is not string %}
{% for version in pillar_php_version %}
{% set first_version = pillar_php_version[0]|string %}
{% set ini = php.lookup.cli.ini|replace(first_version, version) %}
php_cli_ini_{{ version }}:
{{ php_ini(ini, php.cli.ini.opts, settings) }}
{% endfor %}
{% else %}
php_cli_ini:
{{ php_ini(php.lookup.cli.ini, php.cli.ini.opts, settings) }}
{% endif %}
22 changes: 22 additions & 0 deletions php/cli/init.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Installs php-cli and manages the associated php.ini

include:
- php.cli.install
- php.cli.ini

{% set pillar_php_version = salt['pillar.get']('php:version', '7.0') %}
{% if pillar_php_version is iterable and pillar_php_version is not string %}
extend:
{% for version in pillar_php_version %}
php_cli_ini_{{ version }}:
file:
- require:
- sls: php.cli.install
{% endfor %}
{% else %}
extend:
php_cli_ini:
file:
- require:
- sls: php.cli.install
{% endif %}
29 changes: 29 additions & 0 deletions php/cli/install.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{%- set tplroot = tpldir.split('/')[0] %}
{%- set state = 'cli' %}
{%- include tplroot ~ "/installed.jinja" %}

{%- if salt['grains.get']('os_family') == "Debian" %}
{%- set current_php = salt['alternatives.show_current']('php') %}
{% set pillar_php_version = salt['pillar.get']('php:version', '7.0') %}
{% if pillar_php_version is iterable and pillar_php_version is not string %}
{% if 'alternatives_version' in salt['pillar.get']('php') %}
{% set php_version = salt['pillar.get']('php:alternatives_version') %}
{% else %}
{% set php_version = false %}
{% endif %}
{% else %}
{%- set php_version = salt['pillar.get']('php:version', '7.0')|string %}
{% endif %}

{% if php_version %}
php_{{ php_version }}_link:
alternatives.set:
- name: php
- path: /usr/bin/php{{ php_version }}
- require_in:
- pkg: php_install_{{ state }}
- onlyif:
- which php
- test {{ current_php }} != $(which php{{ php_version }})
{%- endif %}
{% endif %}
32 changes: 20 additions & 12 deletions php/composer.sls
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
{%- from "php/map.jinja" import php with context %}
{%- set tplroot = tpldir.split('/')[0] %}
{% from tplroot ~ "/map.jinja" import php with context %}
{%- set install_file = php.local_bin + '/' + php.composer_bin %}
{% set install_file = php.lookup.pkgs.local_bin + '/' + php.lookup.pkgs.composer_bin %}
{%- if not salt['config.get']('sudo_user') %}
{%- set salt_user = salt['config.get']('user', 'root') %}
{%- else %}
{%- set salt_user = salt['config.get']('sudo_user', 'root') %}
{%- endif %}
{% if not salt['config.get']('sudo_user') %}
{% set salt_user = salt['config.get']('user', 'root') %}
{% else %}
{% set salt_user = salt['config.get']('sudo_user', 'root') %}
{% endif %}
{%- set salt_user_home = salt['user.info'](salt_user).get('home', '/root') %}
{% set salt_user_home = salt['user.info'](salt_user).get('home', '/root') %}
include:
- php.deprecated
- php
{% if grains['os_family'] == 'FreeBSD' %}
- php.filter
- php.hash
- php.json
- php.mbstring
- php.openssl
- php.phar
{% endif %}
get-composer:
file.managed:
- name: {{ php.temp_dir }}/installer
- name: {{ php.lookup.pkgs.temp_dir }}/installer
- mode: 0755
- unless: test -f {{ install_file }}
- source: https://getcomposer.org/installer
Expand All @@ -26,7 +34,7 @@ get-composer:
install-composer:
cmd.run:
- name: php {{ php.temp_dir }}/installer --filename={{ php.composer_bin }} --install-dir={{ php.local_bin }}
- name: php {{ php.lookup.pkgs.temp_dir }}/installer --filename={{ php.lookup.pkgs.composer_bin }} --install-dir={{ php.lookup.pkgs.local_bin }}
- unless: test -f {{ install_file }}
- env:
- HOME: {{ salt_user_home }}
Expand All @@ -47,7 +55,7 @@ update-composer:
{% else %}
- unless: test $(date -d "60 days $({{ install_file }} --version | cut -d ' ' -f 4,5)" "+%s") -gt $(date "+%s")
{% endif %}
- cwd: {{ php.local_bin }}
- cwd: {{ php.lookup.pkgs.local_bin }}
- env:
- HOME: {{ salt_user_home }}
- require:
Expand Down
3 changes: 3 additions & 0 deletions php/console-table.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- set tplroot = tpldir.split('/')[0] %}
{%- set state = 'console-table' %}
{%- include tplroot ~ "/installed.jinja" %}
3 changes: 3 additions & 0 deletions php/ctype.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- set tplroot = tpldir.split('/')[0] %}
{%- set state = 'ctype' %}
{%- include tplroot ~ "/installed.jinja" %}
12 changes: 3 additions & 9 deletions php/curl.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{%- from "php/map.jinja" import php with context %}
include:
- php.deprecated
- php
php-curl:
pkg.installed:
- name: {{ php.curl_pkg }}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set state = 'curl' %}
{%- include tplroot ~ "/installed.jinja" %}
3 changes: 3 additions & 0 deletions php/dba.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- set tplroot = tpldir.split('/')[0] %}
{%- set state = 'dba' %}
{%- include tplroot ~ "/installed.jinja" %}
12 changes: 3 additions & 9 deletions php/dev.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{%- from "php/map.jinja" import php with context %}
include:
- php.deprecated
- php
php-dev:
pkg.installed:
- name: {{ php.dev_pkg }}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set state = 'dev' %}
{%- include tplroot ~ "/installed.jinja" %}
3 changes: 3 additions & 0 deletions php/dom.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- set tplroot = tpldir.split('/')[0] %}
{%- set state = 'dom' %}
{%- include tplroot ~ "/installed.jinja" %}
3 changes: 3 additions & 0 deletions php/fileinfo.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- set tplroot = tpldir.split('/')[0] %}
{%- set state = 'fileinfo' %}
{%- include tplroot ~ "/installed.jinja" %}
File renamed without changes.
3 changes: 3 additions & 0 deletions php/filter.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- set tplroot = tpldir.split('/')[0] %}
{%- set state = 'filter' %}
{%- include tplroot ~ "/installed.jinja" %}
11 changes: 0 additions & 11 deletions php/fpm.sls

This file was deleted.

Loading

0 comments on commit 7fbb40b

Please sign in to comment.