add user configuration and fix some bugs

Change-Id: Iee9b4550504a8918824f3260e7622788e5feb098
This commit is contained in:
xiaodongwang 2015-03-08 23:39:19 -07:00
parent 7de85ae46a
commit 91530187f0
10 changed files with 120 additions and 78 deletions

View File

@ -35,11 +35,23 @@ $SNIPPET('kickstart_network_config')
$SNIPPET('kickstart_partition_disks')
$SNIPPET('kickstart_yum_repo_config')
# Root Password
#if $getVar('password', '') != ""
rootpw --iscrypted $password
#else
# Set User Password
#if $getVar('username', 'root') != "root"
rootpw root
#set username = $getVar('username', 'root')
#set crypted_param = ''
#set password_param = '--password=%s' % $username
#if $getVar('password', '') != ""
#set crypted_param = '--iscrypted'
#set password_param = '--password=%s' % $password
#end if
user --name=$username $crypted_param $password_param
#else
#if $getVar('password', '') != ""
rootpw --iscrypted $password
#else
rootpw root
#end if
#end if
# Selinux Disable

View File

@ -64,14 +64,31 @@ d-i live-installer/net-image string http://$http_server/cobbler/ks_mirror/$distr
#end if
# root account and password
#if $getVar('username', 'root') != "root"
d-i passwd/root-login boolean false
d-i passwd/make-user boolean true
d-i user-setup/allow-password-weak boolean true
d-i passwd/root-password password root
d-i passwd/root-password-again password root
#set username = $getVar('username', 'root')
d-i passwd/user-fullname string $username
d-i passwd/username string $username
#if $getVar('password', '') != ""
d-i passwd/user-password-crypted password $password
#else
d-i passwd/user-password password $username
d-i passwd/user-password-again password $username
#end if
#else
d-i passwd/root-login boolean true
d-i passwd/make-user boolean false
d-i user-setup/allow-password-weak boolean true
#if $getVar('password', '') != ""
#if $getVar('password', '') != ""
d-i passwd/root-password-crypted password $password
#else
#else
d-i passwd/root-password password root
d-i passwd/root-password-again password root
#end if
#end if
$SNIPPET('preseed_apt_repo_config')

View File

@ -148,12 +148,9 @@ $SNIPPET($suse_software)
<skel>/etc/skel</skel>
</user_defaults>
<users config:type="list">
#if $getVar('username', 'root') != "root"
<user>
#if $getVar('password', '') != ""
<encrypted config:type="boolean">true</encrypted>
#else
<encrypted config:type="boolean">false</encrypted>
#end if
<fullname>root</fullname>
<gid>0</gid>
<home>/root</home>
@ -167,13 +164,55 @@ $SNIPPET($suse_software)
</password_settings>
<shell>/bin/bash</shell>
<uid>0</uid>
<username>root</username>
<user_password>root</user_password>
</user>
#set username = $getVar('username', 'root')
<user>
#if $getVar('password', '') != ""
<encrypted config:type="boolean">true</encrypted>
<user_password>$password</user_password>
#else
<encrypted config:type="boolean">false</encrypted>
<user_password>$username</user_password>
#end if
<username>$username</username>
<fullname>$username</fullname>
<password_settings>
<expire></expire>
<flag></flag>
<inact></inact>
<max></max>
<min></min>
<warn></warn>
</password_settings>
<shell>/bin/bash</shell>
</user>
#else
<user>
#if $getVar('password', '') != ""
<encrypted config:type="boolean">true</encrypted>
<user_password>$password</user_password>
#else
<encrypted config:type="boolean">false</encrypted>
<user_password>root</user_password>
#end if
<username>root</username>
<fullname>root</fullname>
<gid>0</gid>
<home>/root</home>
<password_settings>
<expire></expire>
<flag></flag>
<inact></inact>
<max></max>
<min></min>
<warn></warn>
</password_settings>
<shell>/bin/bash</shell>
<uid>0</uid>
</user>
#end if
</users>
<scripts>
## we have to include the pre-scripts tag to get kickstart_start included

View File

