Host classification problem

18 views
Skip to first unread message

Jan Jungmann

unread,
Jul 31, 2016, 2:14:41 PM7/31/16
to Ansible Project
Hi all,

I am having a problem with host classification. In my hosts file i have a “nodejs:children” group with application “foo”. “foo” has server-a. In site.yml I use hosts: nodejs:&{{ application }} and assign a role. This works well with multiple applications until the same server is configured in multiple groups. Then multiple roles are applied. I would expect only 1 role applied. Any idea what is going wrong? Here is the relevant files:

hosts:
```
[nodejs:children]
foo
[java:children]
bar
[foo]
localhost
[bar]
localhost
```

site.yml:

```

---

- name: deploy nodejs app

  hosts: nodejs:&{{ application }}

  roles:

    - nodejs


- name: deploy java app

  hosts: java:&{{ application }}

  roles:

    - java

```

command:
```
ansible-playbook site.yml -i hosts --check -e 'application=foo'

```

Thanks,
Jan

Brian Coca

unread,
Feb 9, 2017, 10:27:57 PM2/9/17
to Ansible Project
The hostnames in inventory are unique, if you define a host in more
than one place, it is the same host.

--
----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages