【问题标题】:How to create an EC2 instance in aws through Ansible?如何通过 Ansible 在 aws 中创建 EC2 实例?
【发布时间】:2019-10-24 21:52:39
【问题描述】:

我正在尝试使用 ansible 在 aws 中创建一个 ec2 实例。

我事先使用 aws configure 提供了访问密钥 ID 和访问密钥秘密

我从我在 rosttahub 的帐户中获取了这些密钥

这是代码


---
  - name: Launch EC2 Instance
    hosts: local
    connection: local
    tasks:
      - name: Launching_Instance
        ec2:
          key_name: UbuntuKey
          region: eu-west-1
          instance_type: t2.micro
          image: ami-08d658f84a6d84a80
          group: default
          vpc_subnet_id: subnet-904a51c8
          assign_public_ip: yes
          count: 1
          aws_access_key: ''
          aws_secret_key: ''
          wait: yes

这是我的主机文件中包含的内容

[local]
localhost ansible_connection=local ansible_python_interpreter=python

当我运行剧本时

ansible-playbook ec2.yml

PLAY [Launch EC2 Instance] **********************************************************************************************

TASK [Gathering Facts] **************************************************************************************************
ok: [localhost]

TASK [Launching_Instance] ***********************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "boto required for this module"}

PLAY RECAP **************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

【问题讨论】:

标签: amazon-web-services ansible boto aws-cli botocore


【解决方案1】:

您需要安装 boto python 模块。如果你安装了 pip,它很简单:

pip install boto

如果您使用 pip 安装 awscli 模块,它也会安装所有依赖模块

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-15
    • 2016-12-07
    • 1970-01-01
    • 1970-01-01
    • 2023-02-23
    • 2018-07-02
    相关资源
    最近更新 更多