Skip to content

Commit

Permalink
feat(ng): promote NG formula
Browse files Browse the repository at this point in the history
BREAKING CHANGES: users must adapt their pillar. See `docs.REAME.rst`
  • Loading branch information
sticky-note authored and sticky-note committed Aug 20, 2019
1 parent ea39203 commit f1b71d0
Show file tree
Hide file tree
Showing 217 changed files with 4,371 additions and 5,487 deletions.
444 changes: 121 additions & 323 deletions docs/README.rst

Large diffs are not rendered by default.

11 changes: 2 additions & 9 deletions php/adodb.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
{%- from "php/map.jinja" import php with context %}
include:
- php.deprecated
- php
php-adodb:
pkg.installed:
- name: {{ php.adodb_pkg }}
{% set state = 'adodb' %}
{% include "php/installed.jinja" %}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% 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 %}
{% from "php/map.jinja" import php with context %}
{% from "php/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
9 changes: 9 additions & 0 deletions php/apache2/ini.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Manages the main Apache2 ini file
{% from "php/map.jinja" import php with context %}
{% from "php/ini.jinja" import php_ini %}
{% set settings = php.ini.defaults %}
{% do settings.update(php.apache2.ini.settings) %}
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
18 changes: 18 additions & 0 deletions php/apache2/install.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% from "php/map.jinja" import php with context %}
{% set state = 'apache2' %}
{% include "php/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
11 changes: 2 additions & 9 deletions php/apc.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
{%- from "php/map.jinja" import php with context %}
include:
- php.deprecated
- php
php-apc:
pkg.installed:
- name: {{ php.apc_pkg }}
{% set state = 'apc' %}
{% include "php/installed.jinja" %}
11 changes: 2 additions & 9 deletions php/apcu.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
{%- from "php/map.jinja" import php with context %}
include:
- php.deprecated
- php
php-apcu:
pkg.installed:
- name: {{ php.apcu_pkg }}
{% set state = 'apcu' %}
{% include "php/installed.jinja" %}
2 changes: 2 additions & 0 deletions php/auth-sasl.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% set state = 'auth-sasl' %}
{% include "php/installed.jinja" %}
11 changes: 2 additions & 9 deletions php/bcmath.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
{%- from "php/map.jinja" import php with context %}
include:
- php.deprecated
- php
php-bcmath:
pkg.installed:
- name: {{ php.bcmath_pkg }}
{% set state = 'bcmath' %}
{% include "php/installed.jinja" %}
2 changes: 2 additions & 0 deletions php/bz2.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% set state = 'bz2' %}
{% include "php/installed.jinja" %}
2 changes: 2 additions & 0 deletions php/cache-lite.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% set state = 'cache-lite' %}
{% include "php/installed.jinja" %}
11 changes: 2 additions & 9 deletions php/cgi.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
{%- from "php/map.jinja" import php with context %}
include:
- php.deprecated
- php
php-cgi:
pkg.installed:
- name: {{ php.cgi_pkg }}
{% set state = 'cgi' %}
{% include "php/installed.jinja" %}
9 changes: 0 additions & 9 deletions php/cli.sls

This file was deleted.

