Use ansible expect task instead of expect command

Change-Id: Iba56ceb85278563d00a0cb3f019a9097c06a2066
This commit is contained in:
Douglas Mendizábal 2020-04-27 13:07:56 -05:00
parent 7e610873a9
commit ad607397a4
2 changed files with 5 additions and 29 deletions

View File

@ -1,18 +0,0 @@
#!/usr/bin/expect -f
set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
set timeout -1
spawn /usr/safenet/lunaclient/bin/lunacm -c hagroup listgroups
match_max 100000
expect " Enter the password: "
send -- "\r"
expect eof

View File

@ -70,23 +70,17 @@
- "'Command Result : No Error' not in result.stdout"
- "'The member you specified is already part of an' not in result.stdout"
- name: Copy expect script to check HA status
copy:
src: list-ha-groups.j2
dest: /usr/safenet/lunaclient/bin/list-ha-groups
owner: root
group: root
mode: 0755
- name: Check the HA group
shell: |
/usr/safenet/lunaclient/bin/list-ha-groups
expect:
command: /usr/safenet/lunaclient/bin/lunacm -c hagroup listgroups
responses:
password: "\r"
register: result
failed_when: "'Command Result : No Error' not in result.stdout"
- name: Register the HA Slot ID
shell: |
set -o pipefail && /usr/safenet/lunaclient/bin/list-ha-groups | grep 'HA Group Slot ID' | awk '{ print $NF }'
set -o pipefail && echo "{{ result.stdout }}" | grep 'HA Group Slot ID' | awk '{ print $NF }'
register: ha_slot
- debug: