【问题标题】:Ansible reports requires boto.rds (boto >= 2.26.0) even though boto 2.38.0 is installed即使安装了 boto 2.38.0,Ansible 报告也需要 boto.rds (boto >= 2.26.0)
【发布时间】:2015-08-02 09:32:26
【问题描述】:

使用 Ansible 1.9.1 版:

ansible --version
ansible 1.9.1

在 Ubuntu 14.04.2 LTS 上

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.2 LTS
Release:    14.04
Codename:   trusty

我正在使用 Ansible rds 模块来创建数据库:

- hosts: localhost
  gather_facts: False
  sudo: no

  tasks:

    - name: get-boto-version
      local_action: command python -c 'import boto; print boto.__version__'

    - name: Launch RDS instances
      rds:
        region: eu-west-1
        ec2_access_key: "{{ ec2_access_key }}"
        ec2_secret_key: "{{ ec2_secret_key }}"
        command: create
        instance_name: test
        instance_type: db.m1.small
        tags:
          this: that
        db_engine: MySQL
        size: 10
        username: foo
        password: foobar1000
        vpc_security_groups: this
        subnet: that

我想向数据库添加标签,但是当我运行我的剧本时,我收到以下错误:

    ansible-playbook -i ec2 simple-db.yml --extra-vars "ec2_access_key=${AWS_ACCESS_KEY_ID} ec2_secret_key=${AWS_SECRET_ACCESS_KEY}" -v

    PLAY [localhost] ************************************************************** 

    TASK: [get-boto-version] ****************************************************** 
    changed: [127.0.0.1 -> 127.0.0.1] => {"changed": true, "cmd": ["python", "-c", "import boto; print boto.__version__"], "delta": "0:00:00.138097", "end": "2015-05-21 08:36:55.233037", "rc": 0, "start": "2015-05-21 08:36:55.094940", "stderr": "", 
    "stdout": "2.38.0", "warnings": []}

    TASK: [Launch RDS instances] ************************************************** 
    failed: [127.0.0.1] => {"failed": true}
    msg: Parameter tags requires boto.rds (boto >= 2.26.0)

    FATAL: all hosts have already failed -- aborting

    PLAY RECAP ******************************************************************** 
               to retry, use: --limit @/home/chris/simple-db.retry

    127.0.0.1                  : ok=1    changed=1    unreachable=0    failed=1

尽管安装了更高版本的boto。请参阅上面的任务get-boto-version 的输出和...

$ python -c 'import boto; print boto.__version__'
2.38.0

我正在运行virtualenv。已尝试将 PYTHONPATH 设置为显式指向 botovirtualenv 中的位置,但没有骰子。

谁能看出我做错了什么?

【问题讨论】:

  • 你能在 ansible 中运行同样的命令,看看它会打印出什么吗?

标签: python amazon-web-services boto ansible rds


【解决方案1】:

作为库存变量(在$project_root/group_vars/all$project_root/host_vars/localhost 中),指定:

#$project_root/group_vars/all or #host_vars/localhost
ansible_python_interpreter='/usr/bin/env python'

或直接在库存文件中,如:

# inventory file
localhost ansible_python_interpreter='/usr/bin/env python'

这应该会让你摆脱困境。

默认情况下,Ansible 不会拾取 env python。

【讨论】:

  • 感谢 DefionsCode。我实际上希望它在它 似乎 正在做的 virtualenv 中使用 Python,因为添加 local_action: command which python 会产生 virtualenv python 的路径:"stdout": "/home/chris/src/.hc-inf/bin/python"
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-05-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多