gpt4 book ai didi

vagrant - Ansible apt-get 安装输出

转载 作者:行者123 更新时间:2023-12-04 14:42:26 24 4
gpt4 key购买 nike

我正在使用带有 ansible playbook 的 vagrant 在 ubuntu 镜像上自动安装一堆程序。一个程序无法在 vagrant VM 上安装。在 Vagrant我有文件

config.vm.provision :ansible do |ansible|
ansible.verbose = "vvv"
ansible.playbook = "provisioning/playbook.yml"
end

但详细输出不包括 apt-get输出。我的 playbook.yml 看起来像
---
- hosts: all
sudo: true
tasks:
- name: get vi
apt: state=latest name=vim

如何查看单个(或全部)的控制台输出 apt-get install位于 VM 上,因为 ansible 会以以下格式输出每个安装
TASK: [Install vim] *********************************************************** 
failed: [default] => {"failed": true}
...

最佳答案

转载 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..."
]

关于vagrant - Ansible apt-get 安装输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34026875/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com