Here is an example of using expect from the ansible-doc shell output.

# You can use shell to run other executables to perform actions inline
- name: Run expect to wait for a successful PXE boot via out-of-band CIMC
  ansible.builtin.shell: |
    set timeout 300
    spawn ssh admin@{{ cimc_host }}

    expect "password:"
    send "{{ cimc_password }}\n"

    expect "\n{{ cimc_name }}"
    send "connect host\n"

    expect "pxeboot.n12"
    send "\n"

    exit 0
  args:
    executable: /usr/bin/expect
  delegate_to: localhost

In your case you might need to change it to look like this:

    - name: Install
      shell: |
        set timeout -1
        log_file /tmp/nbexpect.log
        spawn /usr/openv/netbackup/bin/goodies/nbcomponentupdate -product 
NetBackup -component jre -path /tmp/jdk1.8.0_341
        expect "Do you wish to continue"
        sleep 1
        send "y\n"

I have not done this myself. This is just a guess based on the ansible-doc page 
for the shell module.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Sep 26, 2022, at 8:47 AM, Andrew Okullu 
<[email protected]<mailto:[email protected]>> wrote:

Dear Team
i have an issue. I have written a playbook that will perform and update of the 
netbackup java.
############################################################
Expect section

    - name: Install
      shell: |
        set timeout -1
        log_file /tmp/nbexpect.log
        spawn /usr/openv/netbackup/bin/goodies/nbcomponentupdate -product 
NetBackup -component jre -path /tmp/jdk1.8.0_341
        expect {
          "Do you wish to continue" {
            sleep 1
            send "y\n"
            exp_continue
            }

            }
################### Log waiting at prompt
spawn /usr/openv/netbackup/bin/goodies/nbcomponentupdate -product NetBackup 
-component jre -path /tmp/jdk1.8.0_341
Command line: /usr/openv/netbackup/bin/goodies/nbcomponentupdate -product 
NetBackup -component jre -path /tmp/jdk1.8.0_341

Java Runtime Envrionment(JRE) version installed with product 'Veritas 
NetBackup'                                 : 1.8.0_331 (64bit)
Java Runtime Envrionment(JRE) version found at path '/tmp/jdk1.8.0_341'         
                                 : 1.8.0_341 (64bit)

This utility will update the Java Runtime Envrionment(JRE) binaries present at 
'/usr/openv/java/jre' path

This utility may start and stop all (or some) services depending upon the 
present state of services.


Do you want to continue (Y[es]/N[o]):

>From the log file its waiting at the prompt to continue the install.

Some guidance on where am going wrong.

Kind Regards
Andrew Okullu
Mob:+256-772-418560, +256754213295
| Skype:aokullu | twitter: @aokullu | gtalk: aokullu

--
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
[email protected]<mailto:[email protected]>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CABcUpdpO7UkDCuCyGwZO3QEBUZWrmmZXsP6rVb_Ekqv%3DVJr9hg%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/97E050BA-3770-4799-AADF-68EFBDC2D5C9%40nist.gov.

Reply via email to