Open atodorov opened 5 years ago
HI @atodorov This issue seems like using a incompatible ansible package. At present, the PR has not been merged by ansible official. If you want to using the latest footmark to run ansible alibaba cloud module, you should install ansible_alicloud
At present, the PR has not been merged by ansible official.
you should try making this piece of code not fail then. I will try ansible_alicloud.
@xiaozhu36 python3上运行失败,是不是这个版本还不支持python3?
@xuanyunhui footmark从1.13.0版本开始仅支持python3.6。推荐使用目前最新版本1.15.0。
sh-4.4# ansible --version
ansible 2.8.5 config file = /etc/ansible/ansible.cfg configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python3.6/site-packages/ansible executable location = /usr/bin/ansible python version = 3.6.8 (default, Oct 11 2019, 15:04:54) [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)]sh-4.4# pip3 list aliyun-python-sdk-alidns (2.0.14) aliyun-python-sdk-core (2.13.13) aliyun-python-sdk-core-v3 (2.13.11) aliyun-python-sdk-ecs (4.11.0) aliyun-python-sdk-ess (2.3.0) aliyun-python-sdk-rds (2.4.4) aliyun-python-sdk-slb (3.2.7) aliyun-python-sdk-sts (3.0.1) aliyun-python-sdk-vpc (3.0.7) ansible (2.8.5) asn1crypto (0.24.0) Babel (2.5.1) bcrypt (3.1.6) cffi (1.11.5) cryptography (2.3) dbus-python (1.2.4) decorator (4.2.1) ethtool (0.14) footmark (1.15.0) gpg (1.10.0) idna (2.5) iniparse (0.4) Jinja2 (2.10.1) jmespath (0.9.4) MarkupSafe (0.23) paramiko (2.4.3) pip (9.0.3) ply (3.9) pyasn1 (0.3.7) pycparser (2.14) pycryptodome (3.9.4) pygobject (3.28.3) pyinotify (0.9.6) PyNaCl (1.3.0) python-dateutil (2.6.1) python-dmidecode (3.12.2) pytz (2017.2) PyYAML (3.12) rpm (4.14.2) setuptools (39.2.0) six (1.11.0) subscription-manager (1.25.17) syspurpose (1.25.17)
The full traceback is:
Traceback (most recent call last):
File "/root/.ansible/tmp/ansible-tmp-1579594959.5246859-181561173959184/AnsiballZ_ali_instance.py", line 114, in
@lixue323 已经是1.15.0版本的,感觉是python3兼容性的问题
@xuanyunhui pip install virtualenv 安装虚拟环境 virtualenv env3 --python=python3 创建3的虚拟环境env3 source env3/bin/activate 激活虚拟环境 pip install ansible_alicloud 在虚拟环境中安装ansible_alicloud 在虚拟环境中,麻烦再运行一下文件。 应该是python2与python3共存的问题。
@lixue323 我新起一个干净的CentOS8系统,按照你的步骤执行,之后运行测试的playbook问提依旧。再附上我的测试playbook
- name: Create a new ECS
hosts: localhost
connection: local
tasks:
- name: Create an ECS instance
ali_instance:
alicloud_region: cn-beijing
image_id: centos_8_0_x64_20G_alibase_20191225.vhd
instance_type: ecs.c6.large
instance_name: jenkins-master
host_name: jenkins-dna-1.pub.bj
key_name: '***'
vswitch_id: vsw-*********
security_groups: sg-**********
count: '1'
allocate_public_ip: false
instance_tags:
role: jenkins
register: ecs
- name: output information of the vm
debug:
msg: "The created vm is {{ ecs }}."
@lixue323 我测试下来最终看来这个问题确实是包冲突引起的,我的环境里只有一个版本的python,可以排除python版本的问题,但是env环境和机器环境的模块包有区别。我再排查一下,有进度再来反馈
@xuanyunhui 启动虚拟环境,pip install ansible_alicloud --no-cache-dir 在虚拟环境中在试一下。
@lixue323 我找到最终的原因了,ansible里面已经集成的alicloud的模块,这个模块不兼容footmark,默认调用的是ansible自己的模块,我把调用改成优先调用pip install的alicloud模块就能正常工作了。 ansible-alicloud这个最新的版本会PR到ansible吗?
@xuanyunhui pip install ansible_alicloud 执行这个命令之后,会自动安装footmark以及ansible, 并且会替换最新的alicloud到ansible中,你的问题是出现在先手动安装了ansible。ansible中alicloud不是最新版本。感谢你的反馈,对于我们非常有帮助。
This is with 1.11.0, here's my entire pip freeze b/c I've installed ansible 2.8 from GitHub: