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"
}