I was trying to install the vRealize Operations Telegraf agent on my VMs by following the documentation. I wrote the steps out in a Salt state file:
unzip: pkg.installed install-telegraf: cmd.script: - source: https://cloudproxy.domain.tld/downloads/salt/download.sh - name: /tmp/download.sh -o install -v vrops.domain.tld -u admin -p [email protected] - mode: '0777'
Salt takes the
source and puts it in the location under
name, executing it with the included arguments. However, everytime it ran I would get this:
Failed to get vROps Token. Error code: 400
download.sh script and running it interactively on the target machine also failed (using the default ubuntu account) and displayed the same error as above. Using
sudo to elevate and execute the script interactively was successful.
After a few dozen attempts tweaking the above, I eventually settled on wrapping the
download.sh script in another script delivered by SaltStack:
#!/bin/bash curl -k https://cloudproxy.domain.tld/downloads/salt/download.sh -o /tmp/download.sh chmod +x /tmp/download.sh sudo sh -c /tmp/download.sh -o install -v vrops.domain.tld -u admin -p [email protected]
The above script was stored in SaltStack under
/vrops/telegraf/install.sh and now I was able to use SaltStack to fetch this new script and perform the installation:
unzip: pkg.installed download-runner: file.managed: - source: salt://vrops/telegraf/install.sh - name: /tmp/install.sh - mode: '0777' install_vrops_agent: cmd.run: - name: /tmp/install.sh - retry: attempts: 5 until: True interval: 60
retry instruction for
install_vrops_agent. I found that on a fresh deployment out of vRA a VM wouldn’t necessarily be in vROPs at the time the
installer.sh script would run and would subsequently fail. Having the retry there allowed Salt to re-run the script until a suitable exit code was returned.