Reputation: 35
I am trying to restart jboss
on server_group except cgfmgr, its failing. can some please help me with the syntax
TASK:
- name: restarted jboss
service: name=jboss state=restarted enabled=yes
when: inventory_hostname in groups["{{ server_group }}:!cfgmgr-{{ server_group }}"]
Error-
TASK: [restarted jboss] ******************************************************* fatal: [ansible] => error while evaluating conditional: inventory_hostname in groups["sit:!cfgmgr-sit"] FATAL: all hosts have already failed -- aborting
Hostfile
[sit:children]
jboss-sit
cfgmgr-sit
webserver-sit
Upvotes: 1
Views: 2721
Reputation: 68339
You can't use patterns when accessing groups
' elements, only group names.
Try it with group_names
magic variable:
- name: restarted jboss
service: name=jboss state=restarted enabled=yes
when: server_group in group_names and ('cfgmgr-'+server_group) not in group_names
This code is not tested.
Upvotes: 0