fix two potential bugs to make ubuntu14.04 pass regtest

Change-Id: I9a27152233efcaf07ac40e2e02303ec3e87c4dd2

update cobbler snippets

Change-Id: I8af32409cee0d518d20963e83c0652c5b197d057
This commit is contained in:
xiaodongwang 2015-03-12 16:36:32 -07:00
parent 91530187f0
commit e355f4f18e
14 changed files with 329 additions and 211 deletions

View File

@ -79,6 +79,7 @@
<package>rsyslog</package>
<package>iproute2</package>
<package>parted</package>
<package>lsb-release</package>
#if $getVar('tool', '') != ''
#set $suse_software = "software_%s.xml" % $tool
$SNIPPET($suse_software)

View File

@ -74,7 +74,9 @@ local3.info @$compass_server:514
local3.info @server:514
#end if
EOL
rm -rf /var/lib/rsyslog/chef_\\$node_log
if [ -f "/var/lib/rsyslog/chef_\\${node}_log" ]; then
rm -rf /var/lib/rsyslog/chef_\\$node_log
fi
service rsyslog restart
fi
if [ -f "/etc/chef/\\$node.done" ]; then

View File

@ -15,40 +15,51 @@
declare -A disk_mapping
declare -A disk_path_mapping
set \$(ls -s -l /dev/disk/by-path | awk '{print \$10, \$12}')
let disk_mapping_nums=\$#/2
let disk_mapping_offset=0
echo "disk_mapping_nums: \$disk_mapping_nums" > /tmp/log
echo "disk_mapping: \$*" >> /tmp/log
while [ \$disk_mapping_offset -lt \$disk_mapping_nums ]; do
let found_disk_type=0
declare -A ignore_disk_mapping
declare -A ignore_disk_path_mapping
if [ -e /dev/disk/by-path ]; then
set \$(ls -s -l /dev/disk/by-path | awk '{print \$10, \$12}')
let disk_mapping_nums=\$#/2
let disk_mapping_offset=0
echo "disk_mapping_nums: \$disk_mapping_nums" > /tmp/log
echo "disk_mapping: \$*" >> /tmp/log
while [ \$disk_mapping_offset -lt \$disk_mapping_nums ]; do
let found_disk_type=0
#if $getVar('disk_type_only','') != ""
if expr match "\$1" ".*-${disk_type_only}-.*"; then
let found_disk_type=1
fi
if expr match "\$1" ".*-${disk_type_only}-.*"; then
let found_disk_type=1
fi
#else
let found_disk_type=1
let found_disk_type=1
#end if
path_name=\$(basename \$1)
disk_name=\$(basename \$2)
let disk_mapping_offset=\$disk_mapping_offset+1
shift 2
path_name=\$(basename \$1)
disk_name=\$(basename \$2)
let disk_mapping_offset=\$disk_mapping_offset+1
shift 2
if [ \$found_disk_type -gt 0 ]; then
disk_mapping[\${disk_name}]="/dev/disk/by-path/\${path_name}"
disk_mapping[\${path_name}]="/dev/disk/by-path/\${path_name}"
disk_path_mapping[\${disk_name}]="/dev/\${disk_name}"
disk_path_mapping[\${path_name}]="/dev/\${disk_name}"
fi
done
if [ \$found_disk_type -gt 0 ]; then
disk_mapping[\${disk_name}]="/dev/disk/by-path/\${path_name}"
disk_mapping[\${path_name}]="/dev/disk/by-path/\${path_name}"
disk_path_mapping[\${disk_name}]="/dev/\${disk_name}"
disk_path_mapping[\${path_name}]="/dev/\${disk_name}"
else
ignore_disk_mapping[\${disk_name}]="/dev/disk/by-path/\${path_name}"
ignore_disk_mapping[\${path_name}]="/dev/disk/by-path/\${path_name}"
ignore_disk_path_mapping[\${disk_name}]="/dev/\${disk_name}"
ignore_disk_path_mapping[\${path_name}]="/dev/\${disk_name}"
fi
done
for key in \${!disk_mapping[@]}; do
echo "disk mapping \$key => \${disk_mapping[\$key]}" >> /tmp/log
done
for key in \${!disk_mapping[@]}; do
echo "disk mapping \$key => \${disk_mapping[\$key]}" >> /tmp/log
done
for key in \${!disk_path_mapping[@]}; do
echo "disk path mapping \$key => \${disk_path_mapping[\$key]}" >> /tmp/log
done
for key in \${!disk_path_mapping[@]}; do
echo "disk path mapping \$key => \${disk_path_mapping[\$key]}" >> /tmp/log
done
else
echo "/dev/disk/by-path does not exist" >> /tmp/log
fi
declare -A partition_disks
declare -A disks
@ -58,15 +69,27 @@ let disk_offset=0
let found_disk_offset=0
while [ \$disk_offset -lt \$disk_nums ]; do
disk=\$1
disk_name=\$(basename \$1)
disk_name=\$(basename \$disk)
let offset=\${disk_offset}
let disk_offset=\${disk_offset}+1
shift 2
if [[ x"\${disk_mapping[\${disk_name}]}" == x"" ]]; then
echo "ignore disk \${disk_name} since it is not in disk_mapping" >> /tmp/log
let disk_offset=\$disk_offset+1
continue
if [[ x"\${ignore_disk_mapping[\${disk_name}]}" != x"" ]]; then
echo "ignore disk \${disk_name} since it is not in disk_mapping" >> /tmp/log
continue
else
echo "did not found disk path for \$disk but it is not ignored" >> /tmp/log
disk_mapping[\${disk_name}]="/dev/\${disk_name}"
disk_path_mapping[\${disk_name}]="/dev/\${disk_name}"
fi
fi
let found_disk=0
#if $getVar('partition_by_path', '0') != "0"
disk=\${disk_mapping[\${disk_name}]}
#end if
disks[\$offset]=\$disk
#if $getVar('partitions_only', '') != ""
#for $partition_only in $partitions_only.split(',')
#if not $partition_only
@ -82,18 +105,11 @@ while [ \$disk_offset -lt \$disk_nums ]; do
let found_disk=1
#end if
#if $getVar('partition_by_path', '0') != "0"
disk=\${disk_mapping[\${disk_name}]}
#end if
if [ \${found_disk} -gt 0 ]; then
echo "add disk \${disk_name} in partitioning list" >> /tmp/log
partition_disks[\${found_disk_offset}]=\$disk
let found_disk_offset=\${found_disk_offset}+1
partition_disks[\${found_disk_offset}]=\$disk
let found_disk_offset=\${found_disk_offset}+1
fi
disks[\${disk_offset}]=\$disk
let disk_offset=\${disk_offset}+1
done
echo "partition disks \${partition_disks[@]}" >> /tmp/log
echo "disks \${disks[@]}" >> /tmp/log
@ -114,13 +130,15 @@ echo "sorted disks \${sorted_disks[@]}" >> /tmp/log
#end if
set \${sorted_disks[@]}
shift $disk_start_offset
unset sorted_disks
sorted_disks=(\$@)
echo "sorted disks begin from the $start_from_disk: \${sorted_disks[@]}" >> /tmp/log
#end if
#if $getVar('disk_num', '') != ""
set \${sorted_disks[@]}
sorted_disks=\$(printf '%s\n' \$@ | head -n${disk_num})
unset sorted_disks
sorted_disks=(\$(printf '%s\n' \$@ | head -n${disk_num}))
echo "sorted disks for $disk_num disks: \${sorted_disks[@]}" >> /tmp/log
#end if
@ -146,17 +164,20 @@ done
echo "clearpart --all --initlabel" > /tmp/part-include
declare -A remove_disks
let remove_disk_offset=0
#if $getVar('keep_old_partitions', '0') != "0"
for disk in \${sorted_disks[@]}; do
dd if=/dev/zero of=\${disk} bs=512 count=1
remove_disks+=(\$disk)
remove_disks[\${remove_disk_offset}]=\$disk
let remove_disk_offset=\${remove_disk_offset}+1
done
echo "only partition \$sorted_disks_str" >> /tmp/log
echo "ignoredisk --only-use=\$sorted_disks_str" >> /tmp/part-include
#else
for disk in \${disks[@]}; do
dd if=/dev/zero of=\${disk} bs=512 count=1
remove_disks+=(\$disk)
remove_disks[\${remove_disk_offset}]=\$disk
let remove_disk_offset=\${remove_disk_offset}+1
done
#end if
echo "remove disks \${remove_disks[@]}" >> /tmp/log
@ -401,7 +422,7 @@ for key in \${!partitions_name[@]}; do
done
for key in \${!partitions_percentage[@]}; do
echo "partition percentage \$key => \${partitions_percentage[\$key]}" >> /tmp/log
echo "partition percentage \$key => \${partitions_percentage[\$key]}" >> /tmp/log
done
for key in \${!partitions_size[@]}; do
@ -444,8 +465,9 @@ vggroup=''
let disk_nums=\${#sorted_disks[@]}
let disk_offset=0
while [ \${disk_offset} -lt \${disk_nums} ]; do
let pv_id=\${disk_offset}+1
disk=\${sorted_disks[\${disk_offset}]}
let disk_offset=\$disk_offset+1;
let pv_id=\${disk_offset}
partname="pv.0\${pv_id}"
if [ ! -z "\${max_disks_size[\${disk}]}" ]; then
max_disk_size=\${max_disks_size[\${disk}]}
@ -471,7 +493,6 @@ while [ \${disk_offset} -lt \${disk_nums} ]; do
echo "part \${reserve_partname} --size=\${reserve_disk_size} --ondisk=\${disk}" >> /tmp/part-include
reserve_vggroup="\${reserve_vggroup} \${reserve_partname}"
fi
let disk_offset=\$disk_offset+1;
done
if [ ! -z "\$vggroup" ]; then
@ -483,11 +504,11 @@ fi
declare -A sorted_partitions
sorted_partitions[0]=\${default_partition}
partition_offset=1
let sorted_partition_offset=1
for key in \${!partitions_name[@]}; do
if [[ "\$key" != "\${default_partition}" ]]; then
sorted_partitions[\${partition_offset}]=\$key
let partition_offset=\${partition_offset}+1
sorted_partitions[\${sorted_partition_offset}]=\$key
let sorted_partition_offset=\${sorted_partition_offset}+1
fi
done

View File

@ -67,13 +67,15 @@ EOL
\\\\$InputFilePollInterval 1
local3.info @$server:514
EOL
rm -rf /var/lib/rsyslog/chef_\\$node_log
if [ -f "/var/spool/rsyslog/chef_\\${node}_log" ]; then
rm -rf /var/spool/rsyslog/chef_\\${node}_log
fi
service rsyslog restart
fi
if [ -f "/etc/chef/\\$node.done" ]; then
USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem >> /var/log/chef.log 2>&1
if [ -f "/etc/chef/\\${node}.done" ]; then
USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\${node}.json --client_key /etc/chef/\\${node}.pem >> /var/log/chef.log 2>&1
else
USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem -L /var/log/chef/\\$node/chef-client.log >> /var/log/chef.log 2>&1
USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\${node}.json --client_key /etc/chef/\\${node}.pem -L /var/log/chef/\\$node/chef-client.log >> /var/log/chef.log 2>&1
fi
if [ "\\$?" != "0" ]; then
echo "chef-client --node-name \\$node run failed" >> /var/log/chef.log 2>&1

View File

@ -9,20 +9,14 @@ APT::Get::force-yes "true";
#if $getVar('proxy', '') != ''
Acquire::http::Proxy "$proxy";
#end if
#set $repo_data = $getVar("repo_data",[])
#for $repo in $repo_data
#for $dist in $repo.apt_dists
#set $comps = " ".join($repo.apt_components)
#if $repo.mirror_locally
Acquire::http::Proxy::$http_server "DIRECT";
#end if
#end for
#end for
Acquire::http::Proxy::$http_server DIRECT;
#if $getVar("local_repo","") != ""
#import urlparse
#set $local_repo_url = $urlparse.urlparse($local_repo)
#set $local_repo_server = $local_repo_url.hostname
#if $http_server != $local_repo_server
Acquire::http::Proxy::${local_repo_server} DIRECT;
#end if
#end if
EOF

View File

@ -1,34 +1,39 @@
set \$(ls -l /dev/disk/by-label | tr -s '\t' ' ' | cut -d' ' -f9,11)
label_mapping_nums=\$((\$#/2))
label_mapping_offset=0
echo "label_mapping_nums: \$label_mapping_nums" >> /tmp/preseed.log
remove_partitions=""
while [ \$label_mapping_offset -lt \$label_mapping_nums ]; do
partition_label=\$1
partition_name=\$(basename \$2)
shift 2
label_mapping_offset=\$((\${label_mapping_offset}+1))
if [ -z "\${partition_label}" -o -z "\${partition_name}" ]; then
continue
fi
partition=/dev/\${partition_name}
if expr match "\${partition_label}" "reserved_.*"; then
remove_partitions="\${remove_partitions} \${partition}"
echo "add \${partition} into remove list" >> /tmp/preseed.log
partitions=\$(pvs --noheadings --separator :| cut -d: -f1,2)
vg_remove=0
remove_partitions=''
echo "partitions \$partitions" >> /tmp/post_partition.log
for partition in \$partitions; do
set \$(echo \$partition | tr ':' ' ')
partition=\$1
vg=\$2
if [ "\$vg" = "reserved" ]; then
echo "prepare remove partition \$partition" >> /tmp/post_partition.log
remove_partitions="\${remove_partitions} \$partition"
vg_remove=1
else
echo "ignore \$vg since it is not reserved" >> /tmp/post_partition.log
fi
done
echo "remove partitions \${remove_partitions}" >> /tmp/preseed.log
for partition in \${remove_partitions}; do
if [ -z "\$partition" ]; then
continue
fi
set \$(echo \${partition} | sed -e 's/^\(.*\)\([0-9]\+\)\$/\1 \2/g')
if [ "\${vg_remove}" != "0" ]; then
vgremove -f reserved
fi
for remove_partition in \${remove_partitions}; do
echo "remove pv \${remove_partition}" >> /tmp/post_partition.log
pvremove -ff -y \${remove_partition}
set \$(echo \${remove_partition} | sed -e 's/^\(.*\)\([0-9]\+\)\$/\1 \2/g')
partition_disk=\$1
partition_number=\$2
echo "remove disk \${partition_disk} partition \${partition_number}" >> /tmp/preseed.log
if [ -z "\${partition_disk}" -o -z "\${partition_number}" ]; then
continue
if [ ! -z "\${partition_disk}" ]; then
if [ ! -z "\${partition_number}" ]; then
echo "remove partition \${remove_partition} on \${partition_disk} number \${partition_number}" >> /tmp/post_partition.log
parted \${partition_disk} --script -- rm \${partition_number}
else
echo "no partition number found for \${remove_partition}" >> /tmp/post_partition.log
fi
else
echo "no partition disk found for \${remove_partition}" >> /tmp/post_partition.log
fi
parted \${partition_disk} rm \${partition_number}
done

View File

@ -7,10 +7,10 @@ echo "generate pre network config" > /tmp/network_log
#raw
# generic functions to be used later for discovering NICs
mac_exists() {
if [ -f /bin/ip ]; then
if type ip; then
ip -o link | grep -i "$1" 2>/dev/null >/dev/null
return $?
elif [ -f /bin/esxcfg-nics ]; then
elif type esxcfg-nics; then
esxcfg-nics -l | grep -i "$1" 2>/dev/null >/dev/null
return $?
else
@ -19,9 +19,9 @@ mac_exists() {
fi
}
get_ifname() {
if [ -f /bin/ip ]; then
if type ip; then
IFNAME=$(ip -o link | grep -i "$1" | sed -e 's/^[0-9]*: //' -e 's/:.*//')
elif [ -f /bin/esxcfg-nics ]; then
elif type esxcfg-nics; then
IFNAME=$(esxcfg-nics -l | grep -i "$1" | cut -d " " -f 1)
else
IFNAME=$(ifconfig -a | grep -i "$1" | cut -d " " -f 1)

View File

@ -13,55 +13,65 @@
#set $vgname = $hostname.split('.')[0]
#end if
set \$(ls -s -l /dev/disk/by-path | tr -s '\t' ' ' | cut -d' ' -f11,13)
disk_mapping_nums=\$((\$#/2))
disk_mapping_offset=0
echo "disk_mapping_nums: \$disk_mapping_nums" >> /tmp/preseed.log
echo "disk_mapping: \$*" >> /tmp/preseed.log
disk_mapping=""
disk_path_mapping=""
while [ \$disk_mapping_offset -lt \$disk_mapping_nums ]; do
found_disk_type=0
echo "partman early script" >> /tmp/preseed.log
if [ -e /dev/disk/by-path ]; then
set \$(ls -s -l /dev/disk/by-path | tr -s '\t' ' ' | cut -d' ' -f11,13)
disk_mapping_nums=\$((\$#/2))
disk_mapping_offset=0
echo "disk_mapping_nums: \$disk_mapping_nums" >> /tmp/preseed.log
echo "disk_mapping: \$@" >> /tmp/preseed.log
disk_mapping=""
disk_path_mapping=""
while [ \$disk_mapping_offset -lt \$disk_mapping_nums ]; do
found_disk_type=0
#if $getVar('disk_type_only','') != ""
if expr match "\$1" ".*-${disk_type_only}-.*"; then
found_disk_type=1
fi
if expr match "\$1" ".*-${disk_type_only}-.*"; then
found_disk_type=1
fi
#else
found_disk_type=1
found_disk_type=1
#end if
path_name=\$(basename \$1)
disk_path_name=\$(echo \${path_name} | tr '-' '_' | tr ':' '_' | tr '.' '_')
disk_name=\$(basename \$2)
disk_mapping_offset=\$((\${disk_mapping_offset}+1))
shift 2
path_name=\$(basename \$1)
disk_path_name=\$(echo \${path_name} | tr '-' '_' | tr ':' '_' | tr '.' '_')
disk_name=\$(basename \$2)
disk_mapping_offset=\$((\${disk_mapping_offset}+1))
shift 2
if [ \$found_disk_type -gt 0 ]; then
if [ -z "\${disk_mapping}" ]; then
disk_mapping="\${disk_name}"
if [ \$found_disk_type -gt 0 ]; then
if [ -z "\${disk_mapping}" ]; then
disk_mapping="\${disk_name}"
else
disk_mapping="\${disk_mapping} \${disk_name}"
fi
if [ -z "\${disk_path_mapping}" ]; then
disk_path_mapping="\${disk_path_name}"
else
disk_path_mapping="\${disk_path_mapping} \${disk_path_name}"
fi
eval "disk_\${disk_name}=/dev/disk/by-path/\${path_name}"
eval "disk_\${disk_path_name}=/dev/disk/by-path/\${path_name}"
eval "disk_path_\${disk_path_name}=/dev/\${disk_name}"
eval "disk_path_\${disk_name}=/dev/\${disk_name}"
else
disk_mapping="\${disk_mapping} \${disk_name}"
eval "ignore_disk_\${disk_name}=/dev/disk/by-path/\${path_name}"
eval "ignore_disk_\${disk_path_name}=/dev/disk/by-path/\${path_name}"
eval "ignore_disk_path_\${disk_path_name}=/dev/\${disk_name}"
eval "ignore_disk_path_\${disk_name}=/dev/\${disk_name}"
fi
if [ -z "\${disk_path_mapping}" ]; then
disk_path_mapping="\${disk_path_name}"
else
disk_path_mapping="\${disk_path_mapping} \${disk_path_name}"
fi
eval "disk_\${disk_name}=/dev/disk/by-path/\${path_name}"
eval "disk_\${disk_path_name}=/dev/disk/by-path/\${path_name}"
eval "disk_path_\${disk_path_name}=/dev/\${disk_name}"
eval "disk_path_\${disk_name}=/dev/\${disk_name}"
fi
done
done
for key in \${disk_mapping}; do
eval "disk_path=\\${disk_\$key}"
echo "disk_mapping \$key => \${disk_path}" >> /tmp/preseed.log
done
for key in \${disk_mapping}; do
eval "disk_path=\\${disk_\$key}"
echo "disk_mapping \$key => \${disk_path}" >> /tmp/preseed.log
done
for key in \${disk_path_mapping}; do
eval "disk=\\${disk_path_\$key}"
echo "disk path mapping \$key => \${disk}" >> /tmp/preseed.log
done
for key in \${disk_path_mapping}; do
eval "disk=\\${disk_path_\$key}"
echo "disk path mapping \$key => \${disk}" >> /tmp/preseed.log
done
else
echo "/dev/disk/by-path does not exist" >> /tmp/preseed.log
fi
partition_disks=""
disks=""
@ -69,8 +79,15 @@ for disk in \$(list-devices disk); do
disk_name=\$(basename \$disk)
eval "disk_path=\\${disk_\${disk_name}}"
if [ -z "\${disk_path}" ]; then
echo "ignore disk \${disk_name} since it is not in disk_mapping" >> /tmp/preseed.log
continue
eval "ignore_disk_path=\\${ignore_disk_\${disk_name}}"
if [ ! -z "\${ignore_disk_path}" ]; then
echo "ignore disk \${disk_name} since it is not in disk_mapping" >> /tmp/preseed.log
continue
else
echo "did not found disk path for \$disk but it is not ignored" >> /tmp/preseed.log
eval "disk_\${disk_name}=/dev/\${disk_name}"
eval "disk_path_\${disk_name}=/dev/\${disk_name}"
fi
fi
found_disk=0
@ -243,13 +260,20 @@ done
echo "remove disks \${remove_disks}" >> /tmp/preseed.log
partition_disks=""
#if $getVar('keep_old_partitions', '0') != "0"
for disk in \${sorted_disks}; do
#else
for disk in \${disks}; do
#end if
if [ -z "\${partition_disks}" ]; then
partition_disks="\${disk}"
else
partition_disks="\${partition_disks} \${disk}"
fi
done
partition_disks_str=\$(echo \${partition_disks} | tr ' ' ',')
echo "d-i partman-auto/select_disks multiselect \${partition_disks_str}" >> /tmp/part-include
echo "d-i partman-auto/disk string \${partition_disks}" >> /tmp/part-include
echo "disks \${partition_disks}" >> /tmp/preseed.log
@ -590,6 +614,8 @@ for disk in \${sorted_disks}; do
#else
disk_name=\$(basename \$disk)
#end if
eval "used_disk_\${disk_name}=\$disk"
echo "add disk \$disk into disks" >> /tmp/preseed.log
eval "max_disk_size=\\${max_disk_size_\${disk_name}}"
if [ -z "\${max_disk_size}" ]; then
max_disk_size=\${default_max_disk_size}
@ -612,15 +638,36 @@ method{ lvm } vg_name{ $vgname }"
echo "disk \${disk} reserve disk size \${reserve_disk_size}" >> /tmp/preseed.log
if [ \${reserve_disk_size} -gt 0 ]; then
reserve_disk_param="\${partition_fstype} \
device{ \${disk} } \
method{ format } format{ } label{ reserved_\${disk_name} } \
use_filesystem{ } filesystem{ \${partition_fstype} }"
\\$defaultignore{ } device{ \${disk} } \
method{ lvm } vg_name{ reserved }"
recipe="\$recipe \${reserve_disk_size} \${reserve_disk_size} \${reserve_disk_size} \${reserve_disk_param} ."
echo "reserve partition param \${disk_name} => \${reserve_disk_param}" >> /tmp/preseed.log
fi
done
#if $getVar('keep_old_partitions', '0') == "0"
for disk in \$disks; do
#if $getVar('partition_by_path', '0') != "0"
path_name=\$(basename \${disk})
disk_path_name=\$(echo \${path_name} | tr '-' '_' | tr ':' '_' | tr '.' '_')
eval "path_disk=\\${disk_path_\${disk_path_name}}"
disk_name=\$(basename \${path_disk})
#else
disk_name=\$(basename \$disk)
#end if
eval "used_disk=\\${used_disk_\${disk_name}}"
if [ -z "\${used_disk}" ]; then
reserve_disk_param="\${partition_fstype} \
\\$defaultignore{ } device{ \${disk} } \
method{ lvm } vg_name{ reserved }"
recipe="\$recipe 512 512+100% -1 \${reserve_disk_param} ."
echo "reserve partition param \${disk_name} => \${reserve_disk_param}" >> /tmp/preseed.log
fi
done
#end if
echo "d-i partman-auto/expert_recipe string \$recipe" >> /tmp/part-include
echo "d-i partman-auto/choose_recipe select boot-root" >> /tmp/part-include
echo "d-i partman-lvm/vgcreate string $vgname" >> /tmp/part-include
echo "d-i partman-auto-lvm/new_vg_name string $vgname" >> /tmp/part-include
## echo "d-i partman-lvm/vgcreate string $vgname" >> /tmp/part-include
## echo "d-i partman-auto-lvm/new_vg_name string $vgname" >> /tmp/part-include

View File

@ -4,7 +4,7 @@ cat << EOL > /etc/rsyslog.conf
\\$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
\\$ModLoad imfile
\\$WorkDirectory /var/lib/rsyslog
\\$WorkDirectory /var/spool/rsyslog
\\$ActionQueueType LinkedList
\\$ActionQueueFileName srvrfwd
\\$ActionResumeRetryCount -1

View File

@ -4,14 +4,14 @@
<![CDATA[
\#\#\#\# MODULES \#\#\#\##
\\$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
\\$ModLoad imfile
\$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
\$ModLoad imfile
\\$WorkDirectory /var/lib/rsyslog
\\$ActionQueueType LinkedList
\\$ActionQueueFileName srvrfwd
\\$ActionResumeRetryCount -1
\\$ActionQueueSaveOnShutDown on
\$WorkDirectory /var/spool/rsyslog
\$ActionQueueType LinkedList
\$ActionQueueFileName srvrfwd
\$ActionResumeRetryCount -1
\$ActionQueueSaveOnShutDown on
#if $getVar("compass_server", "") != ""
*.* @@$compass_server:514
#else
@ -19,26 +19,26 @@
#end if
\# Provides UDP syslog reception
\#\\$ModLoad imudp
\#\\$UDPServerRun 514
\#\$ModLoad imudp
\#\$UDPServerRun 514
\# Provides TCP syslog reception
\\$ModLoad imtcp
\\$InputTCPServerRun 514
\$ModLoad imtcp
\$InputTCPServerRun 514
#set system_name = $getVar('system_name','')
\\$LocalHostName $system_name
\$LocalHostName $system_name
\#\#\#\# GLOBAL DIRECTIVES \#\#\#\##
\# Use default timestamp format
\\$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
\$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
\# File syncing capability is disabled by default. This feature is usually not required,
\# not useful and an extreme performance hit
\#\\$ActionFileEnableSync on
\#\$ActionFileEnableSync on
\# Include all config files in /etc/rsyslog.d/
\\$IncludeConfig /etc/rsyslog.d/*.conf
\$IncludeConfig /etc/rsyslog.d/*.conf
\#\#\#\# RULES \#\#\#\##

View File

@ -12,9 +12,9 @@ cat << EOF > /etc/init.d/chef
# Description: chef client daemon (chef).
#end raw
echo "old date is: `date`" 2>&1 > /tmp/ntp.log
service ntpd stop 2>&1 >> /tmp/ntp.log
service ntp stop 2>&1 >> /tmp/ntp.log
ntpdate $ntp_server 2>&1 >> /tmp/ntp.log
service ntpd start 2>&1 >> /tmp/ntp.log
service ntp start 2>&1 >> /tmp/ntp.log
echo "new date is: `date`" 2>&1 >> /tmp/ntp.log
crontab -l > /tmp/mycron

View File

@ -67,13 +67,15 @@ EOL
\\\\$InputFilePollInterval 1
local3.info @$server:514
EOL
rm -rf /var/lib/rsyslog/chef_\\$node_log
service rsyslog restart
if [ -f "/var/spool/rsyslog/chef_\\${node}_log" ]; then
rm -rf /var/spool/rsyslog/chef_\\${node}_log
fi
service syslog restart
fi
if [ -f "/etc/chef/\\$node.done" ]; then
USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem >> /var/log/chef.log 2>&1
if [ -f "/etc/chef/\\${node}.done" ]; then
USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\${node}.json --client_key /etc/chef/\\${node}.pem >> /var/log/chef.log 2>&1
else
USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem -L /var/log/chef/\\$node/chef-client.log >> /var/log/chef.log 2>&1
USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\${node}.json --client_key /etc/chef/\\${node}.pem -L /var/log/chef/\\$node/chef-client.log >> /var/log/chef.log 2>&1
fi
if [ "\\$?" != "0" ]; then
echo "chef-client --node-name \\$node run failed" >> /var/log/chef.log 2>&1

View File

@ -1,10 +1,8 @@
set \$(lsblk -n -p -P -o NAME,TYPE,LABEL | grep 'TYPE="part"' | grep 'LABEL="reserved_.*"' | cut -d' ' -f1)
set \$(lsblk -n -r -o NAME,LABEL | grep 'reserved_.*' | cut -d' ' -f1)
echo "list partitions: \$@" >> /tmp/post_partition.log
declare -a remove_partitions
for arg in \$@; do
eval \$arg
partition=\$NAME
partition_name=\$(basename \$partition)
for partition_name in \$@; do
partition=/dev/\${partition_name}
echo "add \${partition_name} => \$partition into remove list" >> /tmp/post_partition.log
remove_partitions[\${partition_name}]=\$partition
done
@ -20,10 +18,16 @@ for partition in \${remove_partitions[@]}; do
partition_disk=\$1
partition_number=\$2
echo "remove disk \${partition_disk} partition \${partition_number}" >> /tmp/post_partition.log
if [ -z "\${partition_disk}" -o -z "\${partition_number}" ]; then
continue
if [ ! -z "\${partition_disk}" ]; then
if [ ! -z "\${partition_number}" ]; then
echo "remove \$partition on \${partition_disk} number \${partition_number}" >> /tmp/post_partition.log
parted \${partition_disk} --script -- rm \${partition_number}
else
echo "partition number not found for partition \$partition" >> /tmp/post_partition.log
fi
else
echo "partition disk not found for partition \$partition" >> /tmp/post_partition.log
fi
parted \${partition_disk} rm \${partition_number}
done
grep -v "LABEL=reserved_.*" /etc/fstab > /tmp/fstab.new

View File

@ -13,52 +13,60 @@
#set $vgname = $hostname.split('.')[0]
#end if
set \$(ls -s -l /dev/disk/by-path | awk '{print \$10, \$12}')
let disk_mapping_nums=\$#/2
let disk_mapping_offset=0
echo "disk_mapping_nums: \$disk_mapping_nums" > /tmp/log
echo "disk_mapping: \$*" >> /tmp/log
declare -a disk_mapping
disk_mapping=()
declare -a disk_path_mapping
disk_path_mapping=()
while [ \$disk_mapping_offset -lt \$disk_mapping_nums ]; do
let found_disk_type=0
if [ -e /dev/disk/by-path ]; then
set \$(ls -s -l /dev/disk/by-path | awk '{print \$10, \$12}')
let disk_mapping_nums=\$#/2
let disk_mapping_offset=0
echo "disk_mapping_nums: \$disk_mapping_nums" > /tmp/log
echo "disk_mapping: \$*" >> /tmp/log
while [ \$disk_mapping_offset -lt \$disk_mapping_nums ]; do
let found_disk_type=0
#if $getVar('disk_type_only','') != ""
if expr match "\$1" ".*-${disk_type_only}-.*"; then
let found_disk_type=1
fi
if expr match "\$1" ".*-${disk_type_only}-.*"; then
let found_disk_type=1
fi
#else
let found_disk_type=1
let found_disk_type=1
#end if
path_name=\$(basename \$1)
disk_path_name=\$(echo \${path_name} | tr '-' '_' | tr ':' '_' | tr '.' '_')
disk_name=\$(basename \$2)
let disk_mapping_offset=\$disk_mapping_offset+1
shift 2
path_name=\$(basename \$1)
disk_path_name=\$(echo \${path_name} | tr '-' '_' | tr ':' '_' | tr '.' '_')
disk_name=\$(basename \$2)
let disk_mapping_offset=\$disk_mapping_offset+1
shift 2
if [ \$found_disk_type -gt 0 ]; then
disk_mapping+=(\${disk_name})
disk_path_mapping+=(\${disk_path_name})
eval "disk_\${disk_name}=/dev/disk/by-path/\${path_name}"
eval "disk_\${disk_path_name}=/dev/disk/by-path/\${path_name}"
eval "disk_path_\${disk_path_name}=/dev/\${disk_name}"
eval "disk_path_\${disk_name}=/dev/\${disk_name}"
fi
done
if [ \$found_disk_type -gt 0 ]; then
disk_mapping+=(\${disk_name})
disk_path_mapping+=(\${disk_path_name})
eval "disk_\${disk_name}=/dev/disk/by-path/\${path_name}"
eval "disk_\${disk_path_name}=/dev/disk/by-path/\${path_name}"
eval "disk_path_\${disk_path_name}=/dev/\${disk_name}"
eval "disk_path_\${disk_name}=/dev/\${disk_name}"
else
eval "ignore_disk_\${disk_name}=/dev/disk/by-path/\${path_name}"
eval "ignore_disk_\${disk_path_name}=/dev/disk/by-path/\${path_name}"
eval "ignore_disk_path_\${disk_path_name}=/dev/\${disk_name}"
eval "ignore_disk_path_\${disk_name}=/dev/\${disk_name}"
fi
done
echo "finish disk mapping" >> /tmp/log
for key in \${disk_mapping[@]}; do
eval "disk_path=\\${disk_\$key}"
echo "disk_mapping \$key => \${disk_path}" >> /tmp/log
done
for key in \${disk_path_mapping[@]}; do
eval "disk=\\${disk_path_\$key}"
echo "disk path mapping \$key => \${disk}" >> /tmp/log
done
echo "finish disk mapping" >> /tmp/log
for key in \${disk_mapping[@]}; do
eval "disk_path=\\${disk_\$key}"
echo "disk_mapping \$key => \${disk_path}" >> /tmp/log
done
for key in \${disk_path_mapping[@]}; do
eval "disk=\\${disk_path_\$key}"
echo "disk path mapping \$key => \${disk}" >> /tmp/log
done
else
echo "/dev/disk/by-path does not exist" >> /tmp/log
fi
declare -a partition_disks
partition_disks=()
@ -73,8 +81,15 @@ while [ \$disk_offset -lt \$disk_nums ]; do
let disk_offset=\$disk_offset+1
eval "disk_path=\\${disk_\${disk_name}}"
if [ -z "\${disk_path}" ]; then
echo "ignore disk \${disk_name} since it is not in disk_mapping" >> /tmp/log
continue
eval "ignore_disk_path=\\${ignore_disk_\${disk_name}}"
if [ ! -z "\${ignore_disk_path}" ]; then
echo "ignore disk \${disk_name} since it is not in disk_mapping" >> /tmp/log
continue
else
echo "did not found disk path for \$disk but it is not ignored" >> /tmp/log
eval "disk_\${disk_name}=/dev/\${disk_name}"
eval "disk_path_\${disk_name}=/dev/\${disk_name}"
fi
fi
let found_disk=0
@ -468,6 +483,31 @@ for disk in \${sorted_disks[@]}; do
echo '</drive>' >> /tmp/profile/partition.xml
done
#if $getVar('keep_old_partitions', '0') == "0"
for disk in \${disks[@]}; do
disk_name=\$(basename \$disk)
eval "used_disk=\\${used_disk_\${disk_name}}"
if [[ -z "\$used_disk" ]]; then
partition_numer=\$(lsblk -n -o MAJ:MIN,TYPE \$disk | grep part | awk '{print \$1}' | cut -d: -f2)
parted \$disk --script -- rm \${partition_numer}
fi
done
#end if
#if $getVar('keep_old_partitions', '0') == "0"
for disk in \${disks[@]}; do
disk_name=\$(basename \$disk)
eval "used_disk=\\${used_disk_\${disk_name}}"
if [[ -z "\$used_disk" ]]; then
partition_numers=\$(parted \$disk --script -- p | awk '/^ / {print \$1}')
echo "remove partition numbers \${partition_numers} on disk \$disk" >> /tmp/log
for partition_numer in \${partition_numers}; do
parted \$disk --script -- rm \${partition_numer}
done
fi
done
#end if
echo "partition disks" >> /tmp/log
if [ \${#vggroup[@]} -gt 0 ]; then