-
-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve an issue with the systemd/sysvinit ansible conflict #65
Resolve an issue with the systemd/sysvinit ansible conflict #65
Conversation
Currently, there appears to be an issue with Ansible in which, if a service is already enabled with sysvinit, the service will not be enabled with Ansible. This appears to be the condition with this repository; likely, the upstream package is bringing in the sysvinit script (as it's not being deployed by ansible) and enabling it. This commit implements a workaround as documented ansible/ansible-modules-core#3764 (comment). While, confusingly, the package is "using" the sysvinit style service tool for enabling the service, systemd implements a compatibility layer that allows enabling it via this shim. This correctly enables the service. See ansible/ansible#22303 See geerlingguy/ansible-role-php@84ab337
- ansible service/systemd module fails to enable some services - ansible/ansible-modules-core#3764 - geerlingguy/ansible-role-varnish#65
- systemd module (and service module, which uses systemd module per deault) has a problem with sysvinit services - see: geerlingguy/ansible-role-varnish#65
tasks/main.yml
Outdated
with_items: "{{ varnish_enabled_services | default([]) }}" | ||
when: > | ||
varnish_enabled_services and | ||
(ansible_os_family == 'Debian' and ansible_distribution_release == "xenial") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line needs a newline.
tasks/main.yml
Outdated
use: "service" | ||
with_items: "{{ varnish_enabled_services | default([]) }}" | ||
when: > | ||
varnish_enabled_services and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For compound when
conditions, you can use the style:
when:
- varnish_enabled_services
- ansible_os_family == 'Debian' and ansible_distribution_release == "xenial"
I just discovered this recently, and am trying to get all my roles to use that style for complex conditionals; can you update these to use that style too?
Recently, Ansible introduced the capability to sum "when" conditions as a yaml list (something like a json array). When formatted thusly: when: - foo == "bar" - baz == "herp" All conditionals are logically "and"ed together. See http://docs.ansible.com/ansible/playbooks_conditionals.html#the-when-statement Further, a line break was added to the bottom of this file.
name: "{{ item }}" | ||
state: started | ||
enabled: yes | ||
use: "service" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another question here—isn't this task the exact same as the task above? I don't see why we'd need to have two tasks that do the exact same thing, but one for Xenial, and another for all other versions...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ehhrm good catch. The initial one shouldn't use service
-- instead, it should just use the Ansible default init system, in case the shim for sysvinit
disappears at some point. I'll fix that up.
Previous work implemented a workaround for an ansible issue in which, in some cases, Ansible would not detect correctly whether a service is enabled. However, the author inadvertently committed a change to both tasks. This commit removes the change to the original task such that it will use the ansible service auto-dectection, and not sysvinit
fixed. Not tested -- I have no way of testing taht change anyways; it's non-xenial specific. I gather CI should pick it up? |
Yep, CI tests look good. Thanks! |
- ansible service/systemd module fails to enable some services - ansible/ansible-modules-core#3764 - geerlingguy/ansible-role-varnish#65 From usableprivacy/upribox@7836e5a
- ansible service/systemd module fails to enable some services - ansible/ansible-modules-core#3764 - geerlingguy/ansible-role-varnish#65
Currently, there appears to be an issue with Ansible in which, if a
service is already enabled with sysvinit, the service will not be
enabled with Ansible. This appears to be the condition with this
repository; likely, the upstream package is bringing in the sysvinit
script (as it's not being deployed by ansible) and enabling it.
This commit implements a workaround as documented
ansible/ansible-modules-core#3764 (comment).
While, confusingly, the package is "using" the sysvinit style service
tool for enabling the service, systemd implements a compatibility layer
that allows enabling it via this shim. This correctly enables the
service.
See ansible/ansible#22303
See geerlingguy/ansible-role-php@84ab337