I am looking to update multiple similar config files and am looking for the 
best path. 

Updating individual files I have down pat with lineinfile and with_items. 
The trick this time is that I have a directory that contains multiple files 
in which I want to make the same update. My original idea was to make a 
role that made the multiple updates to an individual file using with_items. 
I was then thinking of trying to use with_items on the role. Unfortunately 
it looks like I can't use with_items on a call to a role.

If I have to I can just call the role multiple times with a variable name 
with the file name as a parameter. Is that my best bet or did I miss 
something ?

# update config file
    - { role: update-config-file 
      with_items:
          - { tool-file-name: 'file1'   }
          - { tool-file-name: 'file2'   }
          - { tool-file-name: 'file3'   }
          }
#          





Role - update-config-file
updates multiple lines in a config file

- name: lineinfile updates to  /etc/toolname/{{ tool-file-name.conf }}
  lineinfile: dest=/etc/toolname/{{ tool-file-name.conf }}
    regexp='{{ item.regex }}'
    line='{{ item.dataline }}'
    backup=yes
  with_items:
      - { regex: "^TESTING ", 
         dataline: 'TESTING = "0"'  }
      - { regex: '^TESTING_INTERVAL', 
         dataline: 'TESTING_INTERVAL = "20" '  }
      - { regex: '^TCP_IN', 
         dataline: 'TCP_IN = "22,80" '  }



-- 
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/fed8c057-23c2-41f1-84f2-0e7458414ebb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to