public_docs/useful_landscape_commands.md

1.8 KiB

Useful Landscape Commands

Useful links

Retreiving the CA file for self-signed

juju run --application landscape-haproxy 'sudo openssl x509 -in /var/lib/haproxy/default.pem' > landscape_cert.crt

Landscape RC file, after generating API and SECRET key from the UI

export LANDSCAPE_API_KEY="EF414M7SAO1RP7ZNPA9A"
export LANDSCAPE_API_SECRET="vFAojXSy9IiUj1T/Q4ggYDcIn4LIpcWyQsq7uSKk"
export LANDSCAPE_API_URI="https://10.0.1.126/api/"
export LANDSCAPE_API_SSL_CA_FILE="$PWD/landscape_cert.crt"

Adding tags to machines

The following command will tag all machines that have as1-maas-node- in the name with asrock01

landscape-api add-tags-to-computers "as1-maas-node-" "asrock01"

Choosing specific hosts and tagging them

landscape-api add-tags-to-computers "title:as1-maas-node-01" OR "title:as1-maas-node-02" OR "title:as1-maas-node-03" asrock01

Searching something with regex, and then adding the correspongding tag

for c in $(landscape-api get-computers --json | jq -r ".[] | select(.title |test(\"^as1\")) |.title")
do
    landscape-api add-tags-to-computers hostname:${c} asrock01
done

If you're using juju, then you might find the following more useful to add tags per AZ

#!/bin/bash

. landscape_rc

juju_machines=$(mktemp)

juju machines > ${juju_machines}

for az in $(cat ${juju_machines} | awk '{print $6}' | tail +2 | sort | uniq)
do
  for host in $(cat ${juju_machines} | grep ${az} | awk '{print $4}')
  do
    landscape-api add-tags-to-computers title:${host} "${az}"
  done
done