Merge branch 'generic-apache'

This commit is contained in:
Seth House 2013-08-13 15:13:53 -06:00
commit ee72d30b06
8 changed files with 103 additions and 79 deletions

View File

@ -1,18 +1,23 @@
apache apache
====== ======
DEPENDENCIES:
These salt-states are required:
1) apt Formulas to set up and configure the Apache HTTP server
POSSIBLE DEPENDENCIES .. note::
These salt-states may be required depending on what your doing:
1) php See the full `Salt Formulas installation and usage instructions
<http://docs.saltstack.com/topics/conventions/formulas.html>`_.
ORDERING: Available states
----------------
The ordering of the states for apache falls into block ranges which are: ``apache``
Installs the Apache package and starts the service.
``apache.debian_full``
Installs and configures Apache on Debian and Ubuntu systems.
These states are ordered using the ``order`` declaration. Different stages
are divided into the following number ranges:
1) apache will use 1-500 for ordering 1) apache will use 1-500 for ordering
2) apache will reserve 1 -100 as unused 2) apache will reserve 1 -100 as unused
@ -25,17 +30,11 @@ The ordering of the states for apache falls into block ranges which are:
9) apache WILL reserve 451-460 for service.running 9) apache WILL reserve 451-460 for service.running
10) apache will reserve 461-500 for cmd requiring operational services 10) apache will reserve 461-500 for cmd requiring operational services
PILLARS: Dependencies:
1) No pillar data is required * `apt <https://github.com/saltstack-formulas/apt-formula>`_
2) Full pillar structure:
apache: Optional dependencies:
php-ini: 'salt://path/to/file/php.ini'
register-site: 1) `php <https://github.com/saltstack-formulas/php-formula>`_
{{UNQIUE}}:
name: 'my name'
path: 'salt://path/to/sites-available/conf/file'
state: 'enabled'
3) UNIQUE can be any name as an array index, and you can duplicate this section

46
apache/debian_full.sls Normal file
View File

@ -0,0 +1,46 @@
{% if grains['os_family']=="Debian" %}
include:
- apt
- apache
- apache.register_site
extend:
apache:
pkg:
- order: 175
service:
- order: 455
a2dissite 000-default:
cmd.run:
- order: 225
- onlyif: ls /etc/apache2/sites-enabled/000-default
- watch_in:
- cmd: apache-reload
- require:
- pkg: apache
apache-reload:
cmd.wait:
- name: service apache2 reload
- order: 420
apache-restart:
cmd.wait:
- name: service apache2 restart
- order: 425
/etc/apache2/sites-available/default:
file.absent:
- order: 230
- require:
- pkg: apache
/etc/apache2/sites-available/default-ssl:
file.absent:
- order: 230
- require:
- pkg: apache
{% endif %} #END: os = debian

View File

@ -1,8 +1,8 @@
{% if grains['os_family']=="Debian" %}
include: include:
- apt - apt
{% if grains['os']=="Ubuntu" %}
mod-fcgid: mod-fcgid:
pkg.installed: pkg.installed:
- name: libapache2-mod-fcgid - name: libapache2-mod-fcgid

View File

@ -1,47 +1,13 @@
include: {% set pkg = salt['grains.filter_by']({
- apt 'Debian': {'name': 'apache2'},
- apache.register_site 'RedHat': {'name': 'httpd'},
}) %}
{% if grains['os']=="Ubuntu" %}
apache: apache:
pkg.installed: pkg:
- name: apache2 - installed
- order: 175 - name: {{ pkg.name }}
service.running: service:
- name: apache2 - running
- name: {{ pkg.name }}
- enable: True - enable: True
- order: 455
a2dissite 000-default:
cmd.run:
- order: 225
- onlyif: ls /etc/apache2/sites-enabled/000-default
- watch_in:
- cmd: apache-reload
- require:
- pkg: apache
apache-reload:
cmd.wait:
- name: service apache2 reload
- order: 420
apache-restart:
cmd.wait:
- name: service apache2 restart
- order: 425
/etc/apache2/sites-available/default:
file.absent:
- order: 230
- require:
- pkg: apache
/etc/apache2/sites-available/default-ssl:
file.absent:
- order: 230
- require:
- pkg: apache
{% endif %} #END: os = ubuntu

View File

@ -1,8 +1,8 @@
{% if grains['os_family']=="Debian" %}
include: include:
- apt - apt
{% if grains['os']=="Ubuntu" %}
mod-php5: mod-php5:
pkg.installed: pkg.installed:
- name: libapache2-mod-php5 - name: libapache2-mod-php5

View File

@ -1,3 +1,5 @@
{% if grains['os_family']=="Debian" %}
{% if 'apache' in pillar and 'register-site' in pillar['apache'] %} #BEGIN: ['apache']['register-site'] {% if 'apache' in pillar and 'register-site' in pillar['apache'] %} #BEGIN: ['apache']['register-site']
{% for site in pillar['apache']['register-site'] %} {% for site in pillar['apache']['register-site'] %}
@ -44,3 +46,4 @@ a2dissite {{ pillar['apache']['register-site'][site]['name'] }}:
{% endfor %} {% endfor %}
{% endif %} #END: apache-register-site {% endif %} #END: apache-register-site
{% endif %} #END: grains['os_family'] == debian

View File

@ -1,8 +1,8 @@
{% if grains['os_family']=="Debian" %}
include: include:
- apt - apt
{% if grains['os']=="Ubuntu" %}
a2enmod rewrite: a2enmod rewrite:
cmd.run: cmd.run:
- unless: ls /etc/apache2/mods-enabled/rewrite.load - unless: ls /etc/apache2/mods-enabled/rewrite.load

View File

@ -0,0 +1,10 @@
# Example for the apache.debian_full formula:
apache:
php-ini: 'salt://path/to/file/php.ini'
register-site:
# any name as an array index, and you can duplicate this section
{{UNQIUE}}:
name: 'my name'
path: 'salt://path/to/sites-available/conf/file'
state: 'enabled'