@ -27,24 +27,24 @@ PIDFILE=/tmp/chef_client_run.pid
if [ -f \\$PIDFILE ]; then
pid=\\$(cat \\$PIDFILE)
if [ -f /proc/\\$pid/exe ]; then
echo "there are chef_client_run.sh running with pid \\$pid" &>> /var/log/chef.log
echo "there are chef_client_run.sh running with pid \\$pid" >> /var/log/chef.log 2>&1
exit 1
fi
fi
echo \\$$ > \\$PIDFILE
while true; do
echo "run chef-client on \`date\`" &>> /var/log/chef.log
echo "run chef-client on \`date\`" >> /var/log/chef.log 2>&1
clients=\\$(pgrep chef-client)
if [[ "\\$?" == "0" ]]; then
echo "there are chef-clients '\\$clients' running" &>> /var/log/chef.log
echo "there are chef-clients '\\$clients' running" >> /var/log/chef.log 2>&1
break
else
echo "knife search nodes" &>> /var/log/chef.log
echo "knife search nodes" >> /var/log/chef.log 2>&1
# use knife node list here to check if node has been registered because knife search node
# doesn't work as expected.
USER=root HOME=/root knife node list |grep \\$HOSTNAME. &>> /var/log/chef.log
USER=root HOME=/root knife node list |grep \\$HOSTNAME. >> /var/log/chef.log 2>&1
nodes=\\$(USER=root HOME=/root knife node list |grep \\$HOSTNAME.)
echo "found nodes \\$nodes" &>> /var/log/chef.log
echo "found nodes \\$nodes" >> /var/log/chef.log 2>&1
let all_nodes_success=1
for node in \\$nodes; do
mkdir -p /var/log/chef/\\$node
@ -78,15 +78,15 @@ EOL
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
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
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
echo "chef-client --node-name \\$node run failed" >> /var/log/chef.log 2>&1
let all_nodes_success=0
else
echo "chef-client --node-name \\$node run success" &>> /var/log/chef.log
echo "chef-client --node-name \\$node run success" >> /var/log/chef.log 2>&1
touch /etc/chef/\\$node.done
fi
done

View File

@ -1,18 +1,9 @@
#set os_version = $getVar("profile_name","")
#if $str($getVar('anamon_enabled','')) == "1"
#if $getVar("compass_server", "") != ""
wget -O /tmp/anamon "http://$compass_server:$http_port/cobbler/aux/anamon"
#if 'CentOS-7' in os_version
python /tmp/anamon --watchfile "/tmp/syslog /tmp/anaconda.log /tmp/packaging.log" --name "$name" --server "$compass_server" --port "$http_port"
#else
python /tmp/anamon --name "$name" --server "$compass_server" --port "$http_port"
#end if
#else
wget -O /tmp/anamon "http://$server:$http_port/cobbler/aux/anamon"
#if 'CentOS-7' in os_version
python /tmp/anamon --watchfile "/tmp/syslog /tmp/anaconda.log /tmp/packaging.log" --name "$name" --server "$server" --port "$http_port"
#else
python /tmp/anamon --name "$name" --server "$server" --port "$http_port"
#end if
#end if
#end if

View File

@ -26,22 +26,22 @@ PIDFILE=/tmp/chef_client_run.pid
if [ -f \\$PIDFILE ]; then
pid=\\$(cat \\$PIDFILE)
if [ -f /proc/\\$pid/exe ]; then
echo "there are chef_client_run.sh running with pid \\$pid" &>> /var/log/chef.log
echo "there are chef_client_run.sh running with pid \\$pid" >> /var/log/chef.log 2>&1
exit 1
fi
fi
echo \\$$ > \\$PIDFILE
while true; do
echo "run chef-client on \`date\`" &>> /var/log/chef.log
echo "run chef-client on \`date\`" >> /var/log/chef.log 2>&1
clients=\\$(pgrep chef-client)
if [[ "\\$?" == "0" ]]; then
echo "there are chef-clients '\\$clients' running" &>> /var/log/chef.log
echo "there are chef-clients '\\$clients' running" >> /var/log/chef.log 2>&1
break
else
echo "knife search nodes" &>> /var/log/chef.log
USER=root HOME=/root knife node list |grep \\$HOSTNAME. &>> /var/log/chef.log
echo "knife search nodes" >> /var/log/chef.log 2>&1
USER=root HOME=/root knife node list |grep \\$HOSTNAME. >> /var/log/chef.log 2>&1
nodes=\\$(USER=root HOME=/root knife node list |grep \\$HOSTNAME.)
echo "found nodes \\$nodes" &>> /var/log/chef.log
echo "found nodes \\$nodes" >> /var/log/chef.log 2>&1
all_nodes_success=1
for node in \\$nodes; do
mkdir -p /var/log/chef/\\$node
@ -71,15 +71,15 @@ EOL
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
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
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
echo "chef-client --node-name \\$node run failed" >> /var/log/chef.log 2>&1
all_nodes_success=0
else
echo "chef-client --node-name \\$node run success" &>> /var/log/chef.log
echo "chef-client --node-name \\$node run success" >> /var/log/chef.log 2>&1
touch /etc/chef/\\$node.done
fi
done

View File

@ -240,17 +240,7 @@ for remove_partition in \${remove_partitions}; do
pvremove -ff -y \${remove_partition}
done
select_disks=""
echo "remove disks \${remove_disks}" >> /tmp/preseed.log
for remove_disk in \${remove_disks}; do
if [ -z "\${select_disks}" ]; then
select_disks="\${remove_disk}"
else
select_disks="\${select_disks},\${remove_disk}"
fi
done
echo "d-i partman-auto/select_disks multiselect \${select_disks}" >> /tmp/part-include
echo "select disks \${select_disks}" >> /tmp/preseed.log
partition_disks=""
for disk in \${sorted_disks}; do
@ -499,6 +489,15 @@ if [ -z "\${first_disk}" ]; then
first_disk=/dev/sda
fi
#if $getVar('keep_old_partitions', '0') != "0"
echo "d-i grub-installer/with_other_os boolean true" >> /tmp/part-include
#else
echo "d-i grub-installer/only_debian boolean true" >> /tmp/part-include
#end if
echo "d-i grub-installer/bootdev string \${first_disk}" >> /tmp/part-include
echo "setup bootloader on disk \${first_disk}" >> /tmp/preseed.log
partition_param_boot="\${partition_fstype} \
\\$primary{ } \\$bootable{ } method{ format } \
format{ } use_filesystem{ } filesystem{ \${partition_fstype} } \

View File

@ -26,22 +26,22 @@ PIDFILE=/tmp/chef_client_run.pid
if [ -f \\$PIDFILE ]; then
pid=\\$(cat \\$PIDFILE)
if [ -f /proc/\\$pid/exe ]; then
echo "there are chef_client_run.sh running with pid \\$pid" &>> /var/log/chef.log
echo "there are chef_client_run.sh running with pid \\$pid" >> /var/log/chef.log 2>&1
exit 1
fi
fi
echo \\$$ > \\$PIDFILE
while true; do
echo "run chef-client on \`date\`" &>> /var/log/chef.log
echo "run chef-client on \`date\`" >> /var/log/chef.log 2>&1
clients=\\$(pgrep chef-client)
if [[ "\\$?" == "0" ]]; then
echo "there are chef-clients '\\$clients' running" &>> /var/log/chef.log
echo "there are chef-clients '\\$clients' running" >> /var/log/chef.log 2>&1
break
else
echo "knife search nodes" &>> /var/log/chef.log
USER=root HOME=/root knife node list |grep \\$HOSTNAME. &>> /var/log/chef.log
echo "knife search nodes" >> /var/log/chef.log 2>&1
USER=root HOME=/root knife node list |grep \\$HOSTNAME. >> /var/log/chef.log 2>&1
nodes=\\$(USER=root HOME=/root knife node list |grep \\$HOSTNAME.)
echo "found nodes \\$nodes" &>> /var/log/chef.log
echo "found nodes \\$nodes" >> /var/log/chef.log 2>&1
all_nodes_success=1
for node in \\$nodes; do
mkdir -p /var/log/chef/\\$node
@ -71,15 +71,15 @@ EOL
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
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
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
echo "chef-client --node-name \\$node run failed" >> /var/log/chef.log 2>&1
all_nodes_success=0
else
echo "chef-client --node-name \\$node run success" &>> /var/log/chef.log
echo "chef-client --node-name \\$node run success" >> /var/log/chef.log 2>&1
touch /etc/chef/\\$node.done
fi
done

View File

@ -468,24 +468,6 @@ for disk in \${sorted_disks[@]}; do
echo '</drive>' >> /tmp/profile/partition.xml
done
for disk in \${remove_disks[@]}; do
disk_name=\$(basename \$disk)
eval "used_disk=\\${used_disk_\${disk_name}}"
if [ ! -z "\${used_disk}" ]; then
# ignore disk that is already generated
echo "ignore disk \$disk that is already generated" >> /tmp/log
continue
fi
eval "used_disk_\${disk_name}=\$disk"
echo "add disk \$disk into disks" >> /tmp/log
echo '<drive>' >> /tmp/profile/partition.xml
echo " <device>\$disk</device>" >> /tmp/profile/partition.xml
echo ' <initialize config:type="boolean">true</initialize>' >> /tmp/profile/partition.xml
echo ' <use>all</use>' >> /tmp/profile/partition.xml
echo ' <disklabel>gpt</disklabel>' >> /tmp/profile/partition.xml
echo '</drive>' >> /tmp/profile/partition.xml
done
echo "partition disks" >> /tmp/log
if [ \${#vggroup[@]} -gt 0 ]; then
@ -536,8 +518,10 @@ echo ' </device_map_entry>' >> /tmp/profile/bootloader.xml
echo '</device_map>' >> /tmp/profile/bootloader.xml
echo '<global>' >> /tmp/profile/bootloader.xml
echo ' <activate>true</activate>' >> /tmp/profile/bootloader.xml
echo ' <append>$kernel_options_post</append>' >> /tmp/profile/bootloader.xml
echo ' <default>SUSE</default>' >> /tmp/profile/bootloader.xml
echo ' <timeout config:type="integer">0</timeout>' >> /tmp/profile/bootloader.xml
echo ' <generic_mbr>true</generic_mbr>' >> /tmp/profile/bootloader.xml
echo ' <boot_mbr>true</boot_mbr>' >> /tmp/profile/bootloader.xml
echo ' <boot_boot>true</boot_boot>' >> /tmp/profile/bootloader.xml
echo '</global>' >> /tmp/profile/bootloader.xml

View File

@ -1,4 +1,4 @@
# Repository Config
## Repository Config
#set $repo_data = $getVar("repo_data",[])
<add-on>
<add_on_products config:type="list">