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
I see that [ "node1", "node2", "node3", "node4" ] runs, but hosts: sparkmasters and hosts: sparkworkers are skipped with the message:
PLAY [sparkmasters] *********************************************************** skipping: no hosts matched
PLAY [sparkworkers] *********************************************************** skipping: no hosts matched
PLAY RECAP ******************************************************************** node1 : ok=21 changed=12 unreachable=0
failed=0==> node1: Running provisioner: ansible...
Don't have any idea why. If i change group name to array of hosts, then it start to work...
What do I do wrong?
So I've added debug:
- name: Display hostvars
debug: var=hostvars
And see this:
"hostvars": {
"node1": {
"ansible_all_ipv4_addresses": [
"10.0.2.15",
"192.168.56.10"
],
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
It's ansible+vagrant specialities: https://serverfault.com/questions/585722/ansible-not-executing-host-specific-playbook-in-vagrant-multi-machine-provisioni
So I've added gropus declaration to Vagrant file and it started to work: