Several installations of my application - how do I handle this

I have an application written in PHP, MySQL, etc. The application has several dependencies, such as beanstalkd, Solr, and several PHP extensions.

For each client, we have a separate application installation, either on a server that is shared with other clients, or on a server with this client only.

We currently use the Puppet script to download new clients, and then we manually go to each client to do git pull, update db, etc., when something changes.

What we are looking for is really a tool that has as many of the following features as possible:

  • A web interface that allows us to see all customers and their current version.
  • Ability to download new installations
  • Ability to upgrade existing installations to a specific version or branch

We are not looking for a tool to download new servers - we still do it manually. Instead, we are looking for a way to automate client configuration on an existing server.

Is there enough chef or doll for this, is there a more suitable tool or do you yourself recommend something to do?

+6
source share
1 answer

I am a full-time developer working on Puppet at Puppet Labs. I also co-authored Pro Puppet.

Puppets are certainly sufficient for your purposes. Here is one way to solve this problem using Puppet. First, I will turn to dependency management, since they should only be managed once, no matter how many instances of the application are managed. Then I will talk about how to handle several installations of your application using a specific resource type in the resource type Puppet and vcsrepo .

Firstly, regarding the organization of puppet code to handle several installations of the same application. The dependencies you specify, such as beanstalkd, solr, and PHP extensions, must be modeled using the Puppet class. This class will be included in the configuration directory only once, regardless of how many copies of the application are managed on the node. An example of this class might be something like:

 # <modulepath>/site/manifests/app_dependencies.pp class site::app_dependencies { # Make all package resources in this class default to # being managed as installed on the node Package { ensure => installed } # Now manage the dependencies package { 'php': } package { 'solr': } package { 'beanstalk': } # The beanstalk worker queue service needs to be running service { 'beanstalkd': ensure => running, require => Package['beanstalk'], } } 

Now that you have the dependencies in the class, you can simply include this class in the nodes where your application will be deployed. This usually happens in the site.pp file or in the Puppet Dashboard if you use the web interface.

 # $(puppet config print confdir)/manifests/site.pp node www01 { include site::app_dependencies } 

Next, you need to specify how to declare multiple instances of the application on the system. Unfortunately, right now there is no easy way to do this from the web interface, but you can use Puppet manifests and a specific resource type. This solution uses the vcsrepo resource to control the validation of the git repository for the application.

 # <modulepath>/myapp/manifests/instance.pp define myapp::instance($git_rev='master') { # Resource defaults. The owner and group might be the web # service account instead of the root account. File { owner => 0, group => 0, mode => 0644, } # Create a directory for the app. The resource title will be copied # into the $name variable when this resource is declared in Puppet file { "/var/lib/myapp/${name}": ensure => directory } # Check out the GIT repository at a specific version vcsrepo { "/var/lib/myapp/${name}/working_copy": ensure => present, provider => git, source => 'git://github.com/puppetlabs/facter.git', revision => $git_rev, } } 

With this specific resource type, you can declare several installations of your application as follows:

 # $(puppet config print confdir)/manifests/site.pp node www01 { include site::app_dependencies # Our app instances always need their dependencies to be managed first. Myapp::Instance { require => Class['site::app_dependencies'] } # Multiple instances of the application myapp::instance { 'jeff.acme.com': git_rev => 'tags/1.0.0' } myapp::instance { 'josh.acme.com': git_rev => 'tags/1.0.2' } myapp::instance { 'luke.acme.com': git_rev => 'tags/1.1.0' } myapp::instance { 'teyo.acme.com': git_rev => 'master' } } 

Unfortunately, there is currently no easy-to-use way out of the box to make this information visible from the web GUI. However, of course, you can use the external Node API. For more information on pulling external data into Puppet, see these resources:

We hope this information helps.

+10
source

Source: https://habr.com/ru/post/905557/


All Articles