Closed paulo-erichsen closed 1 year ago
it looks like the code to start the service is commented out
https://github.com/arensb/ansible-truenas/blob/main/plugins/modules/service.py#L165-L167
similarly for enabling
https://github.com/arensb/ansible-truenas/blob/main/plugins/modules/service.py#L194-L202
Looks like you're right. This looks like a module that wasn't released; it escaped prematurely.
I believe this is fixed on the bugfix/6-services
branch. @paulo-erichsen, can you please try it out and see if it works for you?
sorry for taking a while to get back. I was out of town for a few days.
I've tried the updated code and it looks good with one caveat.
The NFS service is able to start, but I think it takes a second or so to turn on. I see ansible returning
changed: [root@192.168.122.100] => (item=nfs) => {
"ansible_loop_var": "item",
"changed": true,
"enable_err": 9,
"invocation": {
"module_args": {
"enabled": true,
"ha_propagate": null,
"name": "nfs",
"state": "started"
}
},
"item": "nfs",
"msg": "service started; service enabled",
"service_state": {
"enabled": false,
"id": 9,
"name": "nfs",
"pids": [],
"state": "STOPPED"
}
}
I would expect it to not show "state": "STOPPED"
, but it does start eventually. I guess this is fine as is
Oh! This isn't a bug, or at least not the bug you think it is: the service_state
field in the return value is from the beginning of the module, when it's checking to see whether it needs to do anything, not from the end when the service has been started.
In other words, what it's showing you here is that the service was in "state": "STOPPED"
, which is why it decided that it needed to make a change, and start the service.
that makes sense, thanks for the clarification!
setup:
for some reason, it doesn't seem to start services I have defined
this is my roles/truenas/tasks/main.yml that I'm using
The last step is to enable ssh and nfs. SSH is already started which allows ansible to run, but it doesn't enable it. Also it doesn't seem to enable and start the nfs service.
Running
ansible-playbook -vvv playbooks/truenas.yml
gives meNotice that ansible doesn't return errors, but returns state: STOPPED when it shouldn't