From 0e86fb8c9d5d6bbe32b63557851a96e47e716017 Mon Sep 17 00:00:00 2001 From: Seth House Date: Tue, 13 Aug 2013 14:25:16 -0600 Subject: [PATCH 1/5] Renamed the main sls file to debian_full This is a great and full-featured way to configure Apache on Debian-family OS's but we need a simpler and more universal formula as the main entry-point. --- apache/{init.sls => debian_full.sls} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename apache/{init.sls => debian_full.sls} (100%) diff --git a/apache/init.sls b/apache/debian_full.sls similarity index 100% rename from apache/init.sls rename to apache/debian_full.sls From 053c3443d7826ac55c6d564ae09d387a18d09cf6 Mon Sep 17 00:00:00 2001 From: Seth House Date: Tue, 13 Aug 2013 15:03:16 -0600 Subject: [PATCH 2/5] Added basic formula to install Apache --- apache/init.sls | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 apache/init.sls diff --git a/apache/init.sls b/apache/init.sls new file mode 100644 index 0000000..e899e60 --- /dev/null +++ b/apache/init.sls @@ -0,0 +1,13 @@ +{% set pkg = salt['grains.filter_by']({ + 'Debian': {'name': 'apache2'}, + 'RedHat': {'name': 'httpd'}, +}) %} + +apache: + pkg: + - installed + - name: {{ pkg.name }} + service: + - running + - name: {{ pkg.name }} + - enable: True From 746bbb9db361795de62fea8ab919709462c589bd Mon Sep 17 00:00:00 2001 From: Seth House Date: Tue, 13 Aug 2013 14:29:58 -0600 Subject: [PATCH 3/5] Updated Debian-family formula to use main sls but keep custom ordering --- apache/debian_full.sls | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/apache/debian_full.sls b/apache/debian_full.sls index eb186cd..2e3dd6f 100644 --- a/apache/debian_full.sls +++ b/apache/debian_full.sls @@ -1,17 +1,15 @@ include: - apt + - apache - apache.register_site {% if grains['os']=="Ubuntu" %} - -apache: - pkg.installed: - - name: apache2 - - order: 175 - service.running: - - name: apache2 - - enable: True - - order: 455 +extend: + apache: + pkg: + - order: 175 + service: + - order: 455 a2dissite 000-default: cmd.run: From effba317fdb96a7576116174f92d9faf2a652e69 Mon Sep 17 00:00:00 2001 From: Seth House Date: Tue, 13 Aug 2013 14:30:49 -0600 Subject: [PATCH 4/5] Updated Debian-family formula to work on all Debian-family OSes --- apache/debian_full.sls | 5 +++-- apache/fcgid.sls | 4 ++-- apache/php5.sls | 4 ++-- apache/register_site.sls | 3 +++ apache/rewrite.sls | 4 ++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/apache/debian_full.sls b/apache/debian_full.sls index 2e3dd6f..0f90a3c 100644 --- a/apache/debian_full.sls +++ b/apache/debian_full.sls @@ -1,9 +1,10 @@ +{% if grains['os_family']=="Debian" %} + include: - apt - apache - apache.register_site -{% if grains['os']=="Ubuntu" %} extend: apache: pkg: @@ -42,4 +43,4 @@ apache-restart: - require: - pkg: apache -{% endif %} #END: os = ubuntu +{% endif %} #END: os = debian diff --git a/apache/fcgid.sls b/apache/fcgid.sls index 895cffe..12bbbd0 100644 --- a/apache/fcgid.sls +++ b/apache/fcgid.sls @@ -1,8 +1,8 @@ +{% if grains['os_family']=="Debian" %} + include: - apt -{% if grains['os']=="Ubuntu" %} - mod-fcgid: pkg.installed: - name: libapache2-mod-fcgid diff --git a/apache/php5.sls b/apache/php5.sls index b6b5710..ac28e87 100644 --- a/apache/php5.sls +++ b/apache/php5.sls @@ -1,8 +1,8 @@ +{% if grains['os_family']=="Debian" %} + include: - apt -{% if grains['os']=="Ubuntu" %} - mod-php5: pkg.installed: - name: libapache2-mod-php5 diff --git a/apache/register_site.sls b/apache/register_site.sls index 65eb618..1e6920f 100644 --- a/apache/register_site.sls +++ b/apache/register_site.sls @@ -1,3 +1,5 @@ +{% if grains['os_family']=="Debian" %} + {% if 'apache' in pillar and 'register-site' in pillar['apache'] %} #BEGIN: ['apache']['register-site'] {% for site in pillar['apache']['register-site'] %} @@ -44,3 +46,4 @@ a2dissite {{ pillar['apache']['register-site'][site]['name'] }}: {% endfor %} {% endif %} #END: apache-register-site +{% endif %} #END: grains['os_family'] == debian diff --git a/apache/rewrite.sls b/apache/rewrite.sls index 958c74a..51099f5 100644 --- a/apache/rewrite.sls +++ b/apache/rewrite.sls @@ -1,8 +1,8 @@ +{% if grains['os_family']=="Debian" %} + include: - apt -{% if grains['os']=="Ubuntu" %} - a2enmod rewrite: cmd.run: - unless: ls /etc/apache2/mods-enabled/rewrite.load From d29f634367f82e63a7eb1ce93ea20eb305673f82 Mon Sep 17 00:00:00 2001 From: Seth House Date: Tue, 13 Aug 2013 15:12:57 -0600 Subject: [PATCH 5/5] Updated README with these changes moved Pillar examples into pillar file --- README.rst | 57 +++++++++++++++++++++++++------------------------- pillar.example | 10 +++++++++ 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/README.rst b/README.rst index 8cd058d..bc1c7b6 100644 --- a/README.rst +++ b/README.rst @@ -1,41 +1,40 @@ apache ====== -DEPENDENCIES: - These salt-states are required: - 1) apt +Formulas to set up and configure the Apache HTTP server -POSSIBLE DEPENDENCIES - These salt-states may be required depending on what your doing: +.. note:: - 1) php + See the full `Salt Formulas installation and usage instructions + `_. -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. - 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 + These states are ordered using the ``order`` declaration. Different stages + are divided into the following number ranges: -PILLARS: + 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 - 1) No pillar data is required - 2) Full pillar structure: + Dependencies: -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' + * `apt `_ + + Optional dependencies: + + 1) `php `_ - 3) UNIQUE can be any name as an array index, and you can duplicate this section diff --git a/pillar.example b/pillar.example index e69de29..884db9a 100644 --- a/pillar.example +++ b/pillar.example @@ -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'