node.js - node-ansible fails to connect to the host when multiple connections coexist -


i have api server may trigger multiple node-ansibles simultaneously connect remote machine something.

here's node.js code:

// app.js const ansible = require('node-ansible')  let ansiblenum = 10  (let = 0; < ansiblenum; += 1) { let command = new ansible.playbook().playbook('test') command.inventory('hosts') command.exec()     .then(successresult => {     console.log(successresult)     })     .catch(err => {     console.log(err)     }) } 

and ansible playbook:

# test.yml --- - hosts:   remote_user: ubuntu   become: true   tasks:     - name: test ansible       shell: echo hello       register: result  # store result variable called "result"     - debug: var=result.stdout_lines 

as ansiblenum increases, probability of failure of ansible playbook increases.

the failure message is:

fatal: [10.50.123.123]: unreachable! => {"changed": false, "msg": "failed connect host via ssh: shared connection 10.50.123.123 closed.\r\n", "unreachable": true}

i've read similar question here, solutions provided doesn't work in case.

another way trigger problem executing

ansible-playbook -i hosts test.yml & ansible-playbook -i hosts test.yml.

this command runs ansible without node.js.

i've pushed code github. can download directly.

anyone knows why shared connection got closed?

i've set controlmaster argument auto following document here.

it's strange setting connection type paramiko solves problem.

here's config file located in ~/.ansible.cfg:

[defaults] transport = paramiko 

based on document, seems paramiko doesn't support persistent connection.

i'm still confused why setting solves problem.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -