小编Ret*_*eto的帖子

带有需要 tty 的 shell 脚本的 ansible 管道模式

我正在使用 ansible 在 Debian wheezy 虚拟机上安装 node.js 和 npm,遵循本文档反向移植部分中的步骤。

以下剧本任务过去可以很好地与传统的 ansible ssh 模式配合使用。

- name: install npm
shell: curl https://www.npmjs.org/install.sh | sh creates=/usr/bin/npm
Run Code Online (Sandbox Code Playgroud)

直到我尝试启用 ansible 1.5 的管道化。现在失败了:

npm-install-18570.sh: 246: npm-install-18570.sh: cannot open /dev/tty: No such device or address
Run Code Online (Sandbox Code Playgroud)

下载的 shellscript install.sh 在第 246 行引用了 /dev/tty,因此在管道模式下使用 ansible 执行时会失败。

我可以仅针对这一项任务禁用管道吗?
还有其他选择吗?”

debian pipelining ansible

4
推荐指数
1
解决办法
5717
查看次数

如何保存从mongoose中的query.exec()函数返回的对象

我是猫鼬的新手.这是我的场景:

var childSchema = new Schema({ name: 'string' });
var parentSchema = new Schema({
children: [childSchema]});
var Parent = mongoose.model('Parent', parentSchema);
Run Code Online (Sandbox Code Playgroud)

假设我已经创建了一个带有子项的父级'p',我正在查询'p',使用

var query = Parent.find({"_id":"562676a04787a98217d1c81e"});
query.select('children');                                   
query.exec(function(err,person){                            
    if(err){                                                    
        return console.error(err);                               
    } else {                                                     
        console.log(person);                                     
    }
});                                                    
Run Code Online (Sandbox Code Playgroud)

我需要访问异步函数之外的person对象.有关如何做到这一点的任何想法?

mongoose mongodb node.js

4
推荐指数
1
解决办法
736
查看次数

标签 统计

ansible ×1

debian ×1

mongodb ×1

mongoose ×1

node.js ×1

pipelining ×1