我希望有一组带有基本应用程序配置剧本的git repos,这样我需要对任何VM所做的所有工作,不管它的名称、角色或存在时间,安装基本配置的方法就是对这个repo运行一个ansible- set命令,然后我就可以使用实例了。我遇到的问题是,如果我有一个像这样设置的剧本local.yml:
- hosts: localhost
connection: local
gather_facts: yes
user: root
[...]大概是这样的:
- hosts: all
connection: local
gather_facts: yes
user: root
[...]我一直收到以下错误:
# ansible-pull -d /tmp/myrepo -U 'http://mygithost/myrepo'
Starting ansible-pull at 2015-06-09 15:04:05
localhost | success >> {
"after": "2e4d1c637170f95dfaa8d16ef56491b64a9f931b",
"before": "d7520ea15baa8ec2c45742d0fd8e209c293c3487",
"changed": true
}
**ERROR: Specified --limit does not match any hosts**避免此错误的唯一方法是创建一个具有显式组名和显式主机名的显式库存文件,然后使用'-i‘标志引用,如下所示:
# cat /tmp/myrepo/myinventory
[mygroup]
myhost1
myhost2
# cat /tmp/myrepo/local.yml
- hosts: mygroup
connection: local
gather_facts: yes
user: root
[...]
# ansible-pull -d /tmp/myrepo -i myinventory -U 'http://mygithost/myrepo' 但是我不想那样,我想要任何主机,不管它的名称或角色是否已知能够运行ansible--针对回购和运行游戏手册,而不必显式地将主机的名称配置到库存中。我该怎么做?
发布于 2015-06-11 14:14:38
下面是我在VM中为ansible-pull使用的工作流:
在基本VM中,我将一个名为hosts的文件放在/etc/ansible上
# cat /etc/ansible/hosts
localhost ansible_connection=local我的local.yaml从
- hosts: localhost
gather_facts: yes
user: root
...现在,无需指定主机文件,我就可以使用ansible-pull。
https://stackoverflow.com/questions/30782736
复制相似问题