stdout
的apt
下面是如何再现stdout
的apt
...
--- - 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..." ]