robertdebock / ansible-role-rsyslog

Install and configure rsyslog on your system.
https://robertdebock.nl/
Apache License 2.0
36 stars 40 forks source link

add rsyslog_enable var #9

Closed benformosa closed 6 months ago

benformosa commented 3 years ago

name: add rsyslog_enable var about: Add a variable to completely disable the role


Describe the change Hi Robert, as usual, thanks so much for your fantastic roles. I've added a variable to completely disable the role.

This role works for about 90% of my systems, however I'm not able to use it for some. I'm using this in Red Hat Satellite (Foreman), in which roles are assigned to groups of hosts, but can't be removed from sub-groups. The intention is to have a method to easily disable this role with a variable, rather than creating a duplicate group without the role.

Not sure how this fits with your plans for this role, however I've seen similar mechanisms in other roles I use, e.g. ssh_enable in willshersystems.sshd.

Testing I've run the standard Molecule tests.

robertdebock commented 3 years ago

Okay, I've never encountered this issue. Typically the playbook can be changed using a pattern that includes or excludes a host or group. Something like this:

- name: make this server great again
  hosts: all:!some_group

  roles:
    - role: robertdebock.rsyslog

Come to think of it; there is no (easy) way to "undo" a role.

Can you explain a little more about grouping in Satellite/Foreman? I understand you can make groups, but can't remove groups. (?)

benformosa commented 3 years ago

That's fair enough, the way that Ansible is used within Satellite is a little different.

Rather than me specifying a playbook, Foreman generates one using includes for each role assigned to the host. Roles are assigned to the host in Satellite either directly or via a host group, which it uses instead of Ansible inventory groups. Host groups can have roles and variables assigned. I use a base group for all my hosts, to which I assign most roles and variables. I then create sub-groups for hosts which need non-standard configuration. I can override variables, but I can't override role assignments.

So if I want to configure rsyslog on all my hosts except one, I can either:

  1. Create a base group with the rsyslog role, then create a subgroup which inherits the rsyslog role, but sets the variable to disable the role.
  2. Create a base group with the rsyslog role, then create a duplicate group without the rsyslog role, which I have to keep updated to match the original base group.

For some more detail:

robertdebock commented 6 months ago

Hi,

After (quite some time) consideration; no, I will not introduce a variable to disable a role. Your request may help in your specific use-case, but will not help me.

Thanks anyway for creating this issue, it was certainly worth understanding your use-case.