首页 > 解决方案 > Ansible - 子目录上的 chdir 作为变量

问题描述

我是 Ansible 的新手。我想在以下方面提供圆顶帮助

我正在尝试将 chdir args ia playbok 用于我不知道名称的子目录。父目录是 /tmp/opatch 我需要找到的子目录的名称并将其用作变量

- name: Ansible find files in subdirectory examples
  find:
   path: /tmp/opatch
   file_type: directory
  register: files_matched

- set_fact:
    opathdir:
     - path:  "{{ files_matched.files[0].path }}"

- name: Apply de psu
  shell: $ORACLE_HOME/OPatch/opatch apply -silent -ocmrf /app/stage/bb/ocm.rsp
  args:
   chdir: "{{opathdir}}"
  environment:
   ORACLE_HOME: "{{ oracle_home }}"
   PATH: "{{ oracle_home }}/bin"
  register: applypsu

似乎只有硬编码 chdir 有效,但不能通过变量。

任何帮助表示赞赏

问候,

乔普

标签: ansible

解决方案


推荐阅读