Atualmente, estou tentando automatizar o Oracle Database XE usando o manual ansible. Tudo com a instalação parece estar bem, exceto a etapa em que as variáveis de ambiente do Oracle são definidas:
source /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh
O código no manual ansible é assim:
- name: setup oracle environment
shell: source /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh
shell: reset
shell: /bin/echo 'source /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh' >> /home/vagrant/.bash_profile
- name: create users and schemas on the oracle database
shell: sqlplus SYSTEM/root@XE @ create_schemas_users.sql
Então, quando executo o playbook ansible, no final do processo, recebo algo assim:
TASK [create users and schemas on the oracle database] *******************************************************************************************************************************************************************************
fatal: [wemdbc01]: FAILED! => {"changed": true, "cmd": "sqlplus SYSTEM/root@XE @ create_schemas_users.sql", "delta": "0:00:00.002841", "end": "2017-05-30 08:40:50.652786", "failed": true, "rc": 127, "start": "2017-05-30 08:40:50.649945", "stderr": "/bin/sh: sqlplus: command not found", "stderr_lines": ["/bin/sh: sqlplus: command not found"], "stdout": "", "stdout_lines": []}
to retry, use: --limit @/var/wminst/ansible-config/playbooks/oracle-xe.retry
PLAY RECAP ***************************************************************************************************************************************************************************************************************************
wemdbc01 : ok=6 changed=2 unreachable=0 failed=1
Connection to 127.0.0.1 closed.
O que estou fazendo de errado? Por que depois de executar source /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh
e redefinir o terminal sqlplus
não fica visível para o bash?
Responder1
O shell remoto não consegue encontrar o programa sqlplus. Encontre o caminho do programa no sistema remoto e tente anexá-lo à variável PATH como a primeira parte do comando shell ansible;
shell: "export PATH=$PATH:/mypath/sqlplus; source /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh"