# install ua on both, systemd and non-systemd systems - name: install yandex-ua binary 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: remove package if present ansible.builtin.apt: pkg: yandex-unified-agent state: absent purge: true when: vendor.stdout == 'Debian' or vendor.stdout == 'Ubuntu' - name: install yandex-ua ansible.builtin.script: cmd: scripts/yandexua-install.bash chdir: /root register: script_output changed_when: >- "changed - all done" in script_output.stdout - name: display script stdout debug: var=script_output.stdout_lines when: script_output.stdout is defined - name: display script stderr debug: var=script_output.sterr_lines when: script_output.sterr is defined - name: deploy systemd unit file ansible.builtin.copy: src: templates/unified-agent.service dest: /etc/systemd/system/ diff: true notify: reload systemd when: vendor.stdout == 'Debian' or vendor.stdout == 'Ubuntu' - name: non-systemd restart script ansible.builtin.copy: src: templates/RESTART-UA dest: /etc/yandex/unified_agent/ mode: 0700 notify: restart yandexua diff: true when: vendor.stdout != 'Debian' and vendor.stdout != 'Ubuntu' handlers: - name: reload systemd ansible.builtin.shell: executable: /bin/bash cmd: systemctl daemon-reload