Ansible-pull 没有库存限制
Ansible-pull with no inventory limitations
我想要一组 git 存储库,其中包含基本的应用程序配置手册,这样我需要对任何 VM 做的所有事情,无论它的名称或角色,也不管它存在了多久,安装基本配置是 运行 针对此 repo 的 ansible-pull 命令,我准备好使用实例。我 运行 遇到的问题是,如果我有一个剧本 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'
但我不想要那样,我想要任何主机,无论其名称或角色是否已知能够 运行 对 repo 和 运行 的 ansible-pull playbook,而无需将主机名称显式配置到清单中。我该怎么做?
这是我在虚拟机中用于 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。
我想要一组 git 存储库,其中包含基本的应用程序配置手册,这样我需要对任何 VM 做的所有事情,无论它的名称或角色,也不管它存在了多久,安装基本配置是 运行 针对此 repo 的 ansible-pull 命令,我准备好使用实例。我 运行 遇到的问题是,如果我有一个剧本 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'
但我不想要那样,我想要任何主机,无论其名称或角色是否已知能够 运行 对 repo 和 运行 的 ansible-pull playbook,而无需将主机名称显式配置到清单中。我该怎么做?
这是我在虚拟机中用于 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。