デプロイに grunt を使用したいので、既存の~/.ssh/config
ファイルに基づいてリモート ホストの構成を読み込みたいと考えています。
その構成をロードするには、sshconfgrunt.initConfig()
を使用していますが、環境を定義するときに構成を取得するには、コールバックに呼び出しを含める必要があります。
var sshconf = require('sshconf');
module.exports = function(grunt) {
// Read in ssh configuration
sshconf.read(function(err, sshHosts) {
if (err)
console.log(err);
// SSH config loaded, now init grunt
grunt.initConfig({
sshconfig: {
staging: {
privateKey: grunt.file.read(sshHosts['project_staging'].properties.IdentityFile),
host: sshHosts['project_staging'].properties.HostName,
username: sshHosts['project_staging'].properties.User,
port: sshHosts['project_staging'].properties.Port || 22,
path: "/var/www/project"
},
production: {
// ...
}
},
// Tasks to be executed on remote server
sshexec: {
example_task: {
command: 'uptime && hostname'
}
},
sftp: {
deploy: {
files: {
"./": ["*.json", "*.js", "config/**", "controllers/**", "lib/**", "models/**", "public/**", "views/**"]
},
options: {
//srcBasePath: "test/",
createDirectories: true
}
}
}
// More tasks
// ...
});
grunt.loadNpmTasks('grunt-ssh');
// More plugins ...
});
};
私がそれを呼び出すgrunt --help
と、次のように述べています。
> grunt --help
Grunt: The JavaScript Task Runner (v0.4.1)
…
Available tasks
(no tasks found)
そのコールバック( )でうなり声の開始をラップしない場合、sshconf.read(function(err, sshHosts) {})
すべてが正常に機能します(ロードされていないか、まだ使用する準備ができていないssh構成を除く)。
私がしようとしていることは可能ですか?もしそうなら、どうやって? 明らかな何かが欠けていますか?