Expect module not working

98 views
Skip to first unread message

Krishan Chawla

unread,
Oct 4, 2018, 8:05:41 AM10/4/18
to Ansible Project
---
- hosts: web
become: yes
tasks:
- name: Run bash file
expect:
echo: yes
command: ./linux/setup/psft-dpk-setup.sh
responses:
'Do you want to proceed with the Puppet Installation\? \[Y\|n\]': "Y"
'Enter the full path of the PeopleSoft DPK directory': "/home/opc/linux"
'Enter the PeopleSoft Base Directory': "/peoplesoft"
'Are you happy with your answer\? \[Y\|n\|q\]': "Y"
'Enter the Peoplesoft installation \[PUM or FRESH\] type \[PUM\]': "PUM"
'Enter a new PeopleSoft database name. Ensure that the database name start with a letter and contains only uppercase letters and numbers and is no more than 8 characters in length': "FSCMU029"
'Enter the PeopleSoft database listener port [1521]': "1521"
'Enter a new PeopleSoft database admin users [SYS/SYSTEM] password. Ensure that the password is between 8 and 30 characters in length with at least one lowercase letter, one uppercase letter, one number and one special character \(\_\,\-\,\#\)': "System123#"
'Re-Enter the database admin users password': "System123#"
'Enter a new PeopleSoft database Connect ID. Ensure that the ID contains only alphanumeric characters and is at most 8 characters in length [people]': "people"
'Enter a new PeopleSoft database Connect ID [people] password. Ensure the password contains only alphanumeric characters and is between 6 and 30 characters in length': "people"
'Re-Enter the PeopleSoft Connect ID password': "people"
'Enter a new PeopleSoft database Access ID [SYSADM] password. Ensure the password contains only alphanumeric characters and is between 6 and 30 characters in length': "SYSADM"
'Re-Enter the PeopleSoft Access ID password': "SYSADM"
'Enter a new PeopleSoft database Operator ID [VP1] password. Ensure the password contains only alphanumeric characters and is between 1 and 32 characters in length': "VP1"
'Re-Enter the PeopleSoft Operator ID password': "VP1"
'[Optional] Enter a new Application Server Domain connection password. Ensure the password contains only alphanumeric characters and is between 8 and 30 characters in length': "System123"
'Re-Enter the Application Server Domain connection password': "System123"
'Enter a new WebLogic Server Admin user [system] password. Ensure that the password is between 8 and 30 characters in length with at least one lowercase letter, one uppercase letter, one number or one one special character \(\!\@\#\$\%\^\&\)': 'System@123'
'Re-Enter the WebLogic Server Admin user password': "System@123"
'Enter a new PeopleSoft WebProfile user [PTWEBSERVER] password. Ensure the password contains only alphanumeric characters and is between 8 and 32 characters in length': "PTWEBSERVER"
'Re-Enter the PeopleSoft WebProfile user password': "PTWEBSERVER"
'Enter the PeopleSoft Integration Gateway user [administrator]': "administrator"
'Enter the PeopleSoft Integration Gateway user [administrator] password. Ensure the password contains only alphanumeric characters and is between 8 and 30 characters in length': "Passw0rd"
'Re-Enter the Integration Gateway user password': "Passw0rd"
'Are you happy with your answer? [y\|n]': "y"
'Do you want to continue with the default initialization process? [y\|n]': "y"
timeout: 500

## this script is not working with some resposes

Brad Van Orden

unread,
Oct 4, 2018, 10:50:06 AM10/4/18
to Ansible Project
Can you show the output?  What specific error messages are you getting?


Krishan Chawla

unread,
Oct 4, 2018, 11:20:59 AM10/4/18
to Ansible Project
the output does not show any error message, but it is just taking the first three responses and not the PUM response.

Brad Van Orden

unread,
Oct 4, 2018, 11:41:17 AM10/4/18
to Ansible Project
I would suspect it is not recognizing the third prompt.  Try to simplify it.  You don't need the entire phrase, just the unique part of it.  Also, might try adding

echo: yes

to see if that gives you any more details.


On Thursday, October 4, 2018 at 11:20:59 AM UTC-4, Krishan Chawla wrote:

Krishan Chawla

unread,
Oct 5, 2018, 1:59:43 AM10/5/18
to Ansible Project
i tried with simplified script


---
- hosts: web
become: yes
tasks:
- name: Run bash file
expect:
echo: yes
command: ./linux/setup/psft-dpk-setup.sh
responses:
'Do you want to proceed with the Puppet Installation': "Y"
'Enter the full path of the PeopleSoft DPK directory': "/home/opc/linux"
'Enter the PeopleSoft Base Directory': "/peoplesoft"
'Are you happy with your answer\? \[Y\|n\|q\]': "Y"
'Enter the Peoplesoft installation': "PUM"
'Enter a new PeopleSoft database name': "FSCMU029"
'Enter the PeopleSoft database listener port': "1521"
'Enter a new PeopleSoft database admin users': "System123#"
'Re-Enter the database admin users password': "System123#"
'Enter a new PeopleSoft database Connect ID.': "people"
'Enter a new PeopleSoft database Connect ID [people] password': "people"
'Re-Enter the PeopleSoft Connect ID password': "people"
'Enter a new PeopleSoft database Access ID [SYSADM] password': "SYSADM"
'Re-Enter the PeopleSoft Access ID password': "SYSADM"
'Enter a new PeopleSoft database Operator ID [VP1] password': "VP1"
'Re-Enter the PeopleSoft Operator ID password': "VP1"
'[Optional] Enter a new Application Server Domain connection password': "System123"
'Re-Enter the Application Server Domain connection password': "System123"
'Enter a new WebLogic Server Admin user [system] password': 'System@123'
'Re-Enter the WebLogic Server Admin user password': "System@123"
'Enter a new PeopleSoft WebProfile user [PTWEBSERVER] password': "PTWEBSERVER"
'Re-Enter the PeopleSoft WebProfile user password': "PTWEBSERVER"
'Enter the PeopleSoft Integration Gateway user': "administrator"
'Enter the PeopleSoft Integration Gateway user [administrator] password': "Passw0rd"
'Re-Enter the Integration Gateway user password': "Passw0rd"
'Are you happy with your answer? [y\|n]': "y"
'Do you want to continue with the default initialization process': "y"
timeout: 500


and i got the error 


fatal: [o...@129.213.167.209]: FAILED! => {"changed": true, "cmd": "./linux/setup/psft-dpk-setup.sh", "delta": "0:08:21.740485", "end": "2018-10-05 05:45:09.884143", "msg": "command exceeded timeout", "rc": null, "start": "2018-10-05 05:36:48.143658", "stdout": "\u001b[3;J\u001b[H\u001b[2J\r\nStarting the PeopleSoft Environment Setup Process: \r\n\r\nValidating User Arguments: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]\r\nValidating PeopleSoft Supported Platform: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]\r\n\r\n\r\n\r\nVerifying if Puppet Software is Installed: \r\n\u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]\r\nVerifying if eYAML Hiera Backend is Installed: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]\r\n\r\nPreparing the Redhat Linux VM for PeopleSoft Environment: \r\n\r\nChecking if PeopleSoft DPKs are Present: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]\r\n\r\nThe base directory is used to extract the PeopleSoft DPKs. It is also\r\nused to deploy the PeopleSoft components. This directory should be\r\naccessible on the Linux VM, must have write permission and should\r\nhave enough free space.\r\n\r\nEnter the PeopleSoft Base Directory: /peoplesoft\r\nAre you happy with your answer? [Y|n|q]: Y\r\n\r\nChecking if the Base Directory has Enough Free Space: Checking if Default User Home Directory /home is Writable: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]\r\n\r\n\r\n\r\nValidating the PeopleSoft DPKs in the Linux VM: \r\nValidating the PeopleSoft Application DPK: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]\r\nValidating the PeopleSoft PeopleTools Server DPK: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]\r\nValidating the Oracle Server Database DPK: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]\r\nValidating the PeopleSoft PeopleTools Client DPK: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]\r\nValidating the Elasticsearch DPK: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]\r\nValidating the PeopleSoft PeopleTools DEP DPK: Validating the Manifest Information in PeopleSoft DPKs: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]\r\n\r\nExtracting the PeopleSoft DPK Archives in the Linux VM: \r\nExtracting the Oracle Database Server DPK Archive: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]\r\nExtracting the PeopleSoft PeopleTools Server DPK Archives: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]\r\nExtracting the PeopleSoft FSCM Application DPK Archives: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]\r\n\r\nExtracting the 8.56 PeopleSoft PeopleTools Client DPK Archive: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]\r\nExtracting the 8.55 PeopleSoft PeopleTools Client DPK Archive: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]\r\nExtracting the 8.54 PeopleSoft PeopleTools Client DPK Archive: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]\r\nExtracting the Oracle Database Client DPK Archive: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]\r\n\r\nSetting up Puppet on the Linux VM: \r\nGenerating eYAML Hiera Backend Encryption Keys: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]\r\nUpdating the Puppet Hiera YAML Files in the Linux VM: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]\r\nUpdating the Role in Puppet Site File for the Linux VM: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]\r\n\r\nEnter the PeopleSoft installation [PUM or FRESH] type [PUM]: ", "stdout_lines": ["\u001b[3;J\u001b[H\u001b[2J", "Starting the PeopleSoft Environment Setup Process: ", "", "Validating User Arguments: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]", "Validating PeopleSoft Supported Platform: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]", "", "", "", "Verifying if Puppet Software is Installed: ", "\u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]", "Verifying if eYAML Hiera Backend is Installed: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]", "", "Preparing the Redhat Linux VM for PeopleSoft Environment: ", "", "Checking if PeopleSoft DPKs are Present: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]", "", "The base directory is used to extract the PeopleSoft DPKs. It is also", "used to deploy the PeopleSoft components. This directory should be", "accessible on the Linux VM, must have write permission and should", "have enough free space.", "", "Enter the PeopleSoft Base Directory: /peoplesoft", "Are you happy with your answer? [Y|n|q]: Y", "", "Checking if the Base Directory has Enough Free Space: Checking if Default User Home Directory /home is Writable: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]", "", "", "", "Validating the PeopleSoft DPKs in the Linux VM: ", "Validating the PeopleSoft Application DPK: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]", "Validating the PeopleSoft PeopleTools Server DPK: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]", "Validating the Oracle Server Database DPK: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]", "Validating the PeopleSoft PeopleTools Client DPK: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]", "Validating the Elasticsearch DPK: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]", "Validating the PeopleSoft PeopleTools DEP DPK: Validating the Manifest Information in PeopleSoft DPKs: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]", "", "Extracting the PeopleSoft DPK Archives in the Linux VM: ", "Extracting the Oracle Database Server DPK Archive: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]", "Extracting the PeopleSoft PeopleTools Server DPK Archives: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]", "Extracting the PeopleSoft FSCM Application DPK Archives: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]", "", "Extracting the 8.56 PeopleSoft PeopleTools Client DPK Archive: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]", "Extracting the 8.55 PeopleSoft PeopleTools Client DPK Archive: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]", "Extracting the 8.54 PeopleSoft PeopleTools Client DPK Archive: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]", "Extracting the Oracle Database Client DPK Archive: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]", "", "Setting up Puppet on the Linux VM: ", "Generating eYAML Hiera Backend Encryption Keys: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]", "Updating the Puppet Hiera YAML Files in the Linux VM: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]", "Updating the Role in Puppet Site File for the Linux VM: \u001b[70G[\u001b[1;32m  OK  \u001b[0;39m]", "", "Enter the PeopleSoft installation [PUM or FRESH] type [PUM]: "

as you can see in the last line it is not taking the value PUM of the prompted question

please help.

Krishan Chawla

unread,
Oct 5, 2018, 2:53:40 AM10/5/18
to Ansible Project
the problem is after the fourth response of "Y" there is extraction of files and it takes time. Would this have any problem?

Brad Van Orden

unread,
Oct 5, 2018, 6:11:19 AM10/5/18
to Ansible Project
This is tough.  Is there a directory that pops up when the installation is complete?  You could add:

wait_for:
  path: /peoplesoft

or just wait for a set period of time:

wait_for:  timeout=600

Or may async is better?

- name: Run bash file
   expect:
   async: 600
   poll: 10
     echo: yes
     command: ./linux/setup/psft-dpk-setup.sh
        responses:

Something like that might work?

Krishan Chawla

unread,
Oct 5, 2018, 7:30:09 AM10/5/18
to Ansible Project
It is showing the same exact error. 

Brad Van Orden

unread,
Oct 5, 2018, 8:06:23 AM10/5/18
to Ansible Project
I think we need someone with more experience using expect.  :(
Oracle really needs to provide a method to supply all responses either on the command line or in a file so that this can run unattended.  I've never used the expect module.  So, I'm guessing at best. 

Maybe try:  Turn on debugging?

Brad Van Orden

unread,
Oct 5, 2018, 8:42:10 AM10/5/18
to Ansible Project
The notes in the expect module documentation state: 
The expect module is designed for simple scenarios. For more complex needs, consider the use of expect code with the shell or script modules. (An example is part of the shell module documentation)
 
In the shell module, there is an example of running a command with expect.  Since this is more complicated and involved, maybe you should try that path?
Reply all
Reply to author
Forward
0 new messages