ansibleとvagrantを使用したOracle XEインストールの自動化 - Oracle環境変数が正しく表示されませんか?

ansibleとvagrantを使用したOracle XEインストールの自動化 - Oracle環境変数が正しく表示されませんか?

現在、Ansible PlayBookを使用してOracle Database XEを自動化しようとしています。 Oracle環境変数を設定する手順を除いて、すべてがインストールに問題がないようです。

source /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh

Ansible Playbookのコードは次のとおりです。

- 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

その後、Ansible Playbookを実行すると、プロセスが終了すると次のような結果が表示されます。

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.

私は何が間違っていましたか?実行source /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.shとリセット後に端末がbashに表示されないのはなぜですかsqlplus

ベストアンサー1

リモートシェルがsqlplusプログラムを見つけることができません。リモート・システムでプログラム・パスを見つけ、それをansibleシェル・コマンドの最初の部分としてPATH変数に追加してみてください。

shell: "export PATH=$PATH:/mypath/sqlplus; source /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh"

おすすめ記事