gpt4 book ai didi

vagrant - Ansible 无法识别 aptitude 的 deb 参数

转载 作者:行者123 更新时间:2023-12-01 05:04:08 25 4
gpt4 key购买 nike

根据http://docs.ansible.com/apt_module.html , aptitude 模块允许从 .deb 文件安装:

# Install a .deb package
- apt: deb=/tmp/mypackage.deb

但是在 Ubuntu 14.04 上运行 Ansible 1.9.2 或 1.8.4,这个配置:
- name: install riak
apt: deb=/data/riak/riak.deb update_cache=no

产生这个输出:
TASK: [riak | install riak] *************************************************** 
failed: [riak-server-1] => {"failed": true}
msg: unsupported parameter for module: deb

相同的 Ansible 脚本在运行 Ansible 1.8.4 和 1.9 的 Mac 上运行良好。

在所有情况下, guest 都是 Vagrant 创建的 ubuntu/trusty64。整个 VM 的创建和设置都是使用 Vagrant 和 Ansible 完成的,我们都使用相同的 Vagrant/Ansible 文件运行。

编辑:
>ansible-playbook --version
ansible-playbook 1.9.2
configured module search path = /usr/share/ansible

>ansible --version
ansible 1.9.2
configured module search path = /usr/share/ansible

>locate apt.py | xargs md5sum
0058a84d0685ad1b67895fdf2da95bc5 /usr/local/lib/python2.7/dist-packages/ansible-1.9.2-py2.7.egg/ansible/modules/core/packaging/os/apt.py
134ac4074dd7929826f5cf888b2ec3ad /usr/local/lib/python2.7/dist-packages/ansible-1.9.2-py2.7.egg/ansible/modules/core/packaging/os/apt.pyc

它是从源代码构建的:
>git status
On branch stable-1.9
Your branch is up-to-date with 'origin/stable-1.9'.

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)

modified: lib/ansible/module_utils/basic.py
modified: lib/ansible/modules/core (modified content)
modified: v2/ansible/modules/core (modified content)

>git diff lib/ansible/module_utils/basic.py
diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py
index 91501b1..3430abe 100644
--- a/lib/ansible/module_utils/basic.py
+++ b/lib/ansible/module_utils/basic.py
@@ -911,7 +911,7 @@ class AnsibleModule(object):
#if k in ('CHECKMODE', 'NO_LOG'):
# continue
if k not in self._legal_inputs:
- self.fail_json(msg="unsupported parameter for module: %s" % k)
+ self.fail_json(msg="unsupported parameter for module: %s. supported parameters are %s" % (k, self._legal_inputs))

def _count_terms(self, check):
count = 0

TASK: [riak | install riak] ***************************************************
failed: [riak-server-3] => {"failed": true}
msg: unsupported parameter for module: deb. supported parameters are ['CHECKMODE', 'NO_LOG', 'dpkg_options', 'upgrade', 'force', 'package', 'pkg', 'name', 'purge', 'state', 'update_cache', 'update-cache', 'default_release', 'default-release', 'install_recommends', 'install-recommends', 'cache_valid_time']

在我看来,它真的像是从某个地方获取了旧版本的 apt.py。我跑了 sudo find / -name apt.py ,而我家有好几份,但只有/usr下的一份。

编辑:

我删除了周围的所有 apt.py 实例,以便:
>sudo find / -name apt.py* | xargs md5sum
134ac4074dd7929826f5cf888b2ec3ad /usr/local/lib/python2.7/dist-packages/ansible-1.9.2-py2.7.egg/ansible/modules/core/packaging/os/apt.pyc
0058a84d0685ad1b67895fdf2da95bc5 /usr/local/lib/python2.7/dist-packages/ansible-1.9.2-py2.7.egg/ansible/modules/core/packaging/os/apt.py

最佳答案

好吧,它现在正在工作。事实证明,运行 sudo apt-get install ansible 时留下了 ansible 的残留物。前一段时间。所以,即使我试图完全擦掉剩下的任何 ansible 位

sudo rm -rf /usr/local/lib/python2.7/dist-packages/ansible* /usr/local/bin/ansible* /usr/bin/ansible*

即使我的系统上没有旧的 apt.py, sudo apt-get remove ansible找到要删除的东西。我以为我在走源路线之前已经运行过它,但显然不是。
>sudo apt-get remove ansible
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
python-jinja2 python-markupsafe python-yaml
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
ansible
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 2,758 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 282489 files and directories currently installed.)
Removing ansible (1.5.4+dfsg-1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...

之后,我重新克隆了源:
git clone git@github.com:ansible/ansible --recursive

并重建:
sudo make clean install
sudo /bin/bash ./hacking/env-setup

现在可以从 .deb 文件安装:
TASK: [riak | install riak] *************************************************** 
changed: [riak-server-3]

关于vagrant - Ansible 无法识别 aptitude 的 deb 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30605302/

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