geerlingguy / ansible-role-nginx

Ansible Role - Nginx

Home Page:https://galaxy.ansible.com/geerlingguy/nginx/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request] Ability to not manage the nginx service

Zorlin opened this issue · comments

Hi Jeff!

I'm using the role in a project right now (thank you!) and it's working great. I need to stop it from managing the nginx service, though. In my case setting nginx_service_state: stopped is actually enough, which is cool - but - I'd love to instead have something like nginx_service_state: unmanaged.

Unfortunately, Ansible doesn't support a state=unmanaged parameter, which in a lot of ways makes sense (there are much better ways to not trigger a task!)

Two naive ways I can think of to do this, modifying the task in tasks/main.yml:

First, without having to create a new variable:

- name: Ensure nginx service is running as configured.
  service:
    name: nginx
    state: "{{ nginx_service_state }}"
    enabled: "{{ nginx_service_enabled }}"
  when: nginx_service_state != "unmanaged"

And then, something slightly less ugly:

- name: Ensure nginx service is running as configured.
  service:
    name: nginx
    state: "{{ nginx_service_state }}"
    enabled: "{{ nginx_service_enabled }}"
  when: not nginx_do_not_manage_service

May be out of scope for this role... not sure.

Let me know your thoughts :)

commented

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

commented

This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.