首页 文章

如何使用Ansible的ec2-modify-instance-attribute命令?

提问于
浏览
1

我正在尝试从ansible中修改AWS实例 .

我的playbook旨在在正在运行的AWS实例上编译和安装ixgbevf驱动程序,然后将其关闭,以便可以运行ec2-modify-instance-attribute命令 .

直到等式的最后部分的一切都有效 .

我的最终角色节看起来像这样:

- name: Turn on enhanced networking on on the AMI host
  local_action: ec2-modify-instance-attribute the_instance_id={{ my_instance_id }}  --sriov simple --region us-west-2
  with_items: ec2_info.instances
  ignore_errors: yes

当角色运行时,我得到以下错误:

fatal: [10.11.31.48 -> 127.0.0.1] => module ec2-modify-instance-attribute not found in configured module paths
FATAL: all hosts have already failed -- aborting

有没有办法在Ansible中使用ec2-modify-instance-attribute命令?

2 回答

  • 1

    我结束了以下工作:

    - name: "Stop the AWS instance"
      local_action:
         module: ec2
         state: stopped
         aws_access_key: "{{ aws.ec2.access_key_id }}"
         aws_secret_key: "{{ aws.ec2.secret_access_key }}"
         instance_ids: "{{ ansible_ec2_instance_id }}"
         region: "{{ ansible_ec2_placement_region }}"
         wait: True
    
  • 0

    尝试使用此CLI解决方法

    local_action:
      module: >
        shell
          aws ec2 modify-instance-attribute --instance-id "{{ ec2_id }}"
          --groups "{{ec2_security_group_ids}}" "{{newgroup.group_id}}"
       when: newgroup.group_id not in ec2_security_group_ids
    

相关问题