geerlingguy / ansible-role-clamav

Ansible Role - ClamAV.
https://galaxy.ansible.com/geerlingguy/clamav/
MIT License
60 stars 51 forks source link

Allow custom configuration of freshclam #11

Closed ollie1 closed 4 years ago

ollie1 commented 4 years ago

I'm using this role in my playbooks and it's working nicely on CentOS 7. However, in my environment I need to set an HttpProxy in /etc/freshclam.conf. Would it be possible to add an extension point to allow this file to be configured in the same way that we can configure the clamav daemon?

Currently I have to do something like the following to get this to work, but it's pretty ugly

    - name: populate service facts
      service_facts:
    - name: Use clamav role to do most of setup
      include_role:
        name: geerlingguy.clamav
      vars:
        # Don't change the state of the clamav_daemon - this is done in a later task once freshclam has been configured and run
        clamav_daemon_state: "{{ 'started' if (ansible_facts.services['clamd@scan.service'] is defined) and (ansible_facts.services['clamd@scan.service'].state == 'running') else 'stopped' }}"
    - name: Configure proxy for freshclam
      lineinfile:
        path: /etc/freshclam.conf
        regex: "{{ item.regex }}"
        line: "{{ item.line }}"
      with_items:
        - { regex: '^#?Example', line: '#Example'}
        - { regex: '^#?HTTPProxyServer', line: 'HTTPProxyServer {{ http_proxy_host }}'}
        - { regex: '^#?HTTPProxyPort', line: 'HTTPProxyPort {{ http_proxy_port }}'}
      register: freshclam_config
    - name: Run freshclam after changing freshclam config.
      command: freshclam
      when: freshclam_config.changed
      notify: restart clamav daemon
    - name: Ensure clamav daemon is running
      service:
        name: clamd@scan
        state: started
stale[bot] commented 4 years ago

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.

stale[bot] commented 4 years ago

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.