当前位置:  开发笔记 > 编程语言 > 正文

Ansible apt-get安装输出

如何解决《Ansibleapt-get安装输出》经验,为你挑选了1个好方法。



1> Serge Stroob..:
再现stdoutapt

下面是如何再现stdoutapt...

---
- name: 'apt: update & upgrade'
  apt:
    update_cache: yes
    cache_valid_time: 3600
    upgrade: safe
  register: apt
- debug: msg={{ apt.stdout.split('\n')[:-1] }}

…有了不错的换行符,这要归功于.split('\n'),并且省略了最后一个空字符串[:-1],所有这些当然都是Python字符串操作。

"msg": [
    "Reading package lists...", 
    "Building dependency tree...", 
    "Reading state information...", 
    "Reading extended state information...", 
    "Initializing package states...", 
    "Building tag database...", 
    "No packages will be installed, upgraded, or removed.", 
    "0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.", 
    "Need to get 0 B of archives. After unpacking 0 B will be used.", 
    "Reading package lists...", 
    "Building dependency tree...", 
    "Reading state information...", 
    "Reading extended state information...", 
    "Initializing package states...", 
    "Building tag database..."
]

推荐阅读
U友50081205_653
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有