How to provision the LAMP stack for mass hosting


#1

Hi,

I’m trying to figure out a concept for provisioning PHP-based vhosts
(apache or nginx), while not deploying the PHP application itself.
(instead site owner should have access to install their application).

Probably via a data bag (or not?) I’d like to give only some information
(thinking of the domain name, an SSH key and the node name on which the
site should reside), which then should trigger e.g.

  • user “#{domain}” (with corresponding SSH key)
  • directory “/var/www/#{domain}”
  • php_fpm “#{domain}”
  • nginx_site “#{domain}”
  • mysql_user “#{domain.gsub(/./, ‘’)”
  • mysql_database “#{domain.gsub(/./, ‘’)”
  • file “/var/www/vhost/#{domain}/mysql-password.txt” do
    content mysql.users.domain
    end

Has anybody a solution for this or a ruby-like counterpart, at which I
could look at?

All the examples (which are able to deploy more than one vhost) made use
of the application cookbook - which looks like a good way to go. But
what if I - as said - don’t want to deploy the PHP code itself?

Should I try to use the application cookbook, or would a custom LWRP
reading the data bags and triggering the resources mentioned above fit
better? However, it feels a bit like reinventing the wheel.

Thanks for your comments!
Steffen

P.S: I’m thinking of ~10-20 vhosts per server… not thousands of them.


#2

I personally would be inclined to create a custom LWRP that provides only
what is needed, but the application resource (and its subresources) do
allow you to inject a subtype of Chef::Provider::Deploy and
Chef::Provider::SCM. You may be able to inject a custom provider for one or
more of these concerns and reuse the application cookbook this way.

Using data bag items to store these definitions makes sense, but you may
want to group them into a data bag for each host, or add a key that
establishes affinity between an application and its hosts.

On Mon, Apr 8, 2013 at 8:04 AM, Steffen Gebert st+gmane@st-g.de wrote:

Hi,

I’m trying to figure out a concept for provisioning PHP-based vhosts
(apache or nginx), while not deploying the PHP application itself.
(instead site owner should have access to install their application).

Probably via a data bag (or not?) I’d like to give only some information
(thinking of the domain name, an SSH key and the node name on which the
site should reside), which then should trigger e.g.

  • user “#{domain}” (with corresponding SSH key)
  • directory “/var/www/#{domain}”
  • php_fpm “#{domain}”
  • nginx_site “#{domain}”
  • mysql_user “#{domain.gsub(/./, ‘’)”
  • mysql_database “#{domain.gsub(/./, ‘’)”
  • file “/var/www/vhost/#{domain}/mysql-password.txt” do
    content mysql.users.domain
    end

Has anybody a solution for this or a ruby-like counterpart, at which I
could look at?

All the examples (which are able to deploy more than one vhost) made use
of the application cookbook - which looks like a good way to go. But
what if I - as said - don’t want to deploy the PHP code itself?

Should I try to use the application cookbook, or would a custom LWRP
reading the data bags and triggering the resources mentioned above fit
better? However, it feels a bit like reinventing the wheel.

Thanks for your comments!
Steffen

P.S: I’m thinking of ~10-20 vhosts per server… not thousands of them.


Jeremy Voorhis


#3

Thanks for your response, Jeremy.

I will try to go with data bags + a custom LWRP bundling directories,
vhost, data base etc.

Yours
Steffen

On 4/8/13 6:18 PM, Jeremy Voorhis wrote:

I personally would be inclined to create a custom LWRP that provides only
what is needed, but the application resource (and its subresources) do
allow you to inject a subtype of Chef::Provider::Deploy and
Chef::Provider::SCM. You may be able to inject a custom provider for one or
more of these concerns and reuse the application cookbook this way.

Using data bag items to store these definitions makes sense, but you may
want to group them into a data bag for each host, or add a key that
establishes affinity between an application and its hosts.

On Mon, Apr 8, 2013 at 8:04 AM, Steffen Gebert st+gmane@st-g.de wrote:

Hi,

I’m trying to figure out a concept for provisioning PHP-based vhosts
(apache or nginx), while not deploying the PHP application itself.
(instead site owner should have access to install their application).

Probably via a data bag (or not?) I’d like to give only some information
(thinking of the domain name, an SSH key and the node name on which the
site should reside), which then should trigger e.g.

  • user “#{domain}” (with corresponding SSH key)
  • directory “/var/www/#{domain}”
  • php_fpm “#{domain}”
  • nginx_site “#{domain}”
  • mysql_user “#{domain.gsub(/./, ‘’)”
  • mysql_database “#{domain.gsub(/./, ‘’)”
  • file “/var/www/vhost/#{domain}/mysql-password.txt” do
    content mysql.users.domain
    end

Has anybody a solution for this or a ruby-like counterpart, at which I
could look at?

All the examples (which are able to deploy more than one vhost) made use
of the application cookbook - which looks like a good way to go. But
what if I - as said - don’t want to deploy the PHP code itself?

Should I try to use the application cookbook, or would a custom LWRP
reading the data bags and triggering the resources mentioned above fit
better? However, it feels a bit like reinventing the wheel.

Thanks for your comments!
Steffen

P.S: I’m thinking of ~10-20 vhosts per server… not thousands of them.