]> git.apps.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
tools: Add a couple workstation scripts 686/head
authorDavid Galloway <dgallowa@redhat.com>
Tue, 28 Jun 2022 14:31:33 +0000 (10:31 -0400)
committerDavid Galloway <dgallowa@redhat.com>
Tue, 28 Jun 2022 14:31:33 +0000 (10:31 -0400)
Signed-off-by: David Galloway <dgallowa@redhat.com>
tools/set-next-server-local.sh [new file with mode: 0644]
tools/switch-secrets.sh [new file with mode: 0644]

diff --git a/tools/set-next-server-local.sh b/tools/set-next-server-local.sh
new file mode 100644 (file)
index 0000000..e9834e2
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/bash
+# Modifies dhcp config file to add or remove a next-server and filename
+# The fog next-server and filename are the default for all DHCP hosts so
+# entering 'cobbler' for $2 adds its next-server and filename.
+# Setting 'fog' for $2 just removes it so the host entry uses the global default.
+#
+# This script should live on your workstation somewhere executable.
+#
+# It also assumes you are using tools/switch-secrets to switch between
+# octo an sepia ansible inventories
+
+if [ $# -ne 2 ]; then
+  echo "Usage: $(basename $0) hostname [cobbler|fog]"
+  echo
+  echo "Example: \`$(basename $0) mira042 cobbler\` would add Cobbler's next-server and filename to mira042's DHCP entry"
+  echo
+  exit 1
+elif [ "$2" != "cobbler" ] && [ "$2" != "fog" ]; then
+  echo "Unrecognized option $2.  Must use 'cobbler' or 'fog'"
+  exit 1
+else
+  host=$(echo $1 | cut -d '.' -f1)
+fi
+ls -lah /etc/ansible/hosts | grep -q octo
+if [ $? -eq 0 ]
+then
+  dhcp_server="magna001.ceph.redhat.com"
+else
+  dhcp_server="store01.front.sepia.ceph.com"
+fi
+
+set -x
+
+ssh $dhcp_server "sudo /usr/local/sbin/set-next-server.sh $host $2 && sudo service dhcpd restart"
diff --git a/tools/switch-secrets.sh b/tools/switch-secrets.sh
new file mode 100644 (file)
index 0000000..c0c0e54
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/bash
+# Switches your ansible inventory between ceph-sepia-secrets or ceph-octo-secrets
+
+val=$(ls -lah /etc/ansible/secrets | grep -c "octo")
+if [ $val -eq 1 ]; then
+        sudo rm /etc/ansible/secrets
+        sudo ln -s ~/git/ceph/ceph-sepia-secrets/ansible/secrets /etc/ansible/secrets
+        sudo rm /etc/ansible/hosts
+        sudo ln -s ~/git/ceph/ceph-sepia-secrets/ansible/inventory /etc/ansible/hosts
+        cat ~/.teuthology.yaml.sepia > ~/.teuthology.yaml
+elif [ $val -eq 0 ]; then
+        sudo rm /etc/ansible/secrets
+        sudo ln -s ~/git/ceph/ceph-octo-secrets/ansible/secrets /etc/ansible/secrets
+        sudo rm /etc/ansible/hosts
+        sudo ln -s ~/git/ceph/ceph-octo-secrets/ansible/inventory /etc/ansible/hosts
+        cat ~/.teuthology.yaml.octo > ~/.teuthology.yaml
+fi