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 p@ssw0rd
- 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
Downloading the 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 p@ssw0rd
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
Notice the 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.
- Restore of a Wordpress deployment is stuck redirecting the port
- Backups and Restores using Velero in TKGm 1.6.1
- Unable to upgrade the database: org.postgresql.util.PSQLException: ERROR: could not open shared memory segment: No such file or directory
- Upgrading Cloud Director 10.4.1 to 10.5
- Installing and Configuring Velero in TKGm 1.6.1 on vSphere