繁体   English   中英

"Ansible 安装不工作,怀疑是 CentOS7 的问题"

[英]Ansible install not working, suspect it's a CentOS7 thing

当我尝试调用我的剧本时,我正在设置 Ansible 并收到此错误:

错误! 无法解析模块/操作“amazon.aws.ec2”。 这通常表示拼写错误、缺少集合或不正确的模块路径。

为了解决这个问题,我升级了 Ansible。 我用 --user 和 sudo 都试过了。 我想我可能已经将它安装在用户下以及全球范围内......

所以现在在 root 和用户 BI 下可以运行“ansible --version”,我得到:

    [userB@i-server~]$ ansible --version
    [DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting 
    with Ansible 2.12.
    Current version: 3.6.8 (default, Nov 16 2020, 16:55:22) [GCC 4.8.5 20150623 (Red Hat 4.8.5- 
    44)]. This feature
    will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by 
    setting
    deprecation_warnings=False in ansible.cfg.
ansible [core 2.11.8]
  config file = None
  configured module search path = ['/home/userB/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/userB/.local/lib/python3.6/site-packages/ansible
  ansible collection location = /home/userB/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.6.8 (default, Nov 16 2020, 16:55:22) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
  jinja version = 3.0.3
  libyaml = True

如果我在用户 A(gitlab-runner,我想使用的用户)下运行,我会得到这个:

[gitlab-runner@i-server~]$ ansible
Traceback (most recent call last):
  File "/usr/local/bin/ansible", line 34, in <module>
    from ansible import context
ModuleNotFoundError: No module named 'ansible'
[gitlab-runner@i-server~]$ which ansible
/usr/local/bin/ansible

与 pip 相同:

[gitlab-runner@i-server~]$ pip
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 7, in <module>
    from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip._internal'
[gitlab-runner@i-server~]$ which pip
/usr/local/bin/pip

所以这是捡起来的,/user/local/bin 在 PATH 中,我真的很难过。

我只是希望能够以 gitlab-runner 用户身份使用 aws 模块运行 ansible 剧本。 提前致谢!

如错误消息所述

错误! 无法解析模块/操作amazon.aws.ec2 这通常表示拼写错误、缺少集合或不正确的模块路径。

Amazon.Aws模块是Ansible Collections的一部分,需要通过命令ansible-galaxy collection install amazon.aws到您的

ansible collection location = /home/userB/.ansible/collections:/usr/share/ansible/collections

您还可以查看Community AWS Collection

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM