所以首先,我可能在这里错过了一些非常简单的东西,我只是看不到它。我正在尝试将 ansible pull 与 aws_ec2 库存插件一起使用,以使用打包程序在 AWS 中的 EC2 实例上运行。我有以下库存文件:
plugin: aws_ec2
regions:
- eu-west-1
- eu-west-2
keyed_groups:
- key: tags['role']
prefix: enc
filters:
instance-state-name: running
tag:ami: "true
当我跑步时,ansible-inventory -i /tmp/ansible/inventories/dev/ami_inventory_aws_ec2.yml --list我得到以下组:
"all": {
"children": [
"aws_ec2",
"enc_web",
"ungrouped"
]
},
"aws_ec2": {
"hosts": [
"ip-10-93-66-209.eu-west-1.compute.internal"
]
},
"enc_web": {
"hosts": [
"ip-10-93-66-209.eu-west-1.compute.internal"
]
}
这是我期望看到的。然后在我的剧本中,我有以下内容:
---
- import_playbook: bootstrap.yml
- hosts: enc_web
gather_facts: True
roles:
- name: enc.base
....
在这一点上,我认为运行ansible-pull或ansible-playblook有或没有--limit enc_webansible 会匹配组名并运行,但相反我得到
[WARNING]: Could not match supplied host pattern, ignoring: ami-aws-web-01
ERROR! Specified hosts and/or --limit does not match any hosts
我在这里错过了一些非常基本的东西吗?它应该针对该组名中的所有主机运行吗?
我完整的ansible命令是:
ansible-pull --url=git@bitbucket.org:XXXXX/ansible.git --accept-host-key --directory=/tmp/ansible --full --checkout=web --private-key=/home/ubuntu/.ssh/ansible/ansible -e ami=true -e region=eu-west-1 --vault-password-file=~/.ssh/ansible/dev --inventory-file=/tmp/ansible/inventories/dev/ami_inventory_aws_ec2.yml playbooks/web.yml --limit enc_web