main.yml 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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: Creates directories
  14. file:
  15. path: "{{ item }}"
  16. state: directory
  17. group: 'td-agent'
  18. owner: 'td-agent'
  19. mode: 0755
  20. with_items: ['/etc/td-agent/config.d']
  21. - name: Add include to td-agent configuration
  22. lineinfile:
  23. dest: '/etc/td-agent/td-agent.conf'
  24. regexp: '^@include config.d'
  25. line: '@include config.d/*.conf'
  26. state: present
  27. - name: install Kubernetes fluentd configuration file
  28. template:
  29. src: kubernetes.conf.j2
  30. dest: /etc/td-agent/config.d/kubernetes.conf
  31. group: 'td-agent'
  32. owner: 'td-agent'
  33. mode: 0444
  34. - name: wait for etcd to start up
  35. wait_for: port=4001 delay=10
  36. when: embedded_etcd | bool
  37. - name: wait for etcd peer to start up
  38. wait_for: port=7001 delay=10
  39. when: embedded_etcd | bool
  40. - name: ensure td-agent is running
  41. service:
  42. name: 'td-agent'
  43. state: started
  44. enabled: yes