"HTTP 405 - Method Not Allowed" when attempting vROPs Telegraf install with SaltStack

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:

1
2
3
4
5
6
7
8
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:

1
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:

1
2
3
4
#!/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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
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.

comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy