ansible expect not working for multiple prompt values
I need to install nginx agent for openam using ansible.
while install the nginx_agent it asking multiple question while run the script,
************************************************************************
Welcome to the OpenSSO Policy Agent for NGINX
************************************************************************
Enter the URL where the OpenAM server is running.
Please include the deployment URI also as shown below:
(http://opensso.sample.com:58080/opensso)
**OpenSSO server URL: sss**
Enter the Agent profile name
**Agent Profile Name: sss**
Enter the password to be used for identifying the Agent.
*THIS IS NOT PASSWORD FILE*
**Agent Password:**
-----------------------------------------------
SUMMARY OF YOUR RESPONSES
-----------------------------------------------
OpenSSO server URL : sss
Agent Profile name : sss
Agent Password: sss
**Continue with Installation?
[y/N]: y**
so, i have use expect module in ansible:
- expect:
command: sh /opt/nginx_agent/bin/agentadmin.sh
responses:
OpenSSO server URL: "http://openam.test.mobi:8080/openam"
Agent Profile Name: "nginx"
Agent Password: "test.mobi2"
(^Con[^n]*n+[^n]*)+: "y"
But, its Continue with Installation?
[y/N]:
takes, OpenSSO server URL: value see,
Reference:
"stdout_lines": [
"************************************************************************",
"Welcome to the OpenSSO Policy Agent for NGINX",
"************************************************************************",
"",
"Enter the URL where the OpenAM server is running.",
"Please include the deployment URI also as shown below:",
"(http://opensso.sample.com:58080/opensso)",
"OpenSSO server URL: Enter the Agent profile name",
"Agent Profile Name: Enter the password to be used for identifying the Agent.",
"*THIS IS NOT PASSWORD FILE*",
"Agent Password: ",
"-----------------------------------------------",
"SUMMARY OF YOUR RESPONSES",
"-----------------------------------------------",
"OpenSSO server URL : http://openam.test.mobi:8080/openam",
"Agent Profile name : nginx",
"Agent Password: test.mobi2",
"Continue with Installation?",
"[y/N]: http://openam.test.mobi:8080/openam",
"test.mobi2"
]
Suggest Me , what i miss in this Configuration. How to fix this
linux command-line ansible runlevel
add a comment |
I need to install nginx agent for openam using ansible.
while install the nginx_agent it asking multiple question while run the script,
************************************************************************
Welcome to the OpenSSO Policy Agent for NGINX
************************************************************************
Enter the URL where the OpenAM server is running.
Please include the deployment URI also as shown below:
(http://opensso.sample.com:58080/opensso)
**OpenSSO server URL: sss**
Enter the Agent profile name
**Agent Profile Name: sss**
Enter the password to be used for identifying the Agent.
*THIS IS NOT PASSWORD FILE*
**Agent Password:**
-----------------------------------------------
SUMMARY OF YOUR RESPONSES
-----------------------------------------------
OpenSSO server URL : sss
Agent Profile name : sss
Agent Password: sss
**Continue with Installation?
[y/N]: y**
so, i have use expect module in ansible:
- expect:
command: sh /opt/nginx_agent/bin/agentadmin.sh
responses:
OpenSSO server URL: "http://openam.test.mobi:8080/openam"
Agent Profile Name: "nginx"
Agent Password: "test.mobi2"
(^Con[^n]*n+[^n]*)+: "y"
But, its Continue with Installation?
[y/N]:
takes, OpenSSO server URL: value see,
Reference:
"stdout_lines": [
"************************************************************************",
"Welcome to the OpenSSO Policy Agent for NGINX",
"************************************************************************",
"",
"Enter the URL where the OpenAM server is running.",
"Please include the deployment URI also as shown below:",
"(http://opensso.sample.com:58080/opensso)",
"OpenSSO server URL: Enter the Agent profile name",
"Agent Profile Name: Enter the password to be used for identifying the Agent.",
"*THIS IS NOT PASSWORD FILE*",
"Agent Password: ",
"-----------------------------------------------",
"SUMMARY OF YOUR RESPONSES",
"-----------------------------------------------",
"OpenSSO server URL : http://openam.test.mobi:8080/openam",
"Agent Profile name : nginx",
"Agent Password: test.mobi2",
"Continue with Installation?",
"[y/N]: http://openam.test.mobi:8080/openam",
"test.mobi2"
]
Suggest Me , what i miss in this Configuration. How to fix this
linux command-line ansible runlevel
add a comment |
I need to install nginx agent for openam using ansible.
while install the nginx_agent it asking multiple question while run the script,
************************************************************************
Welcome to the OpenSSO Policy Agent for NGINX
************************************************************************
Enter the URL where the OpenAM server is running.
Please include the deployment URI also as shown below:
(http://opensso.sample.com:58080/opensso)
**OpenSSO server URL: sss**
Enter the Agent profile name
**Agent Profile Name: sss**
Enter the password to be used for identifying the Agent.
*THIS IS NOT PASSWORD FILE*
**Agent Password:**
-----------------------------------------------
SUMMARY OF YOUR RESPONSES
-----------------------------------------------
OpenSSO server URL : sss
Agent Profile name : sss
Agent Password: sss
**Continue with Installation?
[y/N]: y**
so, i have use expect module in ansible:
- expect:
command: sh /opt/nginx_agent/bin/agentadmin.sh
responses:
OpenSSO server URL: "http://openam.test.mobi:8080/openam"
Agent Profile Name: "nginx"
Agent Password: "test.mobi2"
(^Con[^n]*n+[^n]*)+: "y"
But, its Continue with Installation?
[y/N]:
takes, OpenSSO server URL: value see,
Reference:
"stdout_lines": [
"************************************************************************",
"Welcome to the OpenSSO Policy Agent for NGINX",
"************************************************************************",
"",
"Enter the URL where the OpenAM server is running.",
"Please include the deployment URI also as shown below:",
"(http://opensso.sample.com:58080/opensso)",
"OpenSSO server URL: Enter the Agent profile name",
"Agent Profile Name: Enter the password to be used for identifying the Agent.",
"*THIS IS NOT PASSWORD FILE*",
"Agent Password: ",
"-----------------------------------------------",
"SUMMARY OF YOUR RESPONSES",
"-----------------------------------------------",
"OpenSSO server URL : http://openam.test.mobi:8080/openam",
"Agent Profile name : nginx",
"Agent Password: test.mobi2",
"Continue with Installation?",
"[y/N]: http://openam.test.mobi:8080/openam",
"test.mobi2"
]
Suggest Me , what i miss in this Configuration. How to fix this
linux command-line ansible runlevel
I need to install nginx agent for openam using ansible.
while install the nginx_agent it asking multiple question while run the script,
************************************************************************
Welcome to the OpenSSO Policy Agent for NGINX
************************************************************************
Enter the URL where the OpenAM server is running.
Please include the deployment URI also as shown below:
(http://opensso.sample.com:58080/opensso)
**OpenSSO server URL: sss**
Enter the Agent profile name
**Agent Profile Name: sss**
Enter the password to be used for identifying the Agent.
*THIS IS NOT PASSWORD FILE*
**Agent Password:**
-----------------------------------------------
SUMMARY OF YOUR RESPONSES
-----------------------------------------------
OpenSSO server URL : sss
Agent Profile name : sss
Agent Password: sss
**Continue with Installation?
[y/N]: y**
so, i have use expect module in ansible:
- expect:
command: sh /opt/nginx_agent/bin/agentadmin.sh
responses:
OpenSSO server URL: "http://openam.test.mobi:8080/openam"
Agent Profile Name: "nginx"
Agent Password: "test.mobi2"
(^Con[^n]*n+[^n]*)+: "y"
But, its Continue with Installation?
[y/N]:
takes, OpenSSO server URL: value see,
Reference:
"stdout_lines": [
"************************************************************************",
"Welcome to the OpenSSO Policy Agent for NGINX",
"************************************************************************",
"",
"Enter the URL where the OpenAM server is running.",
"Please include the deployment URI also as shown below:",
"(http://opensso.sample.com:58080/opensso)",
"OpenSSO server URL: Enter the Agent profile name",
"Agent Profile Name: Enter the password to be used for identifying the Agent.",
"*THIS IS NOT PASSWORD FILE*",
"Agent Password: ",
"-----------------------------------------------",
"SUMMARY OF YOUR RESPONSES",
"-----------------------------------------------",
"OpenSSO server URL : http://openam.test.mobi:8080/openam",
"Agent Profile name : nginx",
"Agent Password: test.mobi2",
"Continue with Installation?",
"[y/N]: http://openam.test.mobi:8080/openam",
"test.mobi2"
]
Suggest Me , what i miss in this Configuration. How to fix this
linux command-line ansible runlevel
linux command-line ansible runlevel
edited Dec 26 '16 at 12:34
asked Dec 26 '16 at 7:26
Rajkumar .E
10415
10415
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I would try ignoring the Continue with Installation?
and just match on the [y/N]
line.
replace (^Con[^n]*n+[^n]*)+: "y"
with 'y/N' : 'y'
Ansible uses the pexpect module which doesn't always do what you would expect. For example, EOL is 'rn'
, not 'n'
.
See the docs here.
Here is a quick test:
/root/junk.sh
echo 'Enter the Agent profile name'
read -p "Agent Profile Name: " AGENT_PROFILE_NAME
echo $AGENT_PROFILE_NAME > junk.dat
echo "Continue with installation"
read -p "[y/N] : " CONFIRM
echo $CONFIRM >> junk.dat
play:
- expect:
command: sh /root/junk.sh
responses:
'Profile Name' : "oook"
'y/N' : 'y'
Here is an easier way to do it without using expect.
If you look at the agentadmin.sh script you will see that responses to all of the questions are stored in environment variables, i.e.
while [ -z ${OPENAM_URL} ]; do
If you pre-define all of them in the environment section of your playbook the script should run without any user intervention. No need for expect.
So something like:
environment:
OPENAM_URL: whatever_1
AGENT_PROFILE_NAME: whatever_2
AGENT_PASSWORD: whatever_3
CONFIRM: y
- shell: /opt/nginx_agent/bin/agentadmin.sh
i tried your way but, still i have same issue
– Rajkumar .E
Dec 28 '16 at 12:32
Try running it with ansible-playbook -vvv playbook.yml.
– glebaron
Dec 30 '16 at 0:08
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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%2fsuperuser.com%2fquestions%2f1160250%2fansible-expect-not-working-for-multiple-prompt-values%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I would try ignoring the Continue with Installation?
and just match on the [y/N]
line.
replace (^Con[^n]*n+[^n]*)+: "y"
with 'y/N' : 'y'
Ansible uses the pexpect module which doesn't always do what you would expect. For example, EOL is 'rn'
, not 'n'
.
See the docs here.
Here is a quick test:
/root/junk.sh
echo 'Enter the Agent profile name'
read -p "Agent Profile Name: " AGENT_PROFILE_NAME
echo $AGENT_PROFILE_NAME > junk.dat
echo "Continue with installation"
read -p "[y/N] : " CONFIRM
echo $CONFIRM >> junk.dat
play:
- expect:
command: sh /root/junk.sh
responses:
'Profile Name' : "oook"
'y/N' : 'y'
Here is an easier way to do it without using expect.
If you look at the agentadmin.sh script you will see that responses to all of the questions are stored in environment variables, i.e.
while [ -z ${OPENAM_URL} ]; do
If you pre-define all of them in the environment section of your playbook the script should run without any user intervention. No need for expect.
So something like:
environment:
OPENAM_URL: whatever_1
AGENT_PROFILE_NAME: whatever_2
AGENT_PASSWORD: whatever_3
CONFIRM: y
- shell: /opt/nginx_agent/bin/agentadmin.sh
i tried your way but, still i have same issue
– Rajkumar .E
Dec 28 '16 at 12:32
Try running it with ansible-playbook -vvv playbook.yml.
– glebaron
Dec 30 '16 at 0:08
add a comment |
I would try ignoring the Continue with Installation?
and just match on the [y/N]
line.
replace (^Con[^n]*n+[^n]*)+: "y"
with 'y/N' : 'y'
Ansible uses the pexpect module which doesn't always do what you would expect. For example, EOL is 'rn'
, not 'n'
.
See the docs here.
Here is a quick test:
/root/junk.sh
echo 'Enter the Agent profile name'
read -p "Agent Profile Name: " AGENT_PROFILE_NAME
echo $AGENT_PROFILE_NAME > junk.dat
echo "Continue with installation"
read -p "[y/N] : " CONFIRM
echo $CONFIRM >> junk.dat
play:
- expect:
command: sh /root/junk.sh
responses:
'Profile Name' : "oook"
'y/N' : 'y'
Here is an easier way to do it without using expect.
If you look at the agentadmin.sh script you will see that responses to all of the questions are stored in environment variables, i.e.
while [ -z ${OPENAM_URL} ]; do
If you pre-define all of them in the environment section of your playbook the script should run without any user intervention. No need for expect.
So something like:
environment:
OPENAM_URL: whatever_1
AGENT_PROFILE_NAME: whatever_2
AGENT_PASSWORD: whatever_3
CONFIRM: y
- shell: /opt/nginx_agent/bin/agentadmin.sh
i tried your way but, still i have same issue
– Rajkumar .E
Dec 28 '16 at 12:32
Try running it with ansible-playbook -vvv playbook.yml.
– glebaron
Dec 30 '16 at 0:08
add a comment |
I would try ignoring the Continue with Installation?
and just match on the [y/N]
line.
replace (^Con[^n]*n+[^n]*)+: "y"
with 'y/N' : 'y'
Ansible uses the pexpect module which doesn't always do what you would expect. For example, EOL is 'rn'
, not 'n'
.
See the docs here.
Here is a quick test:
/root/junk.sh
echo 'Enter the Agent profile name'
read -p "Agent Profile Name: " AGENT_PROFILE_NAME
echo $AGENT_PROFILE_NAME > junk.dat
echo "Continue with installation"
read -p "[y/N] : " CONFIRM
echo $CONFIRM >> junk.dat
play:
- expect:
command: sh /root/junk.sh
responses:
'Profile Name' : "oook"
'y/N' : 'y'
Here is an easier way to do it without using expect.
If you look at the agentadmin.sh script you will see that responses to all of the questions are stored in environment variables, i.e.
while [ -z ${OPENAM_URL} ]; do
If you pre-define all of them in the environment section of your playbook the script should run without any user intervention. No need for expect.
So something like:
environment:
OPENAM_URL: whatever_1
AGENT_PROFILE_NAME: whatever_2
AGENT_PASSWORD: whatever_3
CONFIRM: y
- shell: /opt/nginx_agent/bin/agentadmin.sh
I would try ignoring the Continue with Installation?
and just match on the [y/N]
line.
replace (^Con[^n]*n+[^n]*)+: "y"
with 'y/N' : 'y'
Ansible uses the pexpect module which doesn't always do what you would expect. For example, EOL is 'rn'
, not 'n'
.
See the docs here.
Here is a quick test:
/root/junk.sh
echo 'Enter the Agent profile name'
read -p "Agent Profile Name: " AGENT_PROFILE_NAME
echo $AGENT_PROFILE_NAME > junk.dat
echo "Continue with installation"
read -p "[y/N] : " CONFIRM
echo $CONFIRM >> junk.dat
play:
- expect:
command: sh /root/junk.sh
responses:
'Profile Name' : "oook"
'y/N' : 'y'
Here is an easier way to do it without using expect.
If you look at the agentadmin.sh script you will see that responses to all of the questions are stored in environment variables, i.e.
while [ -z ${OPENAM_URL} ]; do
If you pre-define all of them in the environment section of your playbook the script should run without any user intervention. No need for expect.
So something like:
environment:
OPENAM_URL: whatever_1
AGENT_PROFILE_NAME: whatever_2
AGENT_PASSWORD: whatever_3
CONFIRM: y
- shell: /opt/nginx_agent/bin/agentadmin.sh
edited Dec 30 '16 at 0:45
answered Dec 26 '16 at 22:58
glebaron
114
114
i tried your way but, still i have same issue
– Rajkumar .E
Dec 28 '16 at 12:32
Try running it with ansible-playbook -vvv playbook.yml.
– glebaron
Dec 30 '16 at 0:08
add a comment |
i tried your way but, still i have same issue
– Rajkumar .E
Dec 28 '16 at 12:32
Try running it with ansible-playbook -vvv playbook.yml.
– glebaron
Dec 30 '16 at 0:08
i tried your way but, still i have same issue
– Rajkumar .E
Dec 28 '16 at 12:32
i tried your way but, still i have same issue
– Rajkumar .E
Dec 28 '16 at 12:32
Try running it with ansible-playbook -vvv playbook.yml.
– glebaron
Dec 30 '16 at 0:08
Try running it with ansible-playbook -vvv playbook.yml.
– glebaron
Dec 30 '16 at 0:08
add a comment |
Thanks for contributing an answer to Super User!
- 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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2fsuperuser.com%2fquestions%2f1160250%2fansible-expect-not-working-for-multiple-prompt-values%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