Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Michele Baldessari mbaldessari

🏠
Working from home
View GitHub Profile
@mbaldessari
mbaldessari / sound-toggle.sh
Created Jul 16, 2022
Toggle pipewire/pulseaudio output or input on/off
View sound-toggle.sh
#!/bin/bash
set -e
function error_out() {
echo "Error wrong arguments. Pick either input or output"
exit 1
}
if [ $# -ne 1 ]; then
error_out
@mbaldessari
mbaldessari / acm-import-cluster.yml
Created Feb 10, 2022
Playbook to import remote cluster in ACM
View acm-import-cluster.yml
---
# We require the kubernetes collection. Install it first via:
# ansible-galaxy collection install community.kubernetes
#
# This expects four environment variables to be set:
# KUBECONFIG -> Pointing to the HUB
# REMOTEAPI -> API endpoint of the remote cluster
# REMOTECLUSTERNAME -> Name of the cluster you want to import
# REMOTETOKEN -> Token of the remote cluster
- name: Playbook to import a cluster
View ovn-commands.txt
export SBDB=$(sudo ovs-vsctl get open . external_ids:ovn-remote | sed -e 's/\"//g') ; export NBDB=$(sudo ovs-vsctl get open . external_ids:ovn-remote
| sed -e 's/\"//g' | sed -e 's/6642/6641/g') ; alias ovn-sbctl='sudo podman exec ovn_controller ovn-sbctl --db=$SBDB' ; alias ovn-nbctl='sudo podman
exec ovn_controller ovn-nbctl --db=$NBDB' ; alias ovn-trace='sudo podman exec ovn_controller ovn-trace --db=$SBDB'
ovn-sbctl list chassis
ovs-vsctl get open . external_ids:ovn-bridge-mappings
ovn-nbctl --db="ssl:172.17.1.122:6641" -p /etc/pki/tls/private/ovn_controller.key -c /etc/pki/tls/certs/ovn_controller.crt -C /etc/ipa/ca.crt show
View standalone-cleanup.sh
#!/bin/bash
set -x
source /etc/os-release
sudo systemctl stop tripleo_\*
sudo systemctl stop ceph\*
sudo pcs cluster destroy
if [ $VERSION_ID == "7" ]; then
sudo docker ps -a -q | xargs docker rm -f
else
View ospgrep.sh
ospgrep() {
echo "$*"
grep -E "\s\b(E[rR]{2}:?|alert|Traceback|TRACE|crit|fatal|HANDLER|TASK|PLAY|Unexpected|FAIL|[Ff]ail|denied|non-zero|[Tt]ime[d\s]?out|UNCAUGHT|EXCEPTION|Unknown|[Aa]ssertion|inuse)" $*
}
View facter-cleanup.sh
rm /opt/puppetlabs/facter/cache/ -rf
rm -fr /var/lib/container-puppet/puppetlabs/
mkdir /var/lib/container-puppet/puppetlabs/
cat > /var/lib/container-puppet/puppetlabs/facter.conf <<EOF
facts : {
ttls: [
{ "kernel" : 98 hour },
{ "memory" : 98 hour },
{ "networking" : 98 hour },
{ "operating system" : 98 hour },
View sos-collect.sh
#!/bin/bash
set -e
cd /home/stack
source ./stackrc
if [ ! -f inv.yml ]; then
tripleo-ansible-inventory --static-yaml-inventory inv.yml
fi
cat > /tmp/sosreport.yml <<EOF
@mbaldessari
mbaldessari / sos-collect.sh
Created Oct 1, 2020
sosreport collection in parallel
View sos-collect.sh
#!/bin/bash
set -ex
mkdir sosreports || /bin/true
declare -A pids
nodes=$(openstack --os-cloud undercloud server list -f value -c Networks |cut -f2 -d\=)
for i in $nodes; do
echo "Collecting for $i"
ssh $i 'sudo sosreport --quiet --batch; sudo chmod 644 /var/tmp/sos*xz' &
pids["$i"]="$!"
@mbaldessari
mbaldessari / gist:d356ef76d68ff8636a3d73b1cd968269
Last active Mar 17, 2020
Clean freeipa from spurious hosts
View gist:d356ef76d68ff8636a3d73b1cd968269
# To delete all hosts that are not freeipa and undercloud
# Go to freeipa-0 and open /tmp/freeipa-setup.env
# look for AdminPassword
kinit admin
# Type in AdminPassword
D='redhat.local'
for i in $(ipa host-find |grep 'Host name:' | awk '{ print $3 }' | grep -v -e freeipa-0 -e undercloud-0 -e "ctlplane.$D" -e "$D" -e "internalapi.$D" -e "storage.$D" -e "storagemgmt.$D"); do ipa host-del "$i"; done
@mbaldessari
mbaldessari / disable-haproxy-backends.sh
Created Sep 18, 2019
Disables other controller haproxy backends on osp ctlplane
View disable-haproxy-backends.sh
#!/bin/bash
set -e
# Before running this script it would be best to disable haproxy on the other nodes
# via: for i in controller-1 controller-2; do pcs resource ban haproxy-bundle $i; done
# To clear the bans: for i in controller-1 controller-2; do pcs resource clear haproxy-bundle $i; done
# Run this script as root on the single controller you want to stay active
CONF="/var/lib/config-data/puppet-generated/haproxy/etc/haproxy/haproxy.cfg"
HOST=$(hostname)
# Enable admin access to the haproxy stat socket