main.yml 1.6 KB

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