Giter Club home page Giter Club logo

puppet-webapp's Introduction

Puppet Webapp

puppet forge version last tag

Wrapper to create resources that compound webapps.

Resources are declared exported, and realized on the same node by default.

Exported resources are tagged with node's FQDN and realized in those nodes upon the presence of the classes that implements the resources.

Dependencies

This module does not have any hard dependency (but stdlib) so it can work infrastructure-wide.

These are the modules Webapp works with:

How it works

First, include webapp class in each node of your infrastructure that may realize a part of the webapp (apache, mysql, solr).

Second, create webapp instances tagged with the fqdn of each node involved.

Webapp instances must be created only on one node. It doesn't need to be one of the tag nodes. For example, use the one you consider the master.

Example of use

Class webapp accepts $instances and $instance_defaults parameters. So you can define webapps in hiera as follows:

---
webapp::instance_defaults :
  port         : 80
  db_ensure    : present
  hosts_ensure : present
  vhost_ensure : present
  tags         :
    - dbserver
    - webhead1
    - webhead2

webapp::instances :

# Create a webapp called `foobar.com`.
#  - Servername is by default the resource name: foobar.com
#  - Database name is derived from the resource name: foobar_com
#  - Database username and password are the database name.
  foobar.com      : {}

# Create webapp `barbaz.com` without database.
# Providing ~ or null as the value for db_ensure means undef.
  barbaz.com      :
    db_ensure     : ~

# Create webapp with name `ex`. This is the database name and user. Password
# is provided explicitly. Servername is provided explicitly, along with
# redirects and custom configuration for the virtual host.
# `vhost_ensure : present` will enforce a redirect 301 from example.com
# to www.example.com.
# This webapp is declared of type `drupal`, so a drush alias (name `ex`) will
# also be declared.
  ex              :
    type          : drupal
    servername    : example.com
    www_ensure    : present
    serveraliases :
      - example.net
      - www.example.net
    redirects     :
      '302'       :
        - source  : /under-construction
          dest    : http://www.example.info/landing
    vhost_extra   : |
      ExpiresActive  On
      ExpiresDefault "access plus 10 minutes"
    db_pass       : s3cr3t
    db_grants     :
      'root@localhost/*.*':
        options    : ['GRANT']
        privileges : ['ALL']
        table      : '*.*'
        user       : 'root@localhost'
      'reader@localhost/ex.*'
        options    : ['GRANT']
        privileges : ['SELECT']
        table      : 'ex.*'
        user       : 'reader@localhost'
    cron           :
      cron1 :
        command : '/usr/local/bin/cronjob.sh'
        hour    : 23
        minute  : 12

As shown webapp instances allows to define the virtualhost, database or solr instance behaviour to some extent. See webapp/instance.pp for detailed documentation on accepted parameters.

License

MIT License, see LICENSE file

Contact

Use contact form on http://sbit.io

Support

Please log tickets and issues on GitHub

puppet-webapp's People

Contributors

jonhattan avatar niteman avatar krismagjistari avatar

Stargazers

Manuel Egío avatar

Watchers

 avatar  avatar James Cloos avatar

Forkers

lkristianl

puppet-webapp's Issues

Accept an array in vhost_extra

vhost_extra at present accepts a string that is passed to apache::vhost custom_fragment.

It would be nice to accept an array and internally convert it to a string.

An array allows for better templating in hiera, by using yaml anchors and hiera lookup/alias.

Example:

# Define the general snippet to enable php fpm proxy. This snippet uses an apache defined variable for the fpmm port.
webapp__fpm : >
  <FilesMatch \.php$>
    SetHandler 'proxy:fcgi://127.0.0.1:${PHP_FPM_PORT}'
  </FilesMatch>

# Define the general structure for all instances of the "api" webapp.
# Here we set the value for the PHP_FPM_PORT before using it.
webapp__api : &api
  vhost_extra : &vhost_extra_base
    - Define PHP_FPM_PORT 9001
    - %{hiera('webapp__fpm')}

# Declare dev and prod webapps.
# In the case of prod, pick the base vhost_extra and extend with more directives. This way we avoid duplication.
webapp::instances :
  api_dev :
    <<          : *api
    servername  : 'api.dev.example.com'
    tags : 
      - dev.node.tld
  api_prod :
    <<          : *api
    servername  : 'api.example.com'
    vhost_extra :
      - *vhost_extra_base
      - php_value newrelic.appname "api.example.com"
    tags        :
      - prod.node.tld

Note the vhost_extra definition in api_prod produces a nested array:

vhost_extra:
  - - Define PHP_FPM_PORT 9001
    - |
    <FilesMatch \.php$>
      SetHandler "proxy:fcgi://127.0.0.1:{PHP_FPM_PORT}"
    </FilesMatch>
  - php_value newrelic.appname "api.example.com"

So the solution must flatten the array.

/cc @sbitio/owners

Drop ssl support

In the aim to reduce complexity.

Same configuration can be acomplished by using vhost_extra_params.

Before:

webapp::instances :
  example-ssl :
    servername  : 'example.com'
    www_ensure  : 'present'
    ssl         : true
    ssl_options :
      cert             : '/opt/certs/example.com/example.com.cert'
      key              : '/opt/certs/example.com/example.com.key'
      ca               : '/opt/certs/example.com/example.com.ca'
      protocol         : 'all -SSLv2 -SSLv3'
      cipher           : 'AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS'
      honorcipherorder : 'On'

After:

webapp::instances :
  example-ssl :
    servername : 'example.com'
    www_ensure : 'present'
    port       : 443
    vhost_extra_params :
      ssl                  : true
      ssl_cert             : '/opt/certs/example.com/example.com.cert'
      ssl_key              : '/opt/certs/example.com/example.com.key'
      ssl_ca               : '/opt/certs/example.com/example.com.ca'
      ssl_protocol         : 'all -SSLv2 -SSLv3'
      ssl_cipher           : 'AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS'
      ssl_honorcipherorder : 'On'

Declare all resources as external

No need to differentiate external from local.

Get rid of creation mode.

Get rid of create_resources(). It doesn't work for external resources in Puppet 4.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.