install.yml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. ---
  2. - name: create prometheus system group
  3. group:
  4. name: prometheus
  5. system: true
  6. state: present
  7. - name: create prometheus system user
  8. user:
  9. name: prometheus
  10. system: true
  11. shell: "/usr/sbin/nologin"
  12. group: prometheus
  13. createhome: false
  14. home: "{{ prometheus_db_dir }}"
  15. - name: create prometheus data directory
  16. file:
  17. path: "{{ prometheus_db_dir }}"
  18. state: directory
  19. owner: prometheus
  20. group: prometheus
  21. mode: 0755
  22. - name: create prometheus configuration directories
  23. file:
  24. path: "{{ item }}"
  25. state: directory
  26. owner: root
  27. group: prometheus
  28. mode: 0770
  29. with_items:
  30. - "{{ prometheus_config_dir }}"
  31. - "{{ prometheus_config_dir }}/rules"
  32. - "{{ prometheus_config_dir }}/file_sd"
  33. - name: propagate official prometheus and promtool binaries
  34. copy:
  35. src: "/tmp/{{ prometheus_tarball }}/{{ item }}"
  36. dest: "{{ prometheus_binary_install_dir }}/{{ item }}"
  37. mode: 0755
  38. owner: root
  39. group: root
  40. remote_src: true
  41. with_items:
  42. - prometheus
  43. - promtool
  44. notify:
  45. - restart prometheus
  46. - name: propagate official console templates
  47. copy:
  48. src: "/tmp/{{ prometheus_tarball }}/{{ item }}/"
  49. dest: "{{ prometheus_config_dir }}/{{ item }}"
  50. mode: 0644
  51. owner: root
  52. group: root
  53. remote_src: true
  54. with_items:
  55. - console_libraries
  56. - consoles
  57. notify:
  58. - restart prometheus
  59. #- name: propagate locally distributed prometheus and promtool binaries
  60. # copy:
  61. # src: "{{ prometheus_binary_local_dir }}/{{ item }}"
  62. # dest: "{{ prometheus_binary_install_dir }}/{{ item }}"
  63. # mode: 0755
  64. # owner: root
  65. # group: root
  66. # remote_src: true
  67. # with_items:
  68. # - prometheus
  69. # - promtool
  70. # notify:
  71. # - restart prometheus
  72. - name: create systemd service unit
  73. template:
  74. src: prometheus.service.j2
  75. dest: /etc/systemd/system/prometheus.service
  76. owner: root
  77. group: root
  78. mode: 0644
  79. notify:
  80. - restart prometheus
  81. - name: Allow prometheus to bind to port in SELinux
  82. seport:
  83. ports: "{{ prometheus_web_listen_address.split(':')[1] }}"
  84. proto: tcp
  85. setype: http_port_t
  86. state: present
  87. when:
  88. - (ansible_os_family == "RedHat")
  89. - (ansible_selinux.status == "enabled")