26 changes: 26 additions & 0 deletions php/cli/ini.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Manages the php cli main ini file
{% from "php/map.jinja" import php with context %}
{% from "php/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_ng_version = salt['pillar.get']('php:ng:version', '7.0') %}
{% if pillar_php_ng_version is iterable and pillar_php_ng_version is not string %}
{% for version in pillar_php_ng_version %}
{% set first_version = pillar_php_ng_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 %}
28 changes: 28 additions & 0 deletions php/cli/install.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{% set state = 'cli' %}
{% include "php/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 %}
31 changes: 19 additions & 12 deletions php/composer.sls
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
{%- from "php/map.jinja" import php with context %}
{% from "php/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 +33,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 +54,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
2 changes: 2 additions & 0 deletions php/console-table.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% set state = 'console-table' %}
{% include "php/installed.jinja" %}
2 changes: 2 additions & 0 deletions php/ctype.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% set state = 'ctype' %}
{% include "php/installed.jinja" %}
11 changes: 2 additions & 9 deletions php/curl.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
{%- from "php/map.jinja" import php with context %}
include:
- php.deprecated
- php
php-curl:
pkg.installed:
- name: {{ php.curl_pkg }}
{% set state = 'curl' %}
{% include "php/installed.jinja" %}
2 changes: 2 additions & 0 deletions php/dba.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% set state = 'dba' %}
{% include "php/installed.jinja" %}
41 changes: 16 additions & 25 deletions php/deprecated.sls
Original file line number Diff line number Diff line change
@@ -1,41 +1,32 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{#- Evaluating as `False` by default, using this method since `defaults.yaml` not available in this repo #}
{%- if not salt['config.get']('php').get('warning_messages', {}).get('v1.0.0', {}).get('mute_critical', False) %}
php-deprecated-in-v1.0.0-test-succeed:
test.succeed_without_changes:
php-deprecated-in-v1.0.0-test-fail:
test.fail_without_changes:
- name: |

################################################################################
# #
# WARNING: BREAKING CHANGES IN UPCOMING VERSION `v1.0.0` #
# WARNING: BREAKING CHANGES SINCE `v1.0.0` #
# #
################################################################################
# #
# This formula currently provides two methods for managing PHP; the old method #
# under `php` and the new method under `php.ng`. In upcoming `v1.0.0`, the old #
# method will be removed and `php.ng` will be promoted to `php` in its place. #
# Prior to `v1.0.0`, this formula provided two methods for managing PHP; the #
# old method under `php` and the new method under `php.ng`. The old method #
# has now been removed and `php.ng` has been promoted to be `php` in its #
# place. #
# #
# If you are not in a position to migrate, you will need to pin your repo to #
# the final release tag before `v1.0.0`, which is expected to be `v0.40.1`. #
# If you are not in a position to migrate, please pin your repo to the final #
# release tag before `v1.0.0`, i.e. `v0.40.1`. #
# #
# If you are currently using `php.ng`, there is nothing to do until `v1.0.0` #
# is released. #
# To migrate from `php.ng`, simply modify your pillar to promote the entire #
# section under `php:ng` so that it is under `php` instead. So with the #
# editor of your choice, highlight the entire section and then unindent one #
# level. Finish by removing the `ng:` line. #
# #
# To migrate from the old `php`, the first step is to convert to `php.ng`, #
# before `v1.0.0` is released. #
# #
# To prevent this message being displayed again, set the pillar/config value: #
# #
# ``` #
# php: #
# warning_messages: #
# v1.0.0: #
# mute_critical: True #
# ``` #
# To migrate from the old `php`, first convert to `php.ng` under `v0.40.1` #
# and then follow the steps laid out in the paragraph directly above. #
# #
################################################################################
# - failhard: True
{%- endif %}
- failhard: True
11 changes: 2 additions & 9 deletions php/dev.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
{%- from "php/map.jinja" import php with context %}
include:
- php.deprecated
- php
php-dev:
pkg.installed:
- name: {{ php.dev_pkg }}
{% set state = 'dev' %}
{% include "php/installed.jinja" %}
2 changes: 2 additions & 0 deletions php/dom.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% set state = 'dom' %}
{% include "php/installed.jinja" %}
2 changes: 2 additions & 0 deletions php/fileinfo.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% set state = 'fileinfo' %}
{% include "php/installed.jinja" %}
File renamed without changes.
2 changes: 2 additions & 0 deletions php/filter.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% set state = 'filter' %}
{% include "php/installed.jinja" %}
11 changes: 0 additions & 11 deletions php/fpm.sls

This file was deleted.

Loading

0 comments on commit f1b71d0

Please sign in to comment.