Ansible 2.1.2.0
のAnier ec2_asg
モジュールで作業しています。私たちは、モジュールec2_asg
掘り下げる可能性のあるec2_asg - TypeError: 'NoneType'オブジェクトは反復不可能です
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: 'NoneType' object is not iterable
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):\n File \"/tmp/ansible_sYlKBr/ansible_module_ec2_asg.py\", line 832, in <module>\n main()\n File \"/tmp/ansible_sYlKBr/ansible_module_ec2_asg.py\", line 821, in main\n create_changed, asg_properties=create_autoscaling_group(connection, module)\n File \"/tmp/ansible_sYlKBr/ansible_module_ec2_asg.py\", line 471, in create_autoscaling_group\n for tag in as_group.tags:\nTypeError: 'NoneType' object is not iterable\n", "module_stdout": "", "msg": "MODULE FAILURE"}
、それはここで失敗している:私は、自動スケーリンググループを作成しようとしているときに、私は次のエラーを取得する
for tag in as_group.tags:
have_tags[tag.key] = [tag.value, tag.propagate_at_launch]
if tag.key not in want_tags:
changed = True
dead_tags.append(tag)
そして、私の可能なタスクは次のとおりです。
- name: Configuring Auto Scaling Group and perform rolling deploy
ec2_asg:
region: "ap-southeast-1a"
name: "MY-ASG"
vpc_zone_identifier: [ "{{ services_1_subnet_id }}", "{{ services_2_subnet_id }}" ]
launch_config_name: "{{ service_group }}-{{ current_datetime }}"
health_check_type: "{{ health_check_type }}"
health_check_period: "{{ health_check_period }}"
desired_capacity: "{{ min_instances }}"
replace_all_instances: yes
replace_batch_size: "{{ replace_batch_size }}"
min_size: "{{ min_instances }}"
max_size: "{{ max_instances }}"
wait_for_instances: yes
wait_timeout: 600
tags:
- Name: "{{ service_group }}"
- deploy_colour: "{{ deploy_colour }}"
- Type: "ABC"
- Env: "{{ env }}"
state: present
register: asg_result
iablesはすでに定義されており、正しいものです。
ASGには既にタグがあります。
'タイプ:" {{item.type}} "'の 'item'とは何ですか?いくつかのリストをループしますか? –
はい。 ' - {name: 'XYZ'、タイプ: 'ABC'}' –
のような項目のリストをループします。ループすると、エラーメッセージに項目の値があるはずです: 'failed:[localhost]( item = {u'type ':u'ABC'、u'name ':u'XYZ'})=> {"failed" ... 'あなたのプレイブックの抜粋に' with_items'を指定していません。 –