Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 52 lines (36 sloc) 1.984 kb
6febefb Brandon R. Stoner Added a README file that explains why this script is (or possibly isn't)...
authored
1 EC2 Rolegen
2 ===========
3
4 How to use it
5 -------------
6
7 On EC2 images that use cloud-init, this can generate "user data scripts" for bootstrapping
8 systems to use different roles. This allows users to configure the systems without needing
9 to put themselves through the tedious process of creating custom AMIs (especially in
10 consideration of micro instances) and allows you to keep your user data scripts in a versioned
11 repository - if desired - with a simple tool that automates the process of generating the
12 scripts.
13
14 This script will leverage CloudInit's ability to use multi-part MIME files in order to allow
15 any number of scripts to coexist, and gzips the user data scripts.
16
17 A simple idea of using this might be that you want a server, but you don't want to make a custom
18 AMI and you don't want to manually configure it. You could create a directory hierarchy next to
19 *genroles.py* like this:
20
21 roles/
22 |- example/
23 |- install.sh
24
25 Now, you could have the following inside of your install.sh file:
26
27 #!/bin/sh
28 echo 'Hello, world.' > /root/hello.txt
29
30 Now, execute this command - and you will have a final packge called example.gz in the ./dist
31 directory:
32
33 python genroles.py
34
35 How it works
36 ------------
37
38 This is pretty simple. All that this script does is look for a directory called 'roles' in
39 your current working directory. If this directory is not found, then it will be created. It
40 will then search this directory for any files or directories.
41
42 If the script finds a directory, then it creates a new role which is given the same name as
c3bf0dd Brandon R. Stoner Some English nitpicking.
authored
43 that directory. If it finds a file, then that file is added to a list of files
44 that should be used for every role. These are *global files*.
6febefb Brandon R. Stoner Added a README file that explains why this script is (or possibly isn't)...
authored
45
c3bf0dd Brandon R. Stoner Some English nitpicking.
authored
46 For each directory, the script collects all global files and all files in that roles directory
6febefb Brandon R. Stoner Added a README file that explains why this script is (or possibly isn't)...
authored
47 and puts them into a gzipped (compression level 9) mime file in the dist directory. These files
48 can be used as user data for your instance in order to bootstrap it.
49
50 **Tada.**
51
Something went wrong with that request. Please try again.