-
Notifications
You must be signed in to change notification settings - Fork 402
Customizing User Data
Out of the box, Asgard will generate a generic launch configuration for ASGs that exports some variables containing information about the ASG. However, it is possible to customize the generated user data with a Groovy based plugin.
The following is an example of the user data generated by Asgard by default
export CLOUD_ENVIRONMENT=The value of cloud.accountName in your Config.groovy file, default is prod
export CLOUD_MONITOR_BUCKET=Either the application name or the cluster name, depending on the application setup
export CLOUD_APP=The application name
export CLOUD_STACK=Value of stack provided when creating the ASG
export CLOUD_CLUSTER=Name of the cluser, derived from the ASG name
export CLOUD_AUTO_SCALE_GROUP=Name of the autoscaling group
export CLOUD_LAUNCH_CONFIG=Name of the launch config
export EC2_REGION=Region code for this launch config
#The following variables are exported if they were specified when creating the ASG
export CLOUD_COUNTRIES=
export CLOUD_DEV_PHASE=
export CLOUD_HARDWARE=
export CLOUD_PARTNERS=
export CLOUD_REVISION=
You can consult the DefaultUserDataProvider
source for more implementation details.
Asgard has a plugin mechanism based on Spring's Groovy bean support which can overwrite the default implementation of user data provider.
In the ASGARD_HOME directory (~/.asgard
by default), create a plugins
directory. In this directory, any .groovy
files will be read in as Spring beans. You can use Spring features like @Autowired
annotations to pull in other internal Asgard services into your plugin class or implement InitializingBean
to trigger initialization logic.
Asgard contains an interface com.netflix.asgard.plugin.UserDataProvider
with a single method:
String buildUserDataForVariables(UserContext userContext, String appName, String autoScalingGroupName,
String launchConfigName)
You can create a Groovy class in the plugins
directory which implements this interface. Asgard can be told to use this plugin as the user data provider by adding an entry to the Config.groovy
file in ASGARD_HOME:
plugin {
userDataProvider = 'myUserDataProvider'
}
The value of userDataProvider
will have to match the name of the Spring bean (usually the class name as lower camel case).
A Netflix Original Production
Tech Blog | Twitter @NetflixOSS | Jobs