I'm trying to write some ansible modules for configuring PVE via pvesh. It's important for ansible to know whether an operation has made a change or not versus an error happening. My plan was to use a pvesh get command to determine if something exists already. In some cases, it seems pvesh exits 2 if the item doesn't exist. In others, though, it exits 255. Unfortunately it also exits 255 if the api path supplied is wrong. In other cases, it exits 0! Are there some rules I'm missing for how the exit code is determined? Or is there a better way to know if something is already created before I create it?
Examples:
pvesh get /access/domains/inn; echo $?
domain 'inn' does not exist
2
pvesh get /access/groups/inn; echo $?
group 'inn' does not exist
255
pvesh get /nodes/asdf/apt/versions; echo $?
hostname lookup 'asdf' failed - failed to get address info for: asdf: Name or service not known
255
pvesh get /nodes/asdf/apt; echo $?
┌──────────────┐
│ id │
╞══════════════╡
│ changelog │
├──────────────┤
│ repositories │
├──────────────┤
│ update │
├──────────────┤
│ versions │
└──────────────┘
0
Examples:
pvesh get /access/domains/inn; echo $?
domain 'inn' does not exist
2
pvesh get /access/groups/inn; echo $?
group 'inn' does not exist
255
pvesh get /nodes/asdf/apt/versions; echo $?
hostname lookup 'asdf' failed - failed to get address info for: asdf: Name or service not known
255
pvesh get /nodes/asdf/apt; echo $?
┌──────────────┐
│ id │
╞══════════════╡
│ changelog │
├──────────────┤
│ repositories │
├──────────────┤
│ update │
├──────────────┤
│ versions │
└──────────────┘
0