I am trying to build a configuration file of default services, the service 
command doesn't seem read the variables until the section is executed so I 
have to prefix the variables with enable/state etc.  Is this expected and 
are there any ways around this?

Thanks
Dave 

---
services:
    default:
     ntpd: enabled=yes


-   name: Default services
#    debug: msg="name={{ item.key }} {{ item.value }}"
    service: name={{ item.key }} {{ item.value }}
    with_dict: "{{ services.default }}"


TASK [services : Default services] 
*********************************************
failed: [localhost] => (item={'value': u'enabled=yes', 'key': u'ntpd'}) => 
{"failed": true, "item": {"key": "ntpd", "value": "enabled=yes"}, "msg": 
"Neither 'state' nor 'enabled' set"}


When using *debug* it produces the expected results.

TASK [services : Default services] 
*********************************************
ok: [localhost] => (item={'value': u'enabled=yes', 'key': u'ntpd'}) => {
    "item": {
        "key": "ntpd",
        "value": "enabled=yes"
    },
    "msg": "name=ntpd enabled=yes"
}

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/870639af-aa1b-41cc-8a59-fd36d50e63f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to