Issue passing argument to ansible ssh
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
add a comment |
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
"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
add a comment |
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
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
ssh ansible ansible-inventory
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
add a comment |
"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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
"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