Issue passing argument to ansible ssh












1














Below ssh connectivity works fine:



ssh -i /opt/cert/id_rsa_prod targetuser@targethost -t bash


My ansible host file has the below entry



[target*]

targethost ansible_python_interpreter=/opt/bin/python2.7 ansible_ssh_extra_args="-t bash" ansible_ssh_common_args="-t" ansible_ssh_private_key_file=/opt/cert/id_rsa_prod USER_RUN=targetuser


When I run this ansible playbook it fails to connect to target host and throws the below error output:




23:53:42 ESTABLISH SSH CONNECTION FOR USER: targetuser



23:53:42 SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o
ControlPersist=60s -o 'IdentityFile="/opt/cert/id_rsa_prod"' -o
KbdInteractiveAuthentication=no -o
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey
-o PasswordAuthentication=no -o User=targetuser -o ConnectTimeout=10 -t bash -o ControlPath=/home/sourceuser/.ansible/cp/e8313d01d6 targethost '/bin/sh -c '"'"'echo ~targetuser && sleep 0'"'"''



23:53:42 (255, '', 'OpenSSH_7.7p1 (CentrifyDC build
5.5.1-395) , OpenSSL 1.0.2o-fips 27 Mar 2018rndebug1: Reading configuration data /home/sourceuser/.ssh/configrndebug1: Reading
configuration data /etc/centrifydc/ssh/ssh_configrndebug1:
/etc/centrifydc/ssh/ssh_config line 3: Applying options for
*rndebug1: auto-mux: Trying existing masterrndebug1: Control socket "/home/sourceuser/.ansible/cp/e8313d01d6" does not
existrndebug2: resolving "bash" port 22rnssh: Could not resolve
hostname bash: Name or service not knownrn')



23:53:42 fatal: [targethost]: UNREACHABLE! => {



23:53:42 "changed": false,



23:53:42 "msg": "Failed to connect to the host via ssh:
OpenSSH_7.7p1 (CentrifyDC build 5.5.1-395) , OpenSSL 1.0.2o-fips 27
Mar 2018rndebug1: Reading configuration data
/home/sourceuser/.ssh/configrndebug1: Reading configuration data
/etc/centrifydc/ssh/ssh_configrndebug1:
/etc/centrifydc/ssh/ssh_config line 3: Applying options for
*rndebug1: auto-mux: Trying existing masterrndebug1: Control socket "/home/sourceuser/.ansible/cp/e8313d01d6" does not
existrndebug2: resolving "bash" port 22rnssh: Could not resolve
hostname bash: Name or service not knownrn",



23:53:42 "unreachable": true



23:53:42 }



23:53:42 to retry, use: --limit
@/opt/scripts/myfolder/site.retry



23:53:42



23:53:42 PLAY RECAP





23:53:42 targethost : ok=0 changed=0 unreachable=1 failed=0




Can you please suggest how to fix the connectivity issue ?










share|improve this question






















  • "Could not resolve hostname bash: Name or service not known" how is that confusing to you? The command line clearly shows the -t bash right in the middle of the -o options to ssh
    – Matthew L Daniel
    Nov 22 '18 at 4:38






  • 1




    If you understand ansible; that is something constructed by ansible tool and not me. Hence, I was looking for a solution as to how we can get ansible construct the correct ssh connection
    – mohtashim
    Nov 22 '18 at 5:27
















1














Below ssh connectivity works fine:



ssh -i /opt/cert/id_rsa_prod targetuser@targethost -t bash


My ansible host file has the below entry



[target*]

targethost ansible_python_interpreter=/opt/bin/python2.7 ansible_ssh_extra_args="-t bash" ansible_ssh_common_args="-t" ansible_ssh_private_key_file=/opt/cert/id_rsa_prod USER_RUN=targetuser


When I run this ansible playbook it fails to connect to target host and throws the below error output:




23:53:42 ESTABLISH SSH CONNECTION FOR USER: targetuser



23:53:42 SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o
ControlPersist=60s -o 'IdentityFile="/opt/cert/id_rsa_prod"' -o
KbdInteractiveAuthentication=no -o
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey
-o PasswordAuthentication=no -o User=targetuser -o ConnectTimeout=10 -t bash -o ControlPath=/home/sourceuser/.ansible/cp/e8313d01d6 targethost '/bin/sh -c '"'"'echo ~targetuser && sleep 0'"'"''



23:53:42 (255, '', 'OpenSSH_7.7p1 (CentrifyDC build
5.5.1-395) , OpenSSL 1.0.2o-fips 27 Mar 2018rndebug1: Reading configuration data /home/sourceuser/.ssh/configrndebug1: Reading
configuration data /etc/centrifydc/ssh/ssh_configrndebug1:
/etc/centrifydc/ssh/ssh_config line 3: Applying options for
*rndebug1: auto-mux: Trying existing masterrndebug1: Control socket "/home/sourceuser/.ansible/cp/e8313d01d6" does not
existrndebug2: resolving "bash" port 22rnssh: Could not resolve
hostname bash: Name or service not knownrn')



23:53:42 fatal: [targethost]: UNREACHABLE! => {



23:53:42 "changed": false,



23:53:42 "msg": "Failed to connect to the host via ssh:
OpenSSH_7.7p1 (CentrifyDC build 5.5.1-395) , OpenSSL 1.0.2o-fips 27
Mar 2018rndebug1: Reading configuration data
/home/sourceuser/.ssh/configrndebug1: Reading configuration data
/etc/centrifydc/ssh/ssh_configrndebug1:
/etc/centrifydc/ssh/ssh_config line 3: Applying options for
*rndebug1: auto-mux: Trying existing masterrndebug1: Control socket "/home/sourceuser/.ansible/cp/e8313d01d6" does not
existrndebug2: resolving "bash" port 22rnssh: Could not resolve
hostname bash: Name or service not knownrn",



23:53:42 "unreachable": true



23:53:42 }



23:53:42 to retry, use: --limit
@/opt/scripts/myfolder/site.retry



23:53:42



23:53:42 PLAY RECAP





23:53:42 targethost : ok=0 changed=0 unreachable=1 failed=0




Can you please suggest how to fix the connectivity issue ?










share|improve this question






















  • "Could not resolve hostname bash: Name or service not known" how is that confusing to you? The command line clearly shows the -t bash right in the middle of the -o options to ssh
    – Matthew L Daniel
    Nov 22 '18 at 4:38






  • 1




    If you understand ansible; that is something constructed by ansible tool and not me. Hence, I was looking for a solution as to how we can get ansible construct the correct ssh connection
    – mohtashim
    Nov 22 '18 at 5:27














1












1








1







Below ssh connectivity works fine:



ssh -i /opt/cert/id_rsa_prod targetuser@targethost -t bash


My ansible host file has the below entry



[target*]

targethost ansible_python_interpreter=/opt/bin/python2.7 ansible_ssh_extra_args="-t bash" ansible_ssh_common_args="-t" ansible_ssh_private_key_file=/opt/cert/id_rsa_prod USER_RUN=targetuser


When I run this ansible playbook it fails to connect to target host and throws the below error output:




23:53:42 ESTABLISH SSH CONNECTION FOR USER: targetuser



23:53:42 SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o
ControlPersist=60s -o 'IdentityFile="/opt/cert/id_rsa_prod"' -o
KbdInteractiveAuthentication=no -o
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey
-o PasswordAuthentication=no -o User=targetuser -o ConnectTimeout=10 -t bash -o ControlPath=/home/sourceuser/.ansible/cp/e8313d01d6 targethost '/bin/sh -c '"'"'echo ~targetuser && sleep 0'"'"''



23:53:42 (255, '', 'OpenSSH_7.7p1 (CentrifyDC build
5.5.1-395) , OpenSSL 1.0.2o-fips 27 Mar 2018rndebug1: Reading configuration data /home/sourceuser/.ssh/configrndebug1: Reading
configuration data /etc/centrifydc/ssh/ssh_configrndebug1:
/etc/centrifydc/ssh/ssh_config line 3: Applying options for
*rndebug1: auto-mux: Trying existing masterrndebug1: Control socket "/home/sourceuser/.ansible/cp/e8313d01d6" does not
existrndebug2: resolving "bash" port 22rnssh: Could not resolve
hostname bash: Name or service not knownrn')



23:53:42 fatal: [targethost]: UNREACHABLE! => {



23:53:42 "changed": false,



23:53:42 "msg": "Failed to connect to the host via ssh:
OpenSSH_7.7p1 (CentrifyDC build 5.5.1-395) , OpenSSL 1.0.2o-fips 27
Mar 2018rndebug1: Reading configuration data
/home/sourceuser/.ssh/configrndebug1: Reading configuration data
/etc/centrifydc/ssh/ssh_configrndebug1:
/etc/centrifydc/ssh/ssh_config line 3: Applying options for
*rndebug1: auto-mux: Trying existing masterrndebug1: Control socket "/home/sourceuser/.ansible/cp/e8313d01d6" does not
existrndebug2: resolving "bash" port 22rnssh: Could not resolve
hostname bash: Name or service not knownrn",



23:53:42 "unreachable": true



23:53:42 }



23:53:42 to retry, use: --limit
@/opt/scripts/myfolder/site.retry



23:53:42



23:53:42 PLAY RECAP





23:53:42 targethost : ok=0 changed=0 unreachable=1 failed=0




Can you please suggest how to fix the connectivity issue ?










share|improve this question













Below ssh connectivity works fine:



ssh -i /opt/cert/id_rsa_prod targetuser@targethost -t bash


My ansible host file has the below entry



[target*]

targethost ansible_python_interpreter=/opt/bin/python2.7 ansible_ssh_extra_args="-t bash" ansible_ssh_common_args="-t" ansible_ssh_private_key_file=/opt/cert/id_rsa_prod USER_RUN=targetuser


When I run this ansible playbook it fails to connect to target host and throws the below error output:




23:53:42 ESTABLISH SSH CONNECTION FOR USER: targetuser



23:53:42 SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o
ControlPersist=60s -o 'IdentityFile="/opt/cert/id_rsa_prod"' -o
KbdInteractiveAuthentication=no -o
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey
-o PasswordAuthentication=no -o User=targetuser -o ConnectTimeout=10 -t bash -o ControlPath=/home/sourceuser/.ansible/cp/e8313d01d6 targethost '/bin/sh -c '"'"'echo ~targetuser && sleep 0'"'"''



23:53:42 (255, '', 'OpenSSH_7.7p1 (CentrifyDC build
5.5.1-395) , OpenSSL 1.0.2o-fips 27 Mar 2018rndebug1: Reading configuration data /home/sourceuser/.ssh/configrndebug1: Reading
configuration data /etc/centrifydc/ssh/ssh_configrndebug1:
/etc/centrifydc/ssh/ssh_config line 3: Applying options for
*rndebug1: auto-mux: Trying existing masterrndebug1: Control socket "/home/sourceuser/.ansible/cp/e8313d01d6" does not
existrndebug2: resolving "bash" port 22rnssh: Could not resolve
hostname bash: Name or service not knownrn')



23:53:42 fatal: [targethost]: UNREACHABLE! => {



23:53:42 "changed": false,



23:53:42 "msg": "Failed to connect to the host via ssh:
OpenSSH_7.7p1 (CentrifyDC build 5.5.1-395) , OpenSSL 1.0.2o-fips 27
Mar 2018rndebug1: Reading configuration data
/home/sourceuser/.ssh/configrndebug1: Reading configuration data
/etc/centrifydc/ssh/ssh_configrndebug1:
/etc/centrifydc/ssh/ssh_config line 3: Applying options for
*rndebug1: auto-mux: Trying existing masterrndebug1: Control socket "/home/sourceuser/.ansible/cp/e8313d01d6" does not
existrndebug2: resolving "bash" port 22rnssh: Could not resolve
hostname bash: Name or service not knownrn",



23:53:42 "unreachable": true



23:53:42 }



23:53:42 to retry, use: --limit
@/opt/scripts/myfolder/site.retry



23:53:42



23:53:42 PLAY RECAP





23:53:42 targethost : ok=0 changed=0 unreachable=1 failed=0




Can you please suggest how to fix the connectivity issue ?







ssh ansible ansible-inventory






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 '18 at 22:16









mohtashimmohtashim

105




105












  • "Could not resolve hostname bash: Name or service not known" how is that confusing to you? The command line clearly shows the -t bash right in the middle of the -o options to ssh
    – Matthew L Daniel
    Nov 22 '18 at 4:38






  • 1




    If you understand ansible; that is something constructed by ansible tool and not me. Hence, I was looking for a solution as to how we can get ansible construct the correct ssh connection
    – mohtashim
    Nov 22 '18 at 5:27


















  • "Could not resolve hostname bash: Name or service not known" how is that confusing to you? The command line clearly shows the -t bash right in the middle of the -o options to ssh
    – Matthew L Daniel
    Nov 22 '18 at 4:38






  • 1




    If you understand ansible; that is something constructed by ansible tool and not me. Hence, I was looking for a solution as to how we can get ansible construct the correct ssh connection
    – mohtashim
    Nov 22 '18 at 5:27
















"Could not resolve hostname bash: Name or service not known" how is that confusing to you? The command line clearly shows the -t bash right in the middle of the -o options to ssh
– Matthew L Daniel
Nov 22 '18 at 4:38




"Could not resolve hostname bash: Name or service not known" how is that confusing to you? The command line clearly shows the -t bash right in the middle of the -o options to ssh
– Matthew L Daniel
Nov 22 '18 at 4:38




1




1




If you understand ansible; that is something constructed by ansible tool and not me. Hence, I was looking for a solution as to how we can get ansible construct the correct ssh connection
– mohtashim
Nov 22 '18 at 5:27




If you understand ansible; that is something constructed by ansible tool and not me. Hence, I was looking for a solution as to how we can get ansible construct the correct ssh connection
– mohtashim
Nov 22 '18 at 5:27












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421211%2fissue-passing-argument-to-ansible-ssh%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421211%2fissue-passing-argument-to-ansible-ssh%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

TypeError: fit_transform() missing 1 required positional argument: 'X'