Skip to content
Gary Hale edited this page Jul 30, 2013 · 31 revisions

Gradle Glu Plugin

This is a plugin for programmatically controlling glu deployment servers using gradle. This plugin allows you to store your glu json model in source control and apply it to the fabric as a gradle task. The model can be stored as a json file or generated using Maps or JsonBuilder closures. It also provides a simple templating function where an "application" is defined that can generate entries for multiple agents with agent-specific overrides.

Configuring Fabrics

The following example shows a basic configuration where the model is stored in the project as a file and applied to the server without changes.

apply plugin: "glu"

glu {
        servers {
                test {
                        url "http://localhost:8080/console"
                        username "admin"
                        password "admin"
                }
        }

        fabrics {
                "glu-test-1" {
                        server servers.test
                        zookeeper "localhost:2181"
                        model file("model.json")
                }
        }
}

The next example shows how to programmatically build a model and use applications to create template configurations for model entries.

apply plugin: "glu"

glu {
        servers {
                test {
                        url "http://localhost:8080/console"
                        username "admin"
                        password "admin"
                }
        }

        applications {
                app1 {
                        mountPoint "/app1"
                        script "http://localhost:8080/glu/repository/scripts/app1_deployment_script.groovy"
                        tags = [ 'app1' ]
                }
        }

        fabrics {
                "glu-test-1" {
                        server servers.test
                        zookeeper "localhost:2181"
                        model merge(
                                applications.app1.generate([
                                        'agents': [ 'agent-1': [ 'tst1', 'step001' ] ],
                                        'initParameters': [ "port": 9000 ]
                                ])
                        )
                        model merge(
                                applications.app1.generate([
                                        'agents': [ 
                                                    'agent-2': [ 'tst2', 'step002' ],
                                                    'agent-3': [ 'tst2', 'step003' ]
                                                  ],
                                        'initParameters': [ "port": 9001 ]
                                ])
                        )
                }
        }
}

In the example above, we create an application that is deployed on multiple agents. We use a single application definition to define the mountpoint, the script and any tags that we want to apply to all instances of the application. Then we generate an entry in the model for each agent that we want to deploy this application on, setting any agent-specific values. Note that we can define multiple agents in a single generate call that use the same initParameters. This approach has value when there are dozens of agents where the same application is being deployed. Each agent can have specific tags applied to it (along with any tags applied at the application level) which would allow you to cross-cut execution plans on different sets of agents.

Clone this wiki locally