- name: setup yandexua gather_facts: no hosts: "{{target}}" become: "{{become}}" tasks: # w/o facts - name: check distro vendor ansible.builtin.shell: executable: /bin/bash cmd: "lsb_release -is 2>/dev/null || echo unknown" register: vendor changed_when: false check_mode: false - name: is installed ansible.builtin.shell: executable: /bin/bash cmd: "[[ -x `which unified_agent` ]]" changed_when: false check_mode: false - name: setup ansible.builtin.template: src: templates/config.yml.j2 dest: /etc/yandex/unified_agent/config.yml mode: 0600 owner: unified_agent group: unified_agent notify: restart yandexua diff: true # systemd - name: enable at startup / systemd ansible.builtin.service: name: unified-agent enabled: true when: vendor.stdout == 'Debian' or vendor.stdout == 'Ubuntu' # non-systemd #- name: enable at startup / non-systemd # ansible.builtin.blockinfile: # path: /etc/rc.local # block: "{{ lookup('file', 'templates/blockinfile_rc.local') }}" # prepend_newline: true # append_newline: true # diff: true - name: restart if not running ansible.builtin.shell: executable: /bin/bash cmd: "[[ -z `pgrep unified_agent` ]]" changed_when: false failed_when: false check_mode: false notify: restart yandexua handlers: - name: restart yandexua ansible.builtin.shell: executable: /bin/bash cmd: "[[ -n `systemctl list-unit-files | grep unified-agent` ]] && systemctl restart unified-agent || /etc/yandex/unified_agent/RESTART-UA"