Skip to content

Commit f8db54f

Browse files
committed
simpleapplication: new sketch; simpleapplication-deploy: new sketch
1 parent 82eecfa commit f8db54f

File tree

12 files changed

+589
-19
lines changed

12 files changed

+589
-19
lines changed

sketches/applications/newrelic/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Tags: cfdc, newrelic, enterprise_compatible
55
Authors: Ted Zlatanov <[email protected]>
66

77
## Description
8-
Sketch for installing, configuring, and starting New Relic.
8+
Sketch for installing, configuring, and starting New Relic monitoring plugins (only server monitoring supported at the moment).
99

1010
## Dependencies
1111
CFEngine::dclib, CFEngine::stdlib
@@ -16,9 +16,9 @@ CFEngine::dclib, CFEngine::stdlib
1616

1717
* parameter _metadata_ *metadata* (default: none, description: none)
1818

19-
* parameter _string_ *license_key* (default: `"not valid"`, description: none)
19+
* parameter _string_ *license_key* (default: `"not valid"`, description: New Relic license key)
2020

21-
* parameter _boolean_ *ensure* (default: `true`, description: Ensure service is running. Set to false to stop service.)
21+
* parameter _boolean_ *ensure* (default: `true`, description: Ensure server monitoring service is running. Set to false to stop service.)
2222

2323
* parameter _boolean_ *install* (default: `true`, description: Install packages. Set to false to remove them.)
2424

sketches/cfsketches.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ databases/mysql_install_simple {"api":{"simple":[{"name":"runenv","type":"enviro
1919
databases/postgresql_install {"api":{"ensure":[{"name":"runenv","type":"environment"},{"name":"mymetadata","type":"metadata"},{"name":"server","type":"boolean"},{"default":false,"name":"purge","type":"boolean"},{"default":[],"name":"extra_packages","type":"list"},{"default":false,"name":"use_only_extra_packages","type":"boolean"},{"name":"installed","type":"return"},{"name":"running","type":"return"}]},"interface":["main.cf"],"manifest":{"README.md":{"documentation":true},"main.cf":{"desc":"main file"},"params/demo_client.json":{"comment":"Install PostgreSQL client"},"params/demo_server.json":{"comment":"Install PostgreSQL server"}},"metadata":{"authors":["Nakarin Phooripoom <[email protected]>","Ted Zlatanov <[email protected]>"],"depends":{"CFEngine::dclib":{},"CFEngine::dclib::3.5.0":{},"CFEngine::stdlib":{"version":105},"cfengine":{"version":"3.5.0"},"os":["linux"]},"description":"Install and enable the PostgreSQL database engine","license":"MIT","name":"Database::Install::PostgreSQL","tags":["cfdc"],"version":1.1},"namespace":"cfdc_db_postgresql"}
2020
databases/postgresql_install_simple {"api":{"simple":[{"name":"runenv","type":"environment"},{"name":"mymetadata","type":"metadata"},{"name":"installed","type":"return"},{"name":"running","type":"return"}]},"interface":["main.cf"],"manifest":{"README.md":{"documentation":true},"main.cf":{"desc":"main file"},"params/demo_client.json":{"comment":"Install PostgreSQL client"},"params/demo_server.json":{"comment":"Install PostgreSQL server"}},"metadata":{"authors":["Nakarin Phooripoom <[email protected]>","Ted Zlatanov <[email protected]>"],"depends":{"CFEngine::dclib":{},"CFEngine::dclib::3.5.0":{},"CFEngine::stdlib":{"version":105},"cfengine":{"version":"3.5.0"},"os":[{"redhat_6":"Red Hat 6","ubuntu_12_4":"Ubuntu 12.4"}]},"description":"Install and enable the PostgreSQL database engine","license":"MIT","name":"Database::Install::PostgreSQL::Simple","tags":["cfdc","database","postgresql","enterprise_compatible"],"version":1.1},"namespace":"cfdc_db_postgresql"}
2121
databases/sqlite_install {"api":{"ensure":[{"name":"runenv","type":"environment"},{"name":"mymetadata","type":"metadata"},{"default":false,"name":"purge","type":"boolean"},{"default":[],"name":"extra_packages","type":"list"},{"default":false,"name":"use_only_extra_packages","type":"boolean"},{"name":"installed","type":"return"}]},"interface":["main.cf"],"manifest":{"README.md":{"documentation":true},"main.cf":{"desc":"main file"},"params/demo.json":{"comment":"Install SQLite"}},"metadata":{"authors":["Nakarin Phooripoom <[email protected]>","Ted Zlatanov <[email protected]>"],"depends":{"CFEngine::dclib":{},"CFEngine::dclib::3.5.0":{},"CFEngine::stdlib":{"version":105},"cfengine":{"version":"3.5.0"},"os":["linux"]},"description":"Install and enable the SQLite database engine","license":"MIT","name":"Database::Install::SQLite","tags":["cfdc"],"version":1.1},"namespace":"cfdc_db_sqlite"}
22+
demo/simpleapplication-deploy {"api":{"deploy":[{"name":"runenv","type":"environment"},{"name":"mymetadata","type":"metadata"},{"description":"Number of web workers","name":"workers","type":"string"},{"default":true,"description":"Enable this deployment? (if disabled, destroy the VMs)","name":"enable","type":"boolean"}]},"interface":["deploy.cf"],"manifest":{"README.md":{"documentation":true},"deploy.cf":{"desc":"main file"},"params/demo.json":{"desc":"example parameters"}},"metadata":{"authors":["Ted Zlatanov <[email protected]>"],"depends":{"Cloud::Services::VMWare":{},"Demo::SimpleApplication":{},"cfengine":{"version":"3.5.0"},"os":[{"linux":"All Linux distributions"}]},"description":"Deploy a full infrastructure for a simple application","license":"MIT","name":"Demo::SimpleApplication::Deploy","tags":["vmware","ensure","deploy","demo","sketchify_generated","enterprise_compatible"],"version":"1.0"},"namespace":"cfdc_simpleapplication"}
23+
demo/simpleapplication {"api":{"configure":[{"name":"runenv","type":"environment"},{"name":"metadata","type":"metadata"}]},"interface":["balance.cf"],"manifest":{"README.md":{"documentation":true},"balance.cf":{"desc":"main file"}},"metadata":{"authors":["Nick Anderson <[email protected]>","Ted Zlatanov <[email protected]>","Diego Zamboni <[email protected]>"],"depends":{"cfengine":{"version":"3.5.0"},"os":[{"centos":"CentOS Linux"}]},"description":"Configures hosts for a simple application consisting of webworkers (Apache + simple static content), haworkers (haproxy dynamically configured to use the existing webworkers) and mcworkers (memcached)","license":"MIT","name":"Demo::SimpleApplication","tags":["vmworld2013","demo","sketchify_generated","enterprise_compatible"],"version":"1.0"},"namespace":"cfdc_simpleapplication"}
2224
libraries/blueprint {"api":{},"interface":["library.cf"],"manifest":{"README.md":{"documentation":true},"library.cf":{"desc":"Blueprint to Design Center glue library"},"test.pl":{"test":true}},"metadata":{"authors":["CFEngine AS"],"depends":{"cfengine":{"version":"3.5.0"}},"description":"Library to connect Blueprint sketches with Design Center","license":"MIT","name":"CFEngine::Blueprint","tags":["cfdc","blueprint"],"version":"1.0.0"}}
2325
libraries/copbl-3.5.0 {"api":{},"interface":["stdlib-350.cf"],"manifest":{"README.md":{"documentation":true},"stdlib-350.cf":{"desc":"COPBL"},"test.pl":{"test":true}},"metadata":{"authors":["CFEngine AS"],"depends":{"cfengine":{"version":"3.5.0"}},"description":"The portions of the CFEngine standard library (also known as COPBL) that are only compatible with 3.5.0 and higher","license":"LGPL","name":"CFEngine::stdlib::3.5.0","tags":["cfdc"],"version":110},"namespace":null}
2426
libraries/copbl {"api":{},"interface":["cfengine_stdlib.cf"],"manifest":{"README.md":{"documentation":true},"cfengine_stdlib.cf":{"desc":"COPBL"},"test.pl":{"test":true}},"metadata":{"authors":["CFEngine AS","ahdinosaur"],"depends":{"cfengine":{"version":"3.4.0"}},"description":"The portions of the CFEngine standard library (also known as COPBL) that are compatible with 3.4.0 releases","license":"LGPL","name":"CFEngine::stdlib","tags":["cfdc"],"version":111},"namespace":null}

sketches/cloud/autobalance/main.cf

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ bundle agent autobalance(runenv, metadata, url, collector, thresholds, given_ec2
5353
$(common_options)),
5454
ifvarclass => "default:autobalance_$(threshold_names)";
5555

56-
"ensure VMWare" usebundle => cfdc_cloud_openstack:ensure($(runenv),
57-
"",
58-
"$($(thresholds)[$(threshold_names)][vmware])",
59-
nth("vmware_options", 0),
60-
nth("vmware_options", 1),
61-
nth("vmware_options", 2),
62-
nth("vmware_options", 3),
63-
nth("vmware_options", 4),
64-
nth("vmware_options", 5),
65-
$(common_options)),
56+
"ensure VMWare" usebundle => cfdc_cloud_vmware:ensure($(runenv),
57+
"",
58+
"$($(thresholds)[$(threshold_names)][vmware])",
59+
nth("vmware_options", 0),
60+
nth("vmware_options", 1),
61+
nth("vmware_options", 2),
62+
nth("vmware_options", 3),
63+
nth("vmware_options", 4),
64+
nth("vmware_options", 5),
65+
$(common_options)),
6666
ifvarclass => "default:autobalance_$(threshold_names)";
6767

6868
reports:

sketches/cloud/vmware/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Cloud::Services::VMWare version 1
22

33
License: MIT
4-
Tags: cfdc, cloud, vmware, vcli
4+
Tags: cfdc, cloud, vmware, vcli, enterprise_compatible
55
Authors: Ted Zlatanov <[email protected]>
66

77
## Description
8-
Manage VMWare services through the vSphere Perl SDK
8+
Manage VMWare services through the vSphere Perl SDK and other external tools.
99

1010
## Dependencies
1111
CFEngine::dclib, CFEngine::dclib::3.5.0, CFEngine::stdlib
@@ -16,11 +16,11 @@ CFEngine::dclib, CFEngine::dclib::3.5.0, CFEngine::stdlib
1616

1717
* parameter _metadata_ *mymetadata* (default: none, description: none)
1818

19-
* parameter _string_ *count* (default: none, description: none)
19+
* parameter _string_ *count* (default: none, description: Number of VMs you want to ensure are running.)
2020

21-
* parameter _string_ *class* (default: none, description: Logical class to assign to machines)
21+
* parameter _string_ *class* (default: none, description: Logical class to assign to the created virtual machines)
2222

23-
* parameter _boolean_ *install_cfengine* (default: none, description: none)
23+
* parameter _boolean_ *install_cfengine* (default: none, description: Whether CFEngine should be installed on the new VMs)
2424

2525
* parameter _string_ *hub* (default: none, description: Hub from which the instances should bootstrap)
2626

@@ -30,7 +30,7 @@ CFEngine::dclib, CFEngine::dclib::3.5.0, CFEngine::stdlib
3030

3131
* parameter _string_ *count_command* (default: none, description: Command to count VMs. Parameters: CLASS)
3232

33-
* parameter _array_ *options* (default: none, description: Options)
33+
* parameter _array_ *options* (default: `{}`, description: Options)
3434

3535
* returns _return_ *instance_count* (default: none, description: none)
3636

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Demo::SimpleApplication::Deploy version 1.0
2+
3+
License: MIT
4+
Tags: vmware, ensure, deploy, demo, sketchify_generated, enterprise_compatible
5+
Authors: Ted Zlatanov <[email protected]>
6+
7+
## Description
8+
Deploy a full infrastructure for a simple application
9+
10+
## Dependencies
11+
Cloud::Services::VMWare, Demo::SimpleApplication
12+
13+
## API
14+
### bundle: deploy
15+
* parameter _environment_ *runenv* (default: none, description: none)
16+
17+
* parameter _metadata_ *mymetadata* (default: none, description: none)
18+
19+
* parameter _string_ *workers* (default: none, description: Number of web workers)
20+
21+
* parameter _boolean_ *enable* (default: `true`, description: Enable this deployment? (if disabled, destroy the VMs))
22+
23+
24+
## SAMPLE USAGE
25+
See `test.cf` or the example parameters provided
26+
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
body file control
2+
{
3+
namespace => "cfdc_simpleapplication";
4+
}
5+
6+
bundle agent deploy(runenv, metadata, workers, enable)
7+
{
8+
9+
classes:
10+
"$(vars)" expression => "default:runenv_$(runenv)_$(vars)";
11+
"not_$(vars)" expression => "!default:runenv_$(runenv)_$(vars)";
12+
13+
"enable" expression => strcmp("$(enable)", "1");
14+
15+
vars:
16+
"activation_id" string => canonify("$(this.bundle)_$($(metadata)[activation][identifier])_$($(metadata)[activation][timestamp])");
17+
18+
"vars" slist => { "@(default:$(runenv).env_vars)" };
19+
"$(vars)" string => "$(default:$(runenv).$(vars))";
20+
21+
"singles" slist => { "haworker", "mcworker" };
22+
23+
classes:
24+
"$(type)" expression => "any";
25+
26+
vars:
27+
"host_marker" string => ".removal.marker";
28+
"type" string => ifelse("am_policy_hub", "hub",
29+
classmatch("webworker.*"), "webworker",
30+
classmatch("mcworker.*"), "mcworker",
31+
classmatch("haworker.*"), "haworker",
32+
"unknown");
33+
34+
methods:
35+
any::
36+
"deploy" usebundle => cfdc_simpleapplication:configure(runenv, ""),
37+
handle => "$(activation_id)_simpleapplication_deploy_configure";
38+
39+
hub.enable::
40+
"ensure webworkers" usebundle => cfdc_cloud_vmware:ensure($(runenv),
41+
"",
42+
$(workers),
43+
"webworker",
44+
"1",
45+
$(sys.ipv4),
46+
"/var/cfengine/scripts/start_vm.sh",
47+
"/var/cfengine/scripts/stop_vm.sh",
48+
"/var/cfengine/scripts/count_vm.sh",
49+
"return"),
50+
handle => "$(activation_id)_simpleapplication_ensure_webworkers";
51+
52+
"ensure singles" usebundle => cfdc_cloud_vmware:ensure($(runenv),
53+
"",
54+
"1",
55+
$(singles),
56+
"1",
57+
$(sys.ipv4),
58+
"/var/cfengine/scripts/start_vm.sh",
59+
"/var/cfengine/scripts/stop_vm.sh",
60+
"/var/cfengine/scripts/count_vm.sh",
61+
"return"),
62+
handle => "$(activation_id)_simpleapplication_ensure_singles";
63+
64+
hub.!enable::
65+
"ensure no webworkers" usebundle => cfdc_cloud_vmware:ensure($(runenv),
66+
"",
67+
"0",
68+
"webworker",
69+
"1",
70+
$(sys.ipv4),
71+
"/var/cfengine/scripts/start_vm.sh",
72+
"/var/cfengine/scripts/stop_vm.sh",
73+
"/var/cfengine/scripts/count_vm.sh",
74+
"return"),
75+
handle => "$(activation_id)_simpleapplication_disable_webworkers";
76+
77+
"ensure no singles" usebundle => cfdc_cloud_vmware:ensure($(runenv),
78+
"",
79+
"0",
80+
$(singles),
81+
"1",
82+
$(sys.ipv4),
83+
"/var/cfengine/scripts/start_vm.sh",
84+
"/var/cfengine/scripts/stop_vm.sh",
85+
"/var/cfengine/scripts/count_vm.sh",
86+
"return"),
87+
handle => "$(activation_id)_simpleapplication_disable_singles";
88+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"Demo::SimpleApplication::Deploy":
3+
{
4+
workers: 3
5+
}
6+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"api" : {
3+
"deploy" : [
4+
{ type: "environment", name: "runenv", },
5+
{ type: "metadata", name: "mymetadata", },
6+
{
7+
"description" : "Number of web workers",
8+
"name" : "workers",
9+
"type" : "string"
10+
},
11+
{
12+
"description" : "Enable this deployment? (if disabled, destroy the VMs)",
13+
"name" : "enable",
14+
"type" : "boolean",
15+
"default": true
16+
}
17+
]
18+
},
19+
"interface" : [
20+
"deploy.cf"
21+
],
22+
"manifest" : {
23+
"params/demo.json": { desc: "example parameters" },
24+
"README.md" : {
25+
"documentation" : true
26+
},
27+
"deploy.cf" : {
28+
"desc" : "main file"
29+
}
30+
},
31+
"metadata" : {
32+
"authors" : [
33+
"Ted Zlatanov <[email protected]>"
34+
],
35+
"description" : "Deploy a full infrastructure for a simple application",
36+
"license" : "MIT",
37+
"name" : "Demo::SimpleApplication::Deploy",
38+
"tags" : [
39+
"vmware",
40+
"ensure",
41+
"deploy",
42+
"demo",
43+
"sketchify_generated",
44+
"enterprise_compatible"
45+
],
46+
"version" : "1.0",
47+
depends: { "Demo::SimpleApplication": { }, "Cloud::Services::VMWare": {}, cfengine: { version: "3.5.0" },
48+
"os" : [ {"linux" : "All Linux distributions"} ]
49+
}
50+
},
51+
"namespace" : "cfdc_simpleapplication"
52+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Demo::SimpleApplication version 1.0
2+
3+
License: MIT
4+
Tags: vmworld2013, demo, sketchify_generated, enterprise_compatible
5+
Authors: Nick Anderson <[email protected]>, Ted Zlatanov <[email protected]>, Diego Zamboni <[email protected]>
6+
7+
## Description
8+
Configures hosts for a simple application consisting of webworkers (Apache + simple static content), haworkers (haproxy dynamically configured to use the existing webworkers) and mcworkers (memcached)
9+
10+
## Dependencies
11+
none
12+
13+
## API
14+
### bundle: configure
15+
* parameter _environment_ *runenv* (default: none, description: none)
16+
17+
* parameter _metadata_ *metadata* (default: none, description: none)
18+
19+
20+
## SAMPLE USAGE
21+
See `test.cf` or the example parameters provided
22+

0 commit comments

Comments
 (0)