Configure disks for hp cloud instances
Nodepool sometimes provides an hp cloud instance that has the majority of space in /dev/vdb which is mounted at /mnt. This patch repurposes that partition as an lvm VG for containers. Also: * creates an LV for /opt and mounts that. * outputs some instance info that may be useful for debugging Closes-Bug: #1407647 Change-Id: I91a6ab3994be348b17caaf9c9200d84463076d87
This commit is contained in:
@@ -12,51 +12,50 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
|
## Shell Opts ----------------------------------------------------------------
|
||||||
set -e -u -v -x
|
set -e -u -v -x
|
||||||
|
|
||||||
|
## Vars
|
||||||
FROZEN_REPO_URL=${FROZEN_REPO_URL:-"http://mirror.rackspace.com/rackspaceprivatecloud"}
|
FROZEN_REPO_URL=${FROZEN_REPO_URL:-"http://mirror.rackspace.com/rackspaceprivatecloud"}
|
||||||
MAX_RETRIES=${MAX_RETRIES:-5}
|
MAX_RETRIES=${MAX_RETRIES:-5}
|
||||||
ADMIN_PASSWORD=${ADMIN_PASSWORD:-"secrete"}
|
ADMIN_PASSWORD=${ADMIN_PASSWORD:-"secrete"}
|
||||||
DEPLOY_SWIFT=${DEPLOY_SWIFT:-"yes"}
|
DEPLOY_SWIFT=${DEPLOY_SWIFT:-"yes"}
|
||||||
|
|
||||||
# update the package cache and install required packages
|
## Functions -----------------------------------------------------------------
|
||||||
apt-get update
|
|
||||||
apt-get install -y python-dev \
|
|
||||||
python2.7 \
|
|
||||||
build-essential \
|
|
||||||
curl \
|
|
||||||
git-core \
|
|
||||||
ipython \
|
|
||||||
tmux \
|
|
||||||
vim \
|
|
||||||
vlan \
|
|
||||||
bridge-utils \
|
|
||||||
lvm2 \
|
|
||||||
xfsprogs \
|
|
||||||
linux-image-extra-$(uname -r)
|
|
||||||
|
|
||||||
# Flush all the iptables rules set by openstack-infra
|
# Get instance info
|
||||||
iptables -F
|
function get_instance_info(){
|
||||||
iptables -X
|
free -mt
|
||||||
iptables -t nat -F
|
df -h
|
||||||
iptables -t nat -X
|
mount
|
||||||
iptables -t mangle -F
|
lsblk
|
||||||
iptables -t mangle -X
|
fdisk -l /dev/xv* /dev/sd* /dev/vd*
|
||||||
iptables -P INPUT ACCEPT
|
uname -a
|
||||||
iptables -P FORWARD ACCEPT
|
pvs
|
||||||
iptables -P OUTPUT ACCEPT
|
vgs
|
||||||
|
lvs
|
||||||
|
which lscpu && lscpu
|
||||||
|
ip a
|
||||||
|
ip r
|
||||||
|
tracepath 8.8.8.8 -m 5
|
||||||
|
which xenstore-read && xenstore-read vm-data/provider_data/provider ||:
|
||||||
|
}
|
||||||
|
|
||||||
# Ensure newline at end of file (missing on Rackspace public cloud Trusty image)
|
function configure_hp_diskspace(){
|
||||||
if ! cat -E /etc/ssh/sshd_config | tail -1 | grep -q "\$$"; then
|
# hp instances arrive with a 470GB drive (vdb) mounted at /mnt
|
||||||
echo >> /etc/ssh/sshd_config
|
# this function repurposes that for the lxc vg then creates a
|
||||||
fi
|
# 50GB lv for /opt
|
||||||
|
mount |grep "/dev/vdb on /mnt" || return 0 # skip if not on hp
|
||||||
# Ensure that sshd permits root login, or ansible won't be able to connect
|
umount /mnt
|
||||||
if grep "^PermitRootLogin" /etc/ssh/sshd_config > /dev/null; then
|
pvcreate -ff -y /dev/vdb
|
||||||
sed -i 's/^PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
|
vgcreate lxc /dev/vdb
|
||||||
else
|
lvcreate -n opt -L50g lxc
|
||||||
echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config
|
mkfs.ext4 /dev/lxc/opt
|
||||||
fi
|
mount /dev/lxc/opt /opt
|
||||||
|
get_instance_info
|
||||||
|
}
|
||||||
|
|
||||||
function key_create(){
|
function key_create(){
|
||||||
ssh-keygen -t rsa -f /root/.ssh/id_rsa -N ''
|
ssh-keygen -t rsa -f /root/.ssh/id_rsa -N ''
|
||||||
@@ -96,6 +95,50 @@ function loopback_create() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
## Main ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
# update the package cache and install required packages
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y python-dev \
|
||||||
|
python2.7 \
|
||||||
|
build-essential \
|
||||||
|
curl \
|
||||||
|
git-core \
|
||||||
|
ipython \
|
||||||
|
tmux \
|
||||||
|
vim \
|
||||||
|
vlan \
|
||||||
|
bridge-utils \
|
||||||
|
lvm2 \
|
||||||
|
xfsprogs \
|
||||||
|
linux-image-extra-$(uname -r)
|
||||||
|
|
||||||
|
get_instance_info
|
||||||
|
|
||||||
|
# Flush all the iptables rules set by openstack-infra
|
||||||
|
iptables -F
|
||||||
|
iptables -X
|
||||||
|
iptables -t nat -F
|
||||||
|
iptables -t nat -X
|
||||||
|
iptables -t mangle -F
|
||||||
|
iptables -t mangle -X
|
||||||
|
iptables -P INPUT ACCEPT
|
||||||
|
iptables -P FORWARD ACCEPT
|
||||||
|
iptables -P OUTPUT ACCEPT
|
||||||
|
|
||||||
|
# Ensure newline at end of file (missing on Rackspace public cloud Trusty image)
|
||||||
|
if ! cat -E /etc/ssh/sshd_config | tail -1 | grep -q "\$$"; then
|
||||||
|
echo >> /etc/ssh/sshd_config
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure that sshd permits root login, or ansible won't be able to connect
|
||||||
|
if grep "^PermitRootLogin" /etc/ssh/sshd_config > /dev/null; then
|
||||||
|
sed -i 's/^PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
|
||||||
|
else
|
||||||
|
echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# ensure that the current kernel can support vxlan
|
# ensure that the current kernel can support vxlan
|
||||||
if ! modprobe vxlan; then
|
if ! modprobe vxlan; then
|
||||||
MINIMUM_KERNEL_VERSION=$(awk '/required_kernel/ {print $2}' rpc_deployment/inventory/group_vars/all.yml)
|
MINIMUM_KERNEL_VERSION=$(awk '/required_kernel/ {print $2}' rpc_deployment/inventory/group_vars/all.yml)
|
||||||
@@ -109,6 +152,8 @@ if [ ! -d "/opt" ];then
|
|||||||
mkdir /opt
|
mkdir /opt
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
configure_hp_diskspace
|
||||||
|
|
||||||
# create /etc/rc.local if it doesn't already exist
|
# create /etc/rc.local if it doesn't already exist
|
||||||
if [ ! -f "/etc/rc.local" ];then
|
if [ ! -f "/etc/rc.local" ];then
|
||||||
touch /etc/rc.local
|
touch /etc/rc.local
|
||||||
@@ -420,3 +465,4 @@ pushd /opt/ansible-lxc-rpc/rpc_deployment
|
|||||||
# Reconfigure Rsyslog
|
# Reconfigure Rsyslog
|
||||||
install_bits infrastructure/rsyslog-config.yml
|
install_bits infrastructure/rsyslog-config.yml
|
||||||
popd
|
popd
|
||||||
|
get_instance_info
|
||||||
|
|||||||
Reference in New Issue
Block a user