Eu quero usar as ferramentas de espera no script bash por ansible. primeiro, passo meu script de shell. Verificando a $JAVA_HOME
variável. Eu configurei, $JAVA_HOME
mas no Ansible, recebo um erro.
Meu env
para $JAVA_HOME
:
[root@portal bin]# env | grep JAVA
JAVA_HOME=/usr/java/jdk1.8.0_161
e minha concha:
#!/usr/bin/expect -f
set timeout 1
spawn /opt/install.sh
expect "\[input\] Are you installing the application at the central data center? \[yes/no default: yes\]? \[yes\]\r"
send "yes\r"
expect "\[input\] What is the code of central data center \[default: 01\]? \[01\]\r"
send "01\r"
expect "What is ip or hostname of your server \[default: localhost\]? \[localhost\]\r"
send "portal\r"
minha cartilha:
- name: --- run portal expect ---
shell: |
cd /opt/
chmod +x portal
./portal
Finalmente Erro no Ansible:
TASK [ansible-portal : --- run portal expect ---]
****************************************************************************************************
fatal: [portal]: FAILED! => {"changed": true, "cmd": "cd /opt/installer/bin/\n chmod +x portal\n ./portal", "delta": "0:00:00.015509", "end": "2018-07-07 14:01:57.971794",
"msg": "non-zero return code", "rc": 1, "start": "2018-07-07 14:01:57.956285", "stderr": "send: spawn id exp6 not open\n
while executing\n\"send \"yes\\r\"\"\n (file \"./portal\" line 8)", "stderr_lines": ["send: spawn id exp6 not open", "
while executing", "\"send \"yes\\r\"\"", " (file \"./portal\" line 8)"], "stdout": "spawn /opt/installer/bin/install.sh\r\nChecking input tasks\r\nSetting
ANT_HOME\r\nChecking Java\r\nError: No JAVA_HOME is set", "stdout_lines":
["spawn /opt/installer/bin/install.sh", "Checking input tasks", "Setting ANT_HOME",
"Checking Java", "Error: No JAVA_HOME is set"]}
Não há problema ao executar o script como de costume.