Hi everyone

Sorry if this comes across as a bit of a silly questions but this has been 
my first real ansible issue that I couldn't resolve.

What I currently do is to declare a special *LogFormat* for apache. This 
spits out nice friendly json formatting for my vhosts and logstash to slurp.

The file I want to template looks a little like this (end result)
(variables in bold)

[root@webserver1 httpd]# cat /etc/httpd/conf.d/10-logstash.conf
LogFormat "{ \
\"host\":\"*webserver1*\", \
\"path\":\"/var/log/httpd/logstash_access_log\", \
\"tags\":[\"*cluster2*\"], \
\"message\": \"%h %l %u %t \\\"%r\\\" %>s %b\", \
\"timestamp\": \"%{%Y-%m-%dT%H:%M:%S%z}t\", \
\"useragent\": \"%{User-agent}i\", \
\"clientip\": \"%a\", \
\"duration\": %D, \
\"status\": %>s, \
\"request\": \"%U%q\", \
\"urlpath\": \"%U\", \
\"urlquery\": \"%q\", \
\"method\": \"%m\", \
\"bytes\": %B, \
\"vhost\": \"%v\" \
}" logstash_apache_json


If you're interested in ELK I then just have this declared withing a 
<Virtualhost>:
CustomLog "/var/log/httpd/logstash_access.log" logstash_apache_json




So I've changed the above to {{ ansible_hostname }} and a var I declare as 
normal but I can't seem to write the file with the template module:


TASK: [template /etc/httpd/conf.d/10-logstash.conf] 
*************************** 
fatal: [10.1.2.75] => {'msg': "AnsibleError: file: 
/home/starkd/uk-cluster2-httpdconfigs/templates/etc/httpd/conf.d/10-logstash.conf.j2,
 
line number: 6, error: Encountered unknown tag 'Y'.", 'failed': True}
fatal: [10.1.2.75] => {'msg': "AnsibleError: file: 
/home/starkd/uk-cluster2-httpdconfigs/templates/etc/httpd/conf.d/10-logstash.conf.j2,
 
line number: 6, error: Encountered unknown tag 'Y'.", 'failed': True}

FATAL: all hosts have already failed -- aborting




(the task is very simple:)
  - name: template /etc/httpd/conf/httpd.conf
    template: >
      src=templates/etc/httpd/conf/httpd.conf.j2
      dest=/etc/httpd/conf/httpd.conf
      owner=root
      group=root
      mode=0644
    notify: restart httpd



So I know I can copy the file and maybe use lineinfile to update these (or 
maybe a script)

I just can't figure out a way of doing this "properly"

Any advice welcome!
Many thanks

-David

-- 
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/68979528-0013-4f42-bf69-8d662663ce7b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to