cookbook 'lamp_role', '= 0.1.0'
lamp_role (2) Versions 0.1.0 Follow4
Installs/Configures lamp_role
cookbook 'lamp_role', '= 0.1.0', :supermarket
knife supermarket install lamp_role
knife supermarket download lamp_role
LAMP cookbook
Role wrapper cookbook for LAMP stack.
This cookbook provides a full LAMP stack on Debian/Ubuntu platform.
Requirements
This cookbook is currently tested with the following setup:
- Chef: 11.10.4
- Ubuntu 12.04
This cookbook depends on the following cookbooks
- apache2 (~> 1.9.6)
- php
- ssl
- mysql_role
On Ubuntu/Debian, use Opscode's apt
cookbook to ensure the package
cache is updated so Chef can install packages, or consider putting
apt-get in your bootstrap process or
knife bootstrap template.
This cookbook (current version) will not work with apache 2.4 and ubuntu 14.04.
Usage
Include default recipe to get a full LAMP stack.
Attributes
This cookbook rewrite some apache2 attributes to suit LAMP stack need. You will likely edit some of them.
See [attributes file](attributes/default.rb) for latest version of overridden attributes
The following attributes are added by this cookbook
Additional attributes for apache default recipe
default[:lamp][:www_browser] = 'w3m' # Name of a package which provides www-browser
Default php modules
default[:lamp][:php_modules] = %w(mysql gd apc curl)
-
node[:lamp][:www_browser]
- textual browser package used to setupapache2ctl status
command. Defaultw3m
-
node[:lamp][:php_modules]
- PHP installed modules. Default%w(mysql gd apc curl)
These other attributes are used in php_application
definition described below
-
node[:php_applications][:applications_bag]
- reserved for future use. -
node[:php_applications][:apps_path]
- Base path where to put php applications. Defaultnode[:apache][:docroot_dir]
-
node[:php_applications][:user]
- Default owner for php applications. Defaultnode[:apache][:user]
-
node[:php_applications][:group]
- Default group for php applications. Defaultnode[:apache][:group]
-
node[:php_applications][:mysql_admin_credentials][:host]
- Database host where to create db users. Defaultlocalhost
-
node[:php_applications][:mysql_admin_credentials][:username]
- Administrative database user for creating db users. Defaultroot
-
node[:php_applications][:mysql_admin_credentials][:password]
- Administrative database password for creating db users. Defaultnode[:mysql][:server_root_password]
Recipes
Default
Install Apache2, PHP and MySQL on the target host. Apache default virtual host is overridden with [this template](templates/default/default-site.erb)
i.e. is configured to respond with '404 Not found' on every request.
Apache status is configured to respond on virtual host only, this can be useful in order to setup monit with apache protocol.
PHP is installed with modules given in attributes and prepared for MySQL integration.
MySQL is configured using this role cookbook
Definitions
php_application
This definition can be used to setup a virtual host for a php application. It accepts some parameters to configure
the application, here are the accepted configuration options and their default values:
-
basedir
- This will be the path where the application is stored. Default#{node[:php_applications][:apps_path]}/#{application_name}
-
owner
- Application folder owner. Defaultnode[:php_applications][:user]
-
group
- Application folder group. Application folder is configured with mode 2775, in this way any content created inside the folder can be shared with all members of this group. Defaultnode[:php_applications][:group]
-
canonical_hostname
- If given and not false the application a [rewrite rule](templates/default/apache_vhost.conf.erb#L45) is added to vhost configuration to redirect all requests made with non canonical hostname to the same path but with canonical hostname, useful for SEO. Defaultapplication_name
-
aliases
- An array of aliases for the given virtual host. Default[]
-
capistrano
- Prepare the virtual host for capistrano support, i.e. Point Document Root to"#{basedir}/current"
. Defaultfalse
-
zend_framework
- Prepare the virtual host for zend framework support, i.e. Point Document Root to"#{basedir}/public"
. Defaultfalse
-
mysql
- If hash can be used to create local users for the application (see [this example](recipes/_integration.rb#L37). Defaultfalse
-
users
- Additional system users to append to application group. Default[]
-
document_root
- Used to override application document root in virtual host configuration. Defaultnil
-
ssl
- SSL support for virtual host, need some documentation. Defaultfalse
Additional parameters can be given to configure php directives in virtual host file. They are hashes of php flags or values
-
php_values
- PHP values in apache config. Default{}
-
php_admin_values
- PHP admin values in apache config. Default{}
-
php_flags
- PHP flags in apache config. Default{}
-
php_admin_flags
- PHP admin flags in apache config. Default{}
A minimal example of php_application
definition is the following
# Plain php site with some features on php_application 'php.example.com' do application_config aliases: ['php2.example.com'], users: %w(vagrant) end
Full usage of this definition is shown in [this recipe](recipes/_integration.rb) and its
[serverspec](test/integration/default/serverspec/php_applications_spec.rb)
Author
Author:: Fabio Napoleoni (f.napoleoni@gmail.com)
Dependent cookbooks
mysql_role >= 0.0.0 |
apache2 ~> 1.9.6 |
php >= 0.0.0 |
ssl >= 0.0.0 |
Contingent cookbooks
There are no cookbooks that are contingent upon this one.
Foodcritic Metric
0.1.0 failed this metric
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/default.rb:3
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/default.rb:8
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/default.rb:9
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/default.rb:10
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/default.rb:11
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/default.rb:12
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/default.rb:13
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/default.rb:16
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/default.rb:19
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/default.rb:22
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/default.rb:25
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/default.rb:26
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/php_applications.rb:2
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/php_applications.rb:4
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/php_applications.rb:7
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/php_applications.rb:8
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/php_applications.rb:11
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/php_applications.rb:12
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/php_applications.rb:13
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/definitions/php_application.rb:13
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/definitions/php_application.rb:14
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/definitions/php_application.rb:15
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/definitions/php_application.rb:44
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/definitions/php_application.rb:45
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/definitions/php_application.rb:53
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/definitions/php_application.rb:57
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/definitions/php_application.rb:68
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/definitions/php_application.rb:96
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/recipes/apache2.rb:24
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/recipes/apache2.rb:27
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/recipes/apache2.rb:30
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/recipes/php_modules.rb:20
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/recipes/php_modules.rb:24
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/apache_vhost.conf.erb:25
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/apache_vhost.conf.erb:26
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/apache_vhost.conf.erb:27
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/apache_vhost.conf.erb:38
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/apache_vhost.conf.erb:39
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/apache_vhost.conf.erb:42
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/apache_vhost.conf.erb:59
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/apache_vhost.conf.erb:64
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/apache_vhost.conf.erb:65
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/apc.ini.erb:3
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/apc.ini.erb:8
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/default-site.erb:7
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/default-site.erb:13
FC007: Ensure recipe dependencies are reflected in cookbook metadata: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/definitions/php_application.rb:51
FC015: Consider converting definition to a LWRP: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/definitions/php_application.rb:1
FC019: Access node attributes in a consistent manner: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/recipes/php_modules.rb:32
FC023: Prefer conditional attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/recipes/php_modules.rb:24
0.1.0 failed this metric
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/default.rb:8
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/default.rb:9
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/default.rb:10
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/default.rb:11
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/default.rb:12
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/default.rb:13
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/default.rb:16
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/default.rb:19
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/default.rb:22
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/default.rb:25
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/default.rb:26
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/php_applications.rb:2
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/php_applications.rb:4
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/php_applications.rb:7
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/php_applications.rb:8
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/php_applications.rb:11
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/php_applications.rb:12
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/attributes/php_applications.rb:13
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/definitions/php_application.rb:13
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/definitions/php_application.rb:14
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/definitions/php_application.rb:15
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/definitions/php_application.rb:44
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/definitions/php_application.rb:45
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/definitions/php_application.rb:53
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/definitions/php_application.rb:57
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/definitions/php_application.rb:68
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/definitions/php_application.rb:96
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/recipes/apache2.rb:24
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/recipes/apache2.rb:27
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/recipes/apache2.rb:30
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/recipes/php_modules.rb:20
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/recipes/php_modules.rb:24
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/apache_vhost.conf.erb:25
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/apache_vhost.conf.erb:26
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/apache_vhost.conf.erb:27
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/apache_vhost.conf.erb:38
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/apache_vhost.conf.erb:39
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/apache_vhost.conf.erb:42
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/apache_vhost.conf.erb:59
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/apache_vhost.conf.erb:64
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/apache_vhost.conf.erb:65
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/apc.ini.erb:3
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/apc.ini.erb:8
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/default-site.erb:7
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/templates/default/default-site.erb:13
FC007: Ensure recipe dependencies are reflected in cookbook metadata: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/definitions/php_application.rb:51
FC015: Consider converting definition to a LWRP: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/definitions/php_application.rb:1
FC019: Access node attributes in a consistent manner: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/recipes/php_modules.rb:32
FC023: Prefer conditional attributes: /tmp/cook/bd881528b66b192e4c51fb1b/lamp_role/recipes/php_modules.rb:24