使用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设置为明确指向boto
中virtualenv
的位置,但没有骰子。
任何人都可以看到我做错了吗?
答案 0 :(得分:0)
作为广告资源变量(在$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。