小编Mee*_*han的帖子

如何让 Ansible 只打印有 stdout 的任务

我有一本包含多个任务的剧本。我需要 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)

ansible

6
推荐指数
1
解决办法
5447
查看次数

每 6 个空格后将一行转换为多行

我有如下文字

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',但它会在每个空格后打印行。

unix bash shell awk sed

2
推荐指数
1
解决办法
70
查看次数

标签 统计

ansible ×1

awk ×1

bash ×1

sed ×1

shell ×1

unix ×1