more advanced apache formula -- attempt #2master
@@ -1,6 +1,41 @@ | |||
apache | |||
===== | |||
====== | |||
DEPENDENCIES: | |||
These salt-states are required: | |||
init.sls | |||
----- | |||
- Installs apache2 on `ubuntu 12.04` | |||
1) apt | |||
POSSIBLE DEPENDENCIES | |||
These salt-states may be required depending on what your doing: | |||
1) php | |||
ORDERING: | |||
The ordering of the states for apache falls into block ranges which are: | |||
1) apache will use 1-500 for ordering | |||
2) apache will reserve 1 -100 as unused | |||
3) apache will reserve 101-150 for pre pkg install | |||
4) apache will reserve 151-200 for pkg install | |||
5) apache will reserve 201-250 for pkg configure | |||
6) apache will reserve 251-300 for downloads, git stuff, load data | |||
7) apache will reserve 301-400 for unknown purposes | |||
8) apache will reserve 401-450 for service restart-reloads | |||
9) apache WILL reserve 451-460 for service.running | |||
10) apache will reserve 461-500 for cmd requiring operational services | |||
PILLARS: | |||
1) No pillar data is required | |||
2) Full pillar structure: | |||
apache: | |||
php-ini: 'salt://path/to/file/php.ini' | |||
register-site: | |||
{{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 |
@@ -0,0 +1,22 @@ | |||
include: | |||
- apt | |||
{% if grains['os']=="Ubuntu" %} | |||
mod-fcgid: | |||
pkg.installed: | |||
- name: libapache2-mod-fcgid | |||
- order: 180 | |||
- require: | |||
- pkg: apache | |||
a2enmod fcgid: | |||
cmd.run: | |||
- order: 225 | |||
- unless: ls /etc/apache2/mods-enabled/fcgid.load | |||
- require: | |||
- pkg: mod-fcgid | |||
- watch_in: | |||
- cmd: apache-restart | |||
{% endif %} |
@@ -0,0 +1,47 @@ | |||
include: | |||
- apt | |||
- apache.register_site | |||
{% if grains['os']=="Ubuntu" %} | |||
apache: | |||
pkg.installed: | |||
- name: apache2 | |||
- order: 175 | |||
service.running: | |||
- name: apache2 | |||
- 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 |
@@ -0,0 +1,34 @@ | |||
include: | |||
- apt | |||
{% if grains['os']=="Ubuntu" %} | |||
mod-php5: | |||
pkg.installed: | |||
- name: libapache2-mod-php5 | |||
- order: 180 | |||
- require: | |||
- pkg: apache | |||
a2enmod php5: | |||
cmd.run: | |||
- unless: ls /etc/apache2/mods-enabled/php5.load | |||
- order: 225 | |||
- require: | |||
- pkg: mod-php5 | |||
- watch_in: | |||
- cmd: apache-restart | |||
{% if 'apache' in pillar and 'php-ini' in pillar['apache'] %} | |||
/etc/php5/apache2/php.ini: | |||
file.managed: | |||
- source: {{ pillar['apache']['php-ini'] }} | |||
- order: 225 | |||
- watch_in: | |||
- cmd: apache-restart | |||
- require: | |||
- pkg: apache | |||
- pkg: php5 | |||
{% endif %} | |||
{% endif %} |
@@ -0,0 +1,46 @@ | |||
{% if 'apache' in pillar and 'register-site' in pillar['apache'] %} #BEGIN: ['apache']['register-site'] | |||
{% for site in pillar['apache']['register-site'] %} | |||
#BEGIN: Call apache a2ensite | |||
########################################## | |||
{% if 'name' in pillar['apache']['register-site'][site] and 'state' in pillar['apache']['register-site'][site] %} | |||
{% if pillar['apache']['register-site'][site]['state'] == 'enabled' %} | |||
a2ensite {{ pillar['apache']['register-site'][site]['name'] }}: | |||
{% else %} | |||
a2dissite {{ pillar['apache']['register-site'][site]['name'] }}: | |||
{% endif %} | |||
cmd.run: | |||
{% if pillar['apache']['register-site'][site]['state'] == 'enabled' %} | |||
- unless: ls /etc/apache2/sites-enabled/{{ pillar['apache']['register-site'][site]['name'] }} | |||
{% else %} | |||
- onlyif: ls /etc/apache2/sites-enabled/{{ pillar['apache']['register-site'][site]['name'] }} | |||
{% endif %} | |||
- order: 230 | |||
- require: | |||
- pkg: apache | |||
- file: /etc/apache2/sites-available/{{ pillar['apache']['register-site'][site]['name'] }} | |||
{% endif %} | |||
########################################## | |||
#BEGIN: Manage apache site config | |||
########################################## | |||
{% if 'name' in pillar['apache']['register-site'][site] and 'path' in pillar['apache']['register-site'][site] %} | |||
/etc/apache2/sites-available/{{ pillar['apache']['register-site'][site]['name'] }}: | |||
file.managed: | |||
- source: {{ pillar['apache']['register-site'][site]['path'] }} | |||
- order: 225 | |||
- user: root | |||
- group: root | |||
- mode: 775 | |||
- watch_in: | |||
- cmd: a2ensite {{ pillar['apache']['register-site'][site]['name'] }} | |||
- cmd: apache-reload | |||
{% endif %} | |||
########################################## | |||
{% endfor %} | |||
{% endif %} #END: apache-register-site |
@@ -0,0 +1,13 @@ | |||
include: | |||
- apt | |||
{% if grains['os']=="Ubuntu" %} | |||
a2enmod rewrite: | |||
cmd.run: | |||
- unless: ls /etc/apache2/mods-enabled/rewrite.load | |||
- order: 225 | |||
- watch_in: | |||
- cmd: apache-restart | |||
{% endif %} |