2017-11-29 4 views
0

ec2インスタンスを作成するために(これまで)偶数のansibleスクリプトを実行しています。ansible-ec2:インスタンスタイプの変更を適用します

これまでのところ、私の役割のデフォルトセクションには、ec2のパラメータを持つ辞書が多かれ少なかれ次のようにありました。

my_instances: 
- instance_type: "t2.micro" 
    exact_count: "1" 
    assign_public_ip: "no" 
- instance_type: "t2.micro" 
    exact_count: "1" 
    assign_public_ip: "no" 

およびそれらのVARSに基づいて、次のタスクを実行している:

- name: Create my instances 
    ec2: 
    instance_type: "{{ item.ec2_instance_type }}" 
    region: "us-east-1" 
    image: "some-image" 
    group_id: "some-group-id" 
    vpc_subnet_id: "some-subnet-id" 
    instance_tags: 
    with_items: "{{ my_instances }}" 

それらのインスタンスはべき等があると私は言ったように、スクリプトを実行しているです。

インスタンスタイプの1つ(t2.micro - >t2.small)が変更されたスクリプトを再実行したいとします。次のように

- instance_type: "t2.small" 

をしかし、私は、上記の変数の変更を行う場合、スクリプトは出力収率が、等冪再度実行:

ok: [localhost] => (item={instance_type': u't2.small'}) 

(出力をトリミング)。

インスタンスタイプがt2.micro

ですが、なぜでしょう?まま

答えて

0

私が知る限り、リサイズはそのままではサポートされていません。ここでは、私たちのプロジェクトで使用ec2.pyためのパッチがあります:

@@ -1416,6 +1381,13 @@ 
       inst.modify_attribute('disableApiTermination', termination_protection) 
       changed = True 

+   # Check "instance_type" attribute 
+   if instance_type and inst.get_attribute('instanceType')['instanceType'] != instance_type: 
+    if inst.state != 'stopped': 
+     module.fail_json(msg='Unable to resize running instance {}'.format(inst.id)) 
+    inst.modify_attribute('instanceType', instance_type) 
+    changed = True 
+ 
      # Check instance state 
      if inst.state != state: 
       instance_dict_array.append(get_instance_info(inst)) 

は、私は、プルリクエストを送信するためにいくつかの時間を見つけることを願っています。

+0

これは私が思ったことです...関連する機能のアイデアは次のとおりです:https://github.com/ansible/ansible/issues/33373 – pkaramol

関連する問題