0
我想執行從我的git資源中提取的postgresql sql。 我想先提取所有從git倉庫的腳本,然後要執行從一個特定的目錄,我以腳本作爲ansible script.This輸入是我的完整ansible腳本無法執行postgres sql腳本
- hosts: "{{ HOST }}"
become: true
become_user: "admin"
become_method: su
gather_facts: true
vars:
app_path: "{{ app_path }}"
app_dir: "{{ app_dir }}"
tasks:
- stat:
path: "{{ app_path }}/{{ app_dir }}"
register: exist
- name: create "{{ app_path }}/{{ app_dir }}" directory
file: dest="{{ app_path }}/{{ app_dir }}" state=directory
when: exist.stat.exists != True
- git:
repo: http://git-url/postgres-demo.git
dest: "{{ app_path }}/{{ app_dir }}"
version: "{{ GIT_TAG }}"
refspec: '+refs/heads/{{ GIT_TAG }}:refs/remotes/origin/{{ GIT_TAG }}'
update: yes
force: true
register: cloned
- name: Execute postgres dump files
shell: "/usr/bin/psql -qAtw -f {{ item }}"
with_fileglob:
- "{{ app_path }}/{{ app_dir }}/{{ scripts_dir }}/*"
register: postgres_sql
become: true
become_user: "postgres"
become_method: su
上面的腳本執行成功但Postgres的一步扔我下面的減弱:
[WARNING]: Unable to find '/home/admin/postgres-dev/test' in expected paths.
當我查看我的PostgreSQL數據庫,我不覺得,我想使用這個腳本來創建表。