Excerpts from Bryan Larsen's message of 2014-04-02 08:42:55 -0400:
> The problem with this is that Redis often rewrites its configuration files; 
> for example when a new master is elected.

I haven't actually used Ansible to set up Redis, but I have run into
software that does this, and I would note three things:

1. Ugh tell upstream to not do this.  They probably won't listen but
   it's just a terrible thing, in my opinion.

2. The lineinfile module can be made to do some terrifying things, and
   you might finds it useful: if you're a bit clever with your regexes
   and backrefs, you can make almost any change you can perform with it
   idempotent.  As an example, this horrifying snippet I use to
   configure ntp.conf:

       - name: Comment out default timeservers.
         lineinfile:
           state: present
           dest: /etc/ntp.conf
           backrefs: yes
           regexp: '^(server (?!{{ ntp_server }}).*)'
           line: '#\\1'
         register: result
         until: not result|changed
         retries: 5
         delay: 1
         notify:
           - restart ntpd

       - name: Set timeserver.
         lineinfile:
           state: present
           dest: /etc/ntp.conf
           insertafter: '^#server .*'
           regexp: '^server .*'
           line: 'server {{ ntp_server }}'
         notify:
           - restart ntpd

   This will comment out any 'server directive beside the one I want, and
   then insert my desired one.

3. Perhaps write some custom facts that get the current state of the
   Redis configuration and incorporate them into the template?  You
   might also find Redis' CONFIG GET/SET/REWRITE commands useful.
--
Morgan Hamill

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1396445081-sup-3584%40al.wesleyan.edu.
For more options, visit https://groups.google.com/d/optout.

Reply via email to