From ad25d29c69827b41c04d3ea6aea496afdce4e031 Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Mon, 14 Mar 2022 17:34:42 +0000 Subject: [PATCH] Add useful commands for landscape api --- useful_landscape_commands.md | 46 +++++++++++++++++++ ...ts_storage_relation_departed_workaround.md | 2 +- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 useful_landscape_commands.md diff --git a/useful_landscape_commands.md b/useful_landscape_commands.md new file mode 100644 index 0000000..2947438 --- /dev/null +++ b/useful_landscape_commands.md @@ -0,0 +1,46 @@ +# Useful Landscape Commands + +Useful links + +* [Landscape API package](https://landscape.canonical.com/static/doc/api/api-client-package.html) +* [Landscape user Guide](https://landscape.canonical.com/static/doc/user-guide/) +* [Landscape API Guide](https://landscape.canonical.com/static/doc/api/) + +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:apnc01appf001-1" OR "title:apnc01appf002-2" OR "title:apnc01appf003-3" appformix +``` + +Searching something with regex, and then adding the correspongding tag + +```bash +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 +``` + diff --git a/vault_secrets_storage_relation_departed_workaround.md b/vault_secrets_storage_relation_departed_workaround.md index 035a9eb..5875e30 100644 --- a/vault_secrets_storage_relation_departed_workaround.md +++ b/vault_secrets_storage_relation_departed_workaround.md @@ -29,7 +29,7 @@ e.g.: - juju run --unit vault/2 -- 'relation-set -r 311 ceph-osd/4_token='"s.bk3GMbPxKwgGXyODysVjihuA"' + juju run --unit vault/2 -- relation-set -r 311 ceph-osd/4_token='"s.bk3GMbPxKwgGXyODysVjihuA"' Pay attention to the escape characters and dots, etc.