为什么Ansible跳过主机组,什么都不做 [英] Why Ansible skips hosts group and does nothing
问题描述
试图运行我的Ansible和有问题。
这里是我的hosts文件:
trying to run my Ansible and have a problem. here is my hosts file:
[dse]
node1 192.168.56.10
node2 192.168.56.20
node3 192.168.56.30
[opscenter]
opscenter 192.168.56.40
[sparkmasters]
node3 192.168.56.30
[sparkworkers]
node1 192.168.56.10
node2 192.168.56.20
node3 192.168.56.30
下面是我的阳明海运的一部分:
Here is a part of my yml:
---
- hosts: [ "node1", "node2", "node3", "node4" ]
user: vagrant
sudo: True
vars:
username: spark
tasks:
- include: some tasks
roles:
- some roles
- hosts: sparkmasters
vars:
spark.version: 1.2
roles:
- spark_master
- hosts: sparkworkers
vars:
spark.version: 1.2
roles:
- spark_workers
我看到[节点1,节点2,节点3,节点4]运行,但主机:sparkmasters和主机:sparkworkers被跳过的消息:
I see that [ "node1", "node2", "node3", "node4" ] runs, but hosts: sparkmasters and hosts: sparkworkers are skipped with the message:
PLAY [sparkmasters]
************************************************** *********跳绳:没有主机匹配
PLAY [sparkmasters] *********************************************************** skipping: no hosts matched
PLAY [sparkworkers]
************************************************** *********跳绳:没有主机匹配
PLAY [sparkworkers] *********************************************************** skipping: no hosts matched
PLAY重点回顾
************************************************** ******************节点1:OK = 21 =改变可达12 = 0结果
失败= 0
PLAY RECAP
******************************************************************** node1 : ok=21 changed=12 unreachable=0
failed=0
==>节点1:运行置备:ansible ...
==> node1: Running provisioner: ansible...
不要有任何想法,为什么。如果我改变组名的主机阵列,那么它开始工作......
Don't have any idea why. If i change group name to array of hosts, then it start to work...
做我错了吗?
所以我加的调试:
- name: Display hostvars
debug: var=hostvars
和看到这一点:
"hostvars": {
"node1": {
"ansible_all_ipv4_addresses": [
"10.0.2.15",
"192.168.56.10"
],
和这个巨大的JSON有涉及到我的主机更多的元数据
我没有想法,我应该怎么看呢?我没有找到与当前主机组信息的任何信息
and this huge json has much more metadata related to my host I didn't get idea, what should I see there? I didn't find any info related to current host group info
推荐答案
这是ansible +无业游民特色:<一href=\"http://serverfault.com/questions/585722/ansible-not-executing-host-specific-playbook-in-vagrant-multi-machine-provisioni\">http://serverfault.com/questions/585722/ansible-not-executing-host-specific-playbook-in-vagrant-multi-machine-provisioni
It's ansible+vagrant specialities: http://serverfault.com/questions/585722/ansible-not-executing-host-specific-playbook-in-vagrant-multi-machine-provisioni
所以我添加gropus声明,无业游民文件并开始工作:
So I've added gropus declaration to Vagrant file and it started to work:
config.vm.provision "ansible" do |ansible|
ansible.playbook = "deploy.yml"
ansible.groups = {
"dse" => ["dsenode01","dsenode02","dsenode03"],
"opscenter" => ["dsenode03"],
"sparkmasters" => ["dsenode01"],
"sparkworkers" => ["dsenode01","dsenode02","dsenode03"]
}
end
这篇关于为什么Ansible跳过主机组,什么都不做的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!