implement postcreate hook, stub out specification of SSL keys via command line params, template bump to support single top level .hook key

This commit is contained in:
Lloyd Hilaiel 2012-05-31 22:08:34 +03:00
Родитель d803fafb3f
Коммит cc635b5c41
3 изменённых файлов: 17 добавлений и 3 удалений

Просмотреть файл

@ -75,6 +75,8 @@ verbs['create'] = function(args) {
if (argv.u) argv.u = urlparse(argv.u).validate().originOnly().toString();
})
.describe('t', 'Instance type, dictates VM speed and cost. i.e. t1.micro or m1.large (see http://aws.amazon.com/ec2/instance-types/)')
.describe('p', 'public SSL key (installed automatically when provided)')
.describe('s', 'secret SSL key (installed automatically when provided)')
.default('t', 't1.micro')
var opts = parser.argv;
@ -135,7 +137,11 @@ verbs['create'] = function(args) {
}
ssh.installPackages(deets.ipAddress, awsboxJson.packages, function(err, r) {
checkErr(err);
printInstructions(name, deets);
var postcreate = (awsboxJson.hooks && awsboxJson.hooks.postcreate) || null;
ssh.runScript(deets.ipAddress, postcreate, function(err, r) {
checkErr(err);
printInstructions(name, deets);
});
});
});
});

Просмотреть файл

@ -54,6 +54,14 @@ exports.installPackages = function(host, packages, cb) {
}
};
exports.runScript = function(host, script, cb) {
if (!script) return cb(null);
var cmd = 'ssh -o "StrictHostKeyChecking no" ec2-user@' + host + " < " + script;
child_process.exec(cmd, function(err, r) {
cb(err);
});
};
exports.addSSHPubKey = function(host, pubkey, cb) {
var cmd = 'ssh -o "StrictHostKeyChecking no" ec2-user@' + host + " 'echo \'" + pubkey + "\' >> .ssh/authorized_keys'";
child_process.exec(cmd, cb);

Просмотреть файл

@ -4,7 +4,7 @@ jsel = require('JSONSelect'),
key = require('./key.js'),
sec = require('./sec.js');
const TEMPLATE_IMAGE_ID = 'ami-b68021df';
const TEMPLATE_IMAGE_ID = 'ami-10852479';
function extractInstanceDeets(horribleBlob) {
var instance = {};
@ -143,7 +143,7 @@ exports.makeAMIPublic = function(imageId, progress, cb) {
setTimeout(function() {
if (typeof progress === 'function') progress(e || "unknown");
attempt();
}, 10000);
}, 15000);
});
}