This is a quick guide to mounting a qcow2 disk images on your host server. This is useful to reset passwords, edit files, or recover something without the virtual machine running.
Step 1 - Enable NBD on the Host
modprobe nbd max_part=8
| # -*- coding: utf-8 -*- | |
| # Author: Douglas Creager <[email protected]> | |
| # This file is placed into the public domain. | |
| # Calculates the current version number. If possible, this is the | |
| # output of “git describe”, modified to conform to the versioning | |
| # scheme that setuptools uses. If “git describe” returns an error | |
| # (most likely because we're in an unpacked copy of a release tarball, | |
| # rather than in a git working copy), then we fall back on reading the | |
| # contents of the RELEASE-VERSION file. |
| ## Install necessary packages | |
| $ sudo apt-get install virtualbox-ose qemu-utils genisoimage cloud-utils | |
| ## get kvm unloaded so virtualbox can load | |
| $ sudo modprobe -r kvm_amd kvm_intel | |
| $ sudo service virtualbox stop | |
| $ sudo service virtualbox start | |
| ## URL to most recent cloud image of 12.04 | |
| $ img_url="http://cloud-images.ubuntu.com/server/releases/12.04/release" |
| # NOTE: These patterns take into account the additional log-line information passed to the logstash listener from rsyslog. YMMV. | |
| DHCPD ((%{SYSLOGTIMESTAMP:timestamp})\s*(%{HOSTNAME:hostname})\s*dhcpd\S+\s*(%{WORD:dhcp_action})?.*[for|on] (%{IPV4:dhcp_client_ip})?.*[from|to] (%{COMMONMAC:dhcp_client_mac})?.*via (%{USERNAME:interface})) | |
| IPTABLES ((%{SYSLOGTIMESTAMP:nf_timestamp})\s*(%{HOSTNAME:nf_host})\s*kernel\S+\s*(%{WORD:nf_action})?.*IN=(%{USERNAME:nf_in_interface})?.*OUT=(%{USERNAME:nf_out_interface})?.*MAC=(%{COMMONMAC:nf_dst_mac}):(%{COMMONMAC:nf_src_mac})?.*SRC=(%{IPV4:nf_src_ip}).*DST=(%{IPV4:nf_dst_ip}).*PROTO=(%{WORD:nf_protocol}).?*SPT=(%{INT:nf_src_port}?.*DPT=%{INT:nf_dst_port}?.*)) | |
| DNS ((%{MONTHDAY:day})-(%{MONTH:month})-(%{YEAR:year}) (%{TIME:timestamp}) client (%{IPV4:dns_client_ip})#(%{NONNEGINT:dns_uuid})?.*query: (%{HOSTNAME:dns_dest}) (%{WORD:dns_type}) (%{WORD:dns_record})?.*(%{IPV4:dns_server})) | |
| PGSQL ((%{SYSLOGTIMESTAMP:pgsql_timestamp}) (%{HOSTNAME:pgsql_hostname})?.*SAST >(%{WORD:pgs |
| #!/usr/bin/env bash | |
| declare -A vm_ip | |
| declare -A vm_id | |
| declare -A vm_status | |
| while read -r _ id _ name _ ip _ ; do | |
| ip=$(echo $ip|cut -d'=' -f2) | |
| vm_ip[$name]=$ip | |
| vm_id[$name]=$id |
| #!/bin/bash | |
| sudo apt-get install -qqy ethtool libgraph-easy-perl graphviz > /dev/null | |
| EXCEPT=/tmp/exceptlist | |
| echo '' > $EXCEPT | |
| result="" | |
| function on_exit() { | |
| rm -f $EXCEPT |
| # Script to create admin and administrator user | |
| #!/bin/bash | |
| IPs=`echo 86.50.1.{150..168}` | |
| for ip in $IPs | |
| do | |
| echo Starting $ip | |
| sshpass -p 'ROOTPWD' ssh -o StrictHostKeyChecking=no -l root $ip "create /map1/accounts1 username=Administrator password=ADMINISTRATORPWD name=Administrator group=admin,config,oemhp_rc,oemhp_power,oemhp_vm" | |
| sshpass -p 'ROOTPWD' ssh -o StrictHostKeyChecking=no -l root $ip "create /map1/accounts1 username=admin password=ADMINPASSWORD name=admin group=admin,config,oemhp_rc,oemhp_power,oemhp_vm" |
| # NOTE | |
| # | |
| # Eduroam settings are organization-specific. | |
| # | |
| # If something works with *@foobar.edu, that _does_not_mean_ the same | |
| # settings automatically work elsewhere. | |
| # | |
| # Fortunately, *most* sites use very similar settings – password logins via | |
| # PEAP or TTLS. That's what this example covers. | |
| # |
| # Add this snippet to the top of your playbook. | |
| # It will install python2 if missing (but checks first so no expensive repeated apt updates) | |
| # [email protected] | |
| - hosts: all | |
| gather_facts: False | |
| tasks: | |
| - name: install python 2 | |
| raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal) |
| #!/bin/bash | |
| # Copyright 2016, Rackspace US, Inc. | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software |