main.yml 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. ---
  2. # TODO: Update fluentd install and configuration when packaging is complete
  3. - name: download and install td-agent
  4. action: "{{ ansible_pkg_mgr }} name='http://packages.treasuredata.com/2/redhat/7/x86_64/td-agent-2.2.0-0.x86_64.rpm' state=present"
  5. - name: Verify fluentd plugin installed
  6. command: '/opt/td-agent/embedded/bin/gem query -i fluent-plugin-kubernetes'
  7. register: _fluent_plugin_check
  8. failed_when: false
  9. changed_when: false
  10. - name: install Kubernetes fluentd plugin
  11. command: '/opt/td-agent/embedded/bin/gem install fluent-plugin-kubernetes'
  12. when: _fluent_plugin_check.rc == 1
  13. - name: Override td-agent configuration file
  14. template:
  15. src: td-agent.j2
  16. dest: /etc/sysconfig/td-agent
  17. group: 'td-agent'
  18. owner: 'td-agent'
  19. mode: 0444
  20. - name: Creates directories
  21. file:
  22. path: "{{ item }}"
  23. state: directory
  24. group: 'td-agent'
  25. owner: 'td-agent'
  26. mode: 0755
  27. with_items: ['/etc/td-agent/config.d', '/var/log/td-agent/tmp']
  28. - name: Add include to td-agent configuration
  29. lineinfile:
  30. dest: '/etc/td-agent/td-agent.conf'
  31. regexp: '^@include config.d'
  32. line: '@include config.d/*.conf'
  33. state: present
  34. - name: install Kubernetes fluentd configuration file
  35. template:
  36. src: kubernetes.conf.j2
  37. dest: /etc/td-agent/config.d/kubernetes.conf
  38. group: 'td-agent'
  39. owner: 'td-agent'
  40. mode: 0444
  41. - name: ensure td-agent is running
  42. service:
  43. name: 'td-agent'
  44. state: started
  45. enabled: yes