Created
March 4, 2016 22:32
-
-
Save rkhaja/f58ade17d54d7cec5276 to your computer and use it in GitHub Desktop.
Example of converting logback.xml from Cassandra configuration into a jinja template using Ansible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: Copy logback.xml file to templates directory to make Jinja2 template | |
copy: | |
src: "{{ cassandra_role_dir }}/files/apache-cassandra-{{ cassandra_version }}/conf/logback.xml" | |
dest: "{{ cassandra_role_dir }}/templates/apache-cassandra-{{ cassandra_version }}/conf/logback.xml.j2" | |
- name: Make Jinga2 template for logback.xml | |
lineinfile: | |
dest: "{{ cassandra_role_dir }}/templates/apache-cassandra-{{ cassandra_version }}/conf/logback.xml.j2" | |
regexp: "{{ item.regexp }}" | |
line: "{{ item.line }}" | |
with_items: | |
- [ { regexp: '<file>\${cassandra.logdir}/system.log</file>', | |
line: ' <file>__OPEN_BRACES__ path_to_cassandra_system_log __CLOSE_BRACES__</file>' }, | |
{ regexp: '<fileNamePattern>\${cassandra.logdir}/system.log.%i.zip</fileNamePattern>', | |
line: ' <fileNamePattern>__OPEN_BRACES__ path_to_cassandra_system_log __CLOSE_BRACES__.%i.zip</fileNamePattern>' }, | |
{ regexp: "<maxIndex>20</maxIndex>", | |
line: ' <maxIndex>__OPEN_BRACES__ max_index __CLOSE_BRACES__</maxIndex>' }, | |
] | |
- include: fix_braces_in_template_file.yml template_file="{{ cassandra_role_dir }}/templates/apache-cassandra-{{ cassandra_version }}/conf/logback.xml.j2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment