#!/bin/bash # breaks somewhere after ua_version #set -e # https://yandex.cloud/en/docs/monitoring/concepts/data-collection/unified-agent/installation [[ ! -x `which curl` ]] && echo error: curl executable not found && exit 1 [[ ! -x `which wget` ]] && echo error: wget executable not found && exit 1 # ansible.builtin.script: # chdir: /root # just in case one runs the script outside ansible cd /root/ # ok=1 changed=0 [[ -x /usr/local/bin/unified_agent ]] && \ echo ok - unified_agent binary is there - nothing to do && exit 0 # config is done in another play set # ok=1 changed=0 #[[ -f /etc/yandex/unified_agent/config.yml ]] && \ # echo ok - config.yml is there - nothing to do && exit 0 # xml listing https://storage.yandexcloud.net/yc-unified-agent/ ua_version=`curl -s https://storage.yandexcloud.net/yc-unified-agent/latest-version` mkdir -p /usr/local/bin/ cd /usr/local/bin/ echo -n install unified_agent version $ua_version binary ... #wget -q https://storage.yandexcloud.net/yc-unified-agent/$ua_version/unified_agent && echo done || exit 1 wget -q https://storage.yandexcloud.net/yc-unified-agent/releases/$ua_version/unified_agent && echo done || exit 1 chmod +x unified_agent cd - >/dev/null [[ -z `grep ^unified_agent /etc/group` ]] && groupadd -g 1515 unified_agent [[ -z `grep ^unified_agent /etc/passwd` ]] && useradd -g unified_agent -u 1515 --system -s /sbin/nologin -d /dev/null -M unified_agent mkdir -p /etc/yandex/unified_agent/ #echo -n check for existing /etc/rc.local ... #if [[ -f /etc/rc.local ]]; then # echo exists #else # echo missing # echo -n create rc.local ... # # warning \$ escape is in there # cat > /etc/rc.local </dev/null || true ln -s /etc/yandex/unified_agent/config.yml /root/config.yml 2>/dev/null || true # ok=1 changed=1 echo changed - all done