--- - hosts: all:!log_hosts gather_facts: no vars: graylog_forwarder_system_packages: - python3-systemd - python3-pip graylog_forwarder_pip_packages: - gelfclient==0.0.7 - journal2gelf==2.0.0 tasks: #- name: Gather variables for each operating system # include_vars: "{{ item }}" # with_first_found: # - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" # - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" # - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" # - "{{ ansible_distribution | lower }}.yml" # - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml" # - "{{ ansible_os_family | lower }}.yml" # tags: # - always - name: Install graylog forwarder package requirements package: name: "{{ graylog_forwarder_system_packages }}" state: present # Graylog wasn't build in repo, and requires running "isolated" - name: Install graylog forwarder requirements pip: name: "{{ graylog_forwarder_pip_packages }}" state: present - name: Install the log forwarder service. include_role: name: systemd_service with_items: "{{ graylog_targets }}" loop_control: loop_var: graylog_target vars: systemd_services: - service_name: gelf-forwarder state: started execstarts: - "/usr/local/bin/journal2gelf {{ graylog_target }}"