From d63c8ac105f1c7a600b8042fe52f310cd8cff42e Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Tue, 15 Mar 2022 17:52:30 +0000 Subject: [PATCH] script to add az as tags automatically from juju status --- useful_landscape_commands.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/useful_landscape_commands.md b/useful_landscape_commands.md index 33d5533..c53bdea 100644 --- a/useful_landscape_commands.md +++ b/useful_landscape_commands.md @@ -44,3 +44,23 @@ do done ``` +If you're using juju, then you might find the following more useful to add tags per AZ + +```bash +#!/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 +``` +