I'm trying to enable carbon-aggregator with ansible in CentOS7 enabling systemctl service with ansible variable "ansible_processor_cores". And it doesn't works. Here is role example:
- name: enable carbon-aggregator
service:
name: 'carbon-aggregator@{0..{{ansible_processor_cores -3}}}'
enabled: yes
state: started
daemon_reload: yes
Carbon.conf.j2:
{% for aggr in range(ansible_processor_cores -2) %}
[aggregator:{{aggr}}]
{% endfor %}
Error is:
FAILED! => {"changed": false, "failed": true, "msg": "Unable to start service carbon-aggregator@{0..1}: Job for carbon-aggregator@\x7b0..1\x7d.service failed because the control process exited with error code. See \"systemctl status \"carbon-aggregator@\\x7b0..1\\x7d.service\"\" and \"journalctl -xe\" for details.\n"}
As I see here is trying to enable some services that I didnt asked:
carbon-aggregator@\x7b0..1\x7d.service
I don't know where they came from. If I'll do that manually it works perfectly like that:
sudo systemctl enable carbon-aggregator@{0..1}
Any suggestions?
To start up a number of services you could use a
with_sequence
loop. See the Loops documentation for details, although I believe that the documentation forwith_sequence
may be incorrect.An example might look something like:
On a system with four cores, the above loop would call the
service
module four times, withname:
set tocarbon-aggregator@0
,carbon-aggregator@1
,carbon-aggregator@2
, andcarbon-aggregator@3
.