[英]Ansible install not working, suspect it's a CentOS7 thing
I'm setting up Ansible and getting this error when I try to call my playbook:当我尝试调用我的剧本时,我正在设置 Ansible 并收到此错误:
ERROR!错误! couldn't resolve module/action 'amazon.aws.ec2'.无法解析模块/操作“amazon.aws.ec2”。 This often indicates a misspelling, missing collection, or incorrect module path.这通常表示拼写错误、缺少集合或不正确的模块路径。
In an attempt to fix this, I upgraded Ansible.为了解决这个问题,我升级了 Ansible。 I tried it with both --user and sudo.我用 --user 和 sudo 都试过了。 I think I may have installed it under a user as well as globally....我想我可能已经将它安装在用户下以及全球范围内......
So now under root and user BI can run "ansible --version" and I get:所以现在在 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
If I run under user A (gitlab-runner, the user I want to use) I get this:如果我在用户 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
same with pip:与 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
So which is picking it up, /user/local/bin is in the PATH, I'm really stumped here.所以这是捡起来的,/user/local/bin 在 PATH 中,我真的很难过。
I just want to be able to run ansible playbooks with the aws module as gitlab-runner user.我只是希望能够以 gitlab-runner 用户身份使用 aws 模块运行 ansible 剧本。 Thanks in advance!提前致谢!
As the error message states如错误消息所述
ERROR!错误! couldn't resolve module/action
amazon.aws.ec2
.无法解析模块/操作amazon.aws.ec2
。 This often indicates a misspelling, missing collection, or incorrect module path.这通常表示拼写错误、缺少集合或不正确的模块路径。
the Amazon.Aws modules are part of Ansible Collections and needs to be installed via command ansible-galaxy collection install amazon.aws
and into your Amazon.Aws模块是Ansible Collections的一部分,需要通过命令ansible-galaxy collection install amazon.aws
到您的
ansible collection location = /home/userB/.ansible/collections:/usr/share/ansible/collections
You may also have a look into Community AWS Collection .您还可以查看Community AWS Collection 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.