我有一本包含多个任务的剧本。我需要 Ansible 只打印包含 STDOUT /debug 任务的任务
- hosts: "{{ v_host }}"
gather_facts: no
tasks:
- name: "Create /tmp in target in all VM's "
file:
path: /tmp
state: directory
owner: oracle
group: oinstall
mode: 0775
- copy:
src: /xxx
dest: /yyy
owner: oracle
group: oinstall
force: yes
mode: 0755
- name: "Performing {{ patch_action }} of CPU patch on {{ v_host }} "
shell: |
cd /tmp
sudo -u oracle ./patch.sh
register: out
- debug: var=out.stdout_lines
Run Code Online (Sandbox Code Playgroud)
我执行不带 -v 选项的剧本以获得更清晰的输出。输出如下所示。
ansible-playbook …Run Code Online (Sandbox Code Playgroud) 我有如下文字
Current state of abc : RUNNING Current state of def : RUNNING Current state of ghi : RUNNING
Run Code Online (Sandbox Code Playgroud)
我希望将这一行分成多行,如下所示
Current state of abc : RUNNING
Current state of def : RUNNING
Current state of ghi : RUNNING
Run Code Online (Sandbox Code Playgroud)
我尝试使用 tr 命令tr ' ' '\n',但它会在每个空格后打印行。