Closed mick1627 closed 1 year ago
HI @mick1627 I am sorry for late reply. Can you share me the error when running alicloud_ecs.py with python 3.8?
@amolari Can you share us the error when running alicloud_ecs.py with python 3.8?
@zopcorn There is no error, but the filtering is ignored.
@amolari Do you want to get some instances by filters dynamically? If so, you can refer to https://docs.ansible.com/ansible/latest/user_guide/intro_dynamic_inventory.html#other-inventory-scripts .
@xiaozhu36 : we're using AWX/tower, so filter partly dynamically through limits. However, we need some pre-filtering (for safety) at the inventory level too. That was working perfectly before using Pythong 3.8.
@amolari would you please try to use aliyun-python-sdk-ecs with version 2.1.3 ? Since we do not have your ansible playbook, we are not able to test it.
filters on tags is now working with pip module aliyun-python-sdk-ecs version 4.24.22
But now I have an other issue setting setting hostname variables to a specific tag does not work anymore.
Here my alicloud.yml file
plugin: alicloud_ecs
alicloud_region: cn-shanghai
keyed_groups:
# add hosts to instance_type groups
- prefix: instance_type
key: instance_type
# add hosts to instance_name groups
- key: instance_name
prefix: name
- key: availability_zone
prefix: ''
separator: ''
- key: "availability_zone | regex_replace('^(.*)-[^-]+$', '\\1')"
prefix: ''
separator: ''
- key: tags
prefix: tag
parent_group: tags
cache: false
cache_plugin: jsonfile
cache_timeout: 7200
cache_connection: /tmp/alicloud_inventory
cache_prefix: alicloud_ecs
# Add hosts to group based on Jinja2 conditionals
groups:
# add hosts to the group Spinnaker if instance_name starts with 'k8sSpinnaker'
# Spinnaker: instance_name.startswith('k8sSpinnaker')
# Create vars from jinja2 expressions
compose:
# set the ansible_host variable to connect with the public ip address without changing the hostnames
ansible_host: private_ip_address
#If true make invalid entries a fatal error, otherwise skip and continue
#Since it is possible to use facts in the expressions they might not always be available and we ignore those errors by default.
strict: false
filters:
tags:
Name: stfeagt04
hostnames:
- tags: fqdn
@zopcorn you can test the inventory plugins with the command ansible-inventory -i alicloud.yml --list no needs to run playbook.
@mick1627 OK, let me have a check.
@xiaozhu36 any news please?
Hi @amolari @mick1627 I am sorry for late reply. This issue has been fixed the by #309 and you can build a new collection to have a try.
In addition, the hostnames
in inventory file should be as following:
hostnames:
- tag:fqdn
Filter on tags does not work anymore with ansible on python 3.8. It works on python 3.6.
Here the filers part from alicloud.yml
The ansible-inventory return all ecs instances.
Filtering on instance ids works.