summaryrefslogtreecommitdiffstats
path: root/build/f_isoroot/f_kscfg/ks.cfg
blob: 1787db8c9fc766eaa1db537aa02ef3eec5f8205c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #75715e } /* Generic.Subheading */
.highlight .kc { color: #66d9ef } /* Keyword.Constant */
.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
.highlight .kn { color: #f92672 } /* Keyword.Namespace */
.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
.highlight .kr { color: #66d9ef } /* Keyword.Reserved */
.highlight .kt { color: #66d9ef } /* Keyword.Type */
.highlight .ld { color: #e6db74 } /* Literal.Date */
.highlight .m { color: #ae81ff } /* Literal.Number */
.highlight .s { color: #e6db74 } /* Literal.String */
.highlight .na { color: #a6e22e } /* Name.Attribute */
.highlight .nb { color: #f8f8f2 } /* Name.Builtin */
.highlight .nc { color: #a6e22e } /* Name.Class */
.highlight .no { color: #66d9ef } /* Name.Constant */
.highlight .nd { color: #a6e22e } /* Name.Decorator */
.highlight .ni { color: #f8f8f2 } /* Name.Entity */
.highlight .ne { color: #a6e22e } /* Name.Exception */
.highlight .nf { color: #a6e22e } /* Name.Function */
.highlight .nl { color: #f8f8f2 } /* Name.Label */
.highlight .nn { color: #f8f8f2 } /* Name.Namespace */
.highlight .nx { color: #a6e22e } /* Name.Other */
.highlight .py { color: #f8f8f2 } /* Name.Property */
.highlight .nt { color: #f92672 } /* Name.Tag */
.highlight .nv { color: #f8f8f2 } /* Name.Variable */
.highlight .ow { color: #f92672 } /* Operator.Word */
.highlight .w { color: #f8f8f2 } /* Text.Whitespace */
.highlight .mb { color: #ae81ff } /* Literal.Number.Bin */
.highlight .mf { color: #ae81ff } /* Literal.Number.Float */
.highlight .mh { color: #ae81ff } /* Literal.Number.Hex */
.highlight .mi { color: #ae81ff } /* Literal.Number.Integer */
.highlight .mo { color: #ae81ff } /* Literal.Number.Oct */
.highlight .sa { color: #e6db74 } /* Literal.String.Affix */
.highlight .sb { color: #e6db74 } /* Literal.String.Backtick */
.highlight .sc { color: #e6db74 } /* Literal.String.Char */
.highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */
.highlight .sd { color: #e6db74 } /* Literal.String.Doc */
.highlight .s2 { color: #e6db74 } /* Literal.String.Double */
.highlight .se { color: #ae81ff } /* Literal.String.Escape */
.highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */
.highlight .si { color: #e6db74 } /* Literal.String.Interpol */
.highlight .sx { color: #e6db74 } /* Literal.String.Other */
.highlight .sr { color: #e6db74 } /* Literal.String.Regex */
.highlight .s1 { color: #e6db74 } /* Literal.String.Single */
.highlight .ss { color: #e6db74 } /* Literal.String.Symbol */
.highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #a6e22e } /* Name.Function.Magic */
.highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */
.highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */
.highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */
.highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */
.highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */
}
@media (prefers-color-scheme: light) {
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
}
Barometer
---------
.. This work is licensed under a Creative Commons Attribution 4.0 International License.
.. http://creativecommons.org/licenses/by/4.0

::

    Note: this repository provides a demo implementation. It is not intended
    for unmodified use in production. It has not been tested for production.



The ability to monitor the Network Function Virtualization Infrastructure
(NFVI) where VNFs are in operation will be a key part of Service Assurance
within an NFV environment, in order to enforce SLAs or to detect violations,
faults or degradation in the performance of NFVI resources so that events
and relevant metrics are reported to higher level fault management systems.
If fixed function appliances are going to be replaced by virtualized
appliances the service levels, manageability and service assurance needs
to remain consistent or improve on what is available today.

As such, the NFVI needs to support the ability to monitor:

#. Traffic monitoring and performance monitoring of the components that
   provide networking functionality to the VNF, including: physical
   interfaces, virtual switch interfaces and flows, as well as the
   virtual interfaces themselves and their status, etc.
#. Platform monitoring including: CPU, memory, load, cache, thermals, fan
   speeds, voltages and machine check exceptions, etc.


All of the statistics and events gathered must be collected in-service and
must be capable of being reported by standard Telco mechanisms (e.g. SNMP,
REST), for potential enforcement or correction actions. In addition, this
information could be fed to analytics systems to enable failure prediction,
and can also be used for intelligent workload placement.
a> 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631
install
text
#%include /tmp/source.ks
cdrom
reboot --eject
lang en_US.UTF-8
keyboard us
rootpw r00tme
timezone --utc Etc/UTC
firewall --disabled
selinux --disabled
# ignore unsupported hardware warning
unsupported_hardware
# SKIP CONFIGURING X
skipx
repo --name="mos-centos" --baseurl=file:///run/install/repo/mos-centos/ --cost=100

# NEVER ever place zerombr here, it breaks automated installation
%include /tmp/bootloader.ks
%include /tmp/partition.ks
%include /tmp/post_partition.ks





%packages --nobase
@Core
fuel
fuel-library
fuel-dockerctl
authconfig
bind-utils
bridge-utils
cronie
crontabs
curl
dhcp
docker
fuel-bootstrap-cli
fuel-bootstrap-image
# NOTE(kozhukalov): We don't need target centos images in 8.0
# fuel-target-centos-images7.1.1503
fuelmenu
fuel-docker-images
fuel-mirror
fuel-openstack-metadata
gdisk
lrzip
lsof
man
mlocate
nmap-ncat
ntp
ntpdate
openssh-clients
policycoreutils
python-pypcap
rsync
puppet
rubygem-netaddr
rubygem-openstack
selinux-policy-targeted
strace
sysstat
system-config-firewall-base
tcpdump
telnet
vim
virt-what
wget
yum
yum-plugin-priorities
%end





# PREINSTALL SECTION
# HERE ARE COMMANDS THAT WILL BE LAUNCHED BEFORE
# INSTALLATION PROCESS ITSELF
%pre
#!/bin/sh

# hard drives
drives=""
removable_drives=""
for drv in `ls -1 /sys/block | grep "sd\|hd\|vd\|cciss"`; do
    if !(blkid | grep -q "${drv}.*Fuel"); then
      if (grep -q 0 /sys/block/${drv}/removable); then
          drives="${drives} ${drv}"
      else
          removable_drives="${removable_drives} ${drv}"
      fi
    fi
done
default_drive=`echo ${drives} ${removable_drives} | awk '{print $1}'`

installdrive=${installdrive:-undefined}
forceformat=${forceformat:-no}
for I in $(cat /proc/cmdline); do
  case "$I" in
    *=*)
      if ! [[ "${I}" =~ "." ]]; then eval "$I"; fi
    ;;
  esac
done

set ${drives} ${removable_drives}
numdrives=`echo $#`

tgtdrive="${installdrive}"

function confirm_format {
  check_drive="$1"
  local confirm_format="no"

  if [[ "$forceformat" == "yes" ]] ; then
    return 0
  fi

  if parted -s /dev/$check_drive print &>/dev/null ; then
    echo
    echo "$check_drive drive contains partition table:"
    parted -s /dev/$check_drive print
    echo
    read -p "Are you sure you want to erase ALL data on disk $check_drive? (y/N)" confirm_format
    if [[ "$confirm_format" == "y" ]] || [[ "$confirm_format" == "Y" ]] || [[ "$forceformat" == "yes" ]]; then
      return 0
    else
      return 1
    fi
  else
    return 0
  fi
}

format_confirmed="no"

if [ $numdrives -lt 1 ]; then
    exec < /dev/tty3 > /dev/tty3 2>&1
    chvt 3
    clear
    echo
    echo '********************************************************************'
    echo '*                            E R R O R                             *'
    echo '*                                                                  *'
    echo '*      There is no suitable media available for installation.      *'
    echo '*                Please attach a drive and try again.              *'
    echo '*                                                                  *'
    echo '********************************************************************'
    echo
    read -p "Press Enter to shut down the system: " _
    poweroff
fi

if [ ${numdrives} -gt 1 ] || [ `echo ${drives} | wc -w` -eq 0 ] ; then
    exec < /dev/tty3 > /dev/tty3 2>&1
    chvt 3
    while [ "${tgtdrive}" = "undefined" ]; do
        clear
        echo
        echo '********************************************************************************'
        echo '*                                 W A R N I N G                                *'
        echo '*                                                                              *'
        echo '*  Which of the detected hard drives do you want to be used as                 *'
        echo '*  the installation target?                                                    *'
        echo '*                                                                              *'
        echo '********************************************************************************'
        echo
        echo "Possible choices"
        echo "Persistent drives: ${drives}"
        echo "Removable drives: ${removable_drives}"
        echo
        if [ `echo ${drives} | wc -w` -eq 1 ] ; then
            read -t 30 -p "Choose hard drive: " tgtdrive || tgtdrive=$default_drive
        else
            read -p "Choose hard drive: " tgtdrive
        fi
        match="no"
        for drive in ${drives[@]} ${removable_drives[@]}; do
          if [[ "$drive" == "$tgtdrive" ]] && match="yes" ; then
            if confirm_format $tgtdrive ; then
              format_confirmed="yes"
              break
            else
              tgtdrive="undefined"
              read -p "You may select another disk. Press Enter to continue." _
            fi
          fi
        done
        if [[ "$match" == "no" ]]; then
          tgtdrive="undefined"
          read -p "Invalid choice. Press Enter to continue." _
        fi
    done
    clear
    chvt 1
else
    tgtdrive=`echo ${drives} | sed -e "s/^\s*//" -e "s/\s*$//"`
fi

if [ "$format_confirmed" != "yes" ] ; then
  exec < /dev/tty3 > /dev/tty3 2>&1
  chvt 3
  if ! confirm_format $tgtdrive ; then
      clear
      echo
      echo '********************************************************************'
      echo '*                            E R R O R                             *'
      echo '*                                                                  *'
      echo '*           Disk $tgtdrive contains active partition(s).           *'
      echo '*        Installation cannot continue without confirmation.        *'
      echo '*                                                                  *'
      echo '********************************************************************'
      echo
      read -p "Press Enter to restart: " _
      reboot
  fi
  chvt 1
fi

# verify tgtdrive is at least 41GB
tgtdrivesize=$(( $(cat "/sys/class/block/${tgtdrive}/size") / 2 / 1024 ))
if [ $tgtdrivesize -lt 41984 ]; then
    exec < /dev/tty3 > /dev/tty3 2>&1
    chvt 3
    clear
    echo
    echo '********************************************************************'
    echo '*                            E R R O R                             *'
    echo '*                                                                  *'
    echo '*  Your disk is under 41GB in size. Installation cannot continue.  *'
    echo '*             Restart installation with a larger disk.             *'
    echo '*                                                                  *'
    echo '********************************************************************'
    echo
    read -p "Press Enter to restart: " _
    reboot
fi

# paths in /dev have "/" instead of "!" for cciss devices
tgtdrive=$(echo $tgtdrive | sed -e 's/!/\//')

# source
if test -e /dev/disk/by-label/OpenStack_Fuel; then
    echo "harddrive --partition=LABEL=OpenStack_Fuel --dir=/" > /tmp/source.ks
elif test -e /dev/disk/by-uuid/will_be_substituted_with_actual_uuid; then
    echo "harddrive --partition=UUID=will_be_substituted_with_actual_uuid --dir=/" > /tmp/source.ks
else
    echo "cdrom" > /tmp/source.ks
fi

vgdisplay -c | cut -d':' -f1 | xargs vgremove -ff
dd if=/dev/zero of=/dev/${tgtdrive} bs=10M count=10
sleep 3
hdparm -z /dev/${tgtdrive}
parted -s /dev/${tgtdrive} mklabel gpt
parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary 0% 24
parted -s /dev/${tgtdrive} set 1 bios_grub on
parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary fat16 24 224
parted -s /dev/${tgtdrive} set 2 boot on
parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary 224 424
sleep 3
hdparm -z /dev/${tgtdrive}

# partition

# This adds support for the p seperator required for cciss devices
if echo ${tgtdrive} | grep -q -e cciss ; then
    bootdev=${tgtdrive}p
else
    bootdev=${tgtdrive}
fi

cat << EOF > /tmp/partition.ks
part /boot --onpart=/dev/${bootdev}3
part /boot/efi --onpart=/dev/${bootdev}2
part pv.001 --ondisk=${tgtdrive} --size=1 --grow
part pv.002 --ondisk=${tgtdrive} --size=20000
volgroup os pv.001
volgroup docker pv.002
logvol swap --vgname=os --recommended --name=swap
logvol / --vgname=os --size=10000 --name=root --fstype=ext4
logvol /var --vgname=os --size=10000 --name=var --fstype=ext4
logvol /var/log --vgname=os --size=4000 --grow --name=varlog --fstype=ext4
EOF



# bootloader
echo "bootloader --driveorder=${tgtdrive} --append=' biosdevname=0 crashkernel=none'" > /tmp/bootloader.ks

# Anaconda can not install grub 0.97 on disks which are >4T.
# The reason is that grub does not support such large geometries
# and it simply thinks that the cylinder number has negative value.
# Here we just set geometry manually so that grub thinks that disk
# size is equal to 1G.
# 130 cylinders * (16065 * 512 = 8225280 bytes) = 1G
echo "%post --nochroot --log=/mnt/sysimage/root/anaconda-post-partition.log" > /tmp/post_partition.ks
echo "echo \"device (hd0) /dev/${tgtdrive}\" >> /tmp/grub.script" >> /tmp/post_partition.ks
echo "echo \"geometry (hd0) 130 255 63\" >> /tmp/grub.script" >> /tmp/post_partition.ks
echo "echo \"root (hd0,2)\" >> /tmp/grub.script" >> /tmp/post_partition.ks
echo "echo \"install /grub/stage1 (hd0) /grub/stage2 p /grub/grub.conf\" >> /tmp/grub.script" >> /tmp/post_partition.ks
echo "echo quit >> /tmp/grub.script" >> /tmp/post_partition.ks
echo "cat /tmp/grub.script | chroot /mnt/sysimage /sbin/grub --no-floppy --batch" >> /tmp/post_partition.ks
echo "%end" >> /tmp/post_partition.ks
%end





# POSTINSTALL SECTIONS
# HERE ARE COMMANDS THAT WILL BE LAUNCHED JUST AFTER
# INSTALLATION ITSELF COMPLETED


# Parse /proc/cmdline and save for next steps
%post --log=/root/anaconda-parse-cmdline.log
#!/bin/bash
set -x

# Parse cmdline to alter keys which contains dot in their names
# Such keys can't be used as variables in bash,
# so every dot is replaced with double underscore.
# Double underscore needed to avoid possible naming collisions.
for item in $(cat /proc/cmdline); do
  if [[ "${item}" =~ '=' ]]; then
    key="${item%%=*}"
    value="${item#*=}"
  else
    key="${item}"
    value='yes'
  fi
  key="${key//\./__}"
  value="${value:-'yes'}"
  echo "${key}=${value}" >> /root/anaconda.cmdline.vars
done

source /root/anaconda.cmdline.vars

if [[ ! -z $ifname ]]; then
  echo "adminif=$(udevadm info --query=property -p /sys/class/net/${ifname%%:*} | \
    awk -F\= '$1 == "ID_NET_NAME_ONBOARD" {s=$2; exit}; $1 == "ID_NET_NAME_SLOT" {s=$2; exit}; $1 == "ID_NET_NAME_PATH" {s=$2; next}; END {print s}')" >> /root/anaconda.cmdline.vars
fi

%end





# Mount installation media in chroot
%post --nochroot --log=/mnt/sysimage/root/anaconda-post-before-chroot.log
#!/bin/bash
set -x

source "/mnt/sysimage/root/anaconda.cmdline.vars"

SOURCE="/mnt/sysimage/tmp/source"

mkdir -p "${SOURCE}"

case "${repo}" in
  nfs:*)
    nfs_url="${repo#nfs:}"
    mount -t nfs "${nfs_url}" "${SOURCE}"
  ;;
  *)
    if [ -d "/mnt/source" ]; then
      mount -o bind "/mnt/source" "${SOURCE}"
    fi
  ;;
esac
%end





%post --log=/root/anaconda-post-configure-repos.log
#!/bin/bash
set -x

# Mounting installation source
SOURCE=/tmp/source
FS=/tmp/fs

mkdir -p ${SOURCE}
mkdir -p ${FS}

if test -e /dev/disk/by-label/OpenStack_Fuel; then
    mount /dev/disk/by-label/OpenStack_Fuel ${SOURCE}
elif test -e /dev/disk/by-uuid/will_be_substituted_with_actual_uuid; then
    mount /dev/disk/by-uuid/will_be_substituted_with_actual_uuid ${FS}
    mount -o loop ${FS}/nailgun.iso ${SOURCE}
fi

# this file is provided by fuel-openstack-metadata package
OPENSTACK_VERSION=`cat /etc/fuel_openstack_version`

# ----------------------
# UNPACKING REPOSITORIES
# ----------------------

wwwdir="/var/www/nailgun"
repodir="${wwwdir}/${OPENSTACK_VERSION}"

# Copying Centos files
mkdir -p ${repodir}/centos/x86_64
mkdir -p ${repodir}/mos-centos/x86_64
cp -r ${SOURCE}/images ${repodir}/centos/x86_64
cp -r ${SOURCE}/isolinux ${repodir}/centos/x86_64
cp -r ${SOURCE}/repodata ${repodir}/centos/x86_64
cp -r ${SOURCE}/Packages ${repodir}/centos/x86_64
cp -r ${SOURCE}/mos-centos/repodata ${repodir}/mos-centos/x86_64
cp -r ${SOURCE}/mos-centos/Packages ${repodir}/mos-centos/x86_64
cp -r ${SOURCE}/extra-repos ${repodir}/
cp ${SOURCE}/.treeinfo ${repodir}/centos/x86_64

# Copying Ubuntu files
mkdir -p ${repodir}/ubuntu/x86_64/images
cp -r ${SOURCE}/ubuntu/dists ${repodir}/ubuntu/x86_64
cp -r ${SOURCE}/ubuntu/pool ${repodir}/ubuntu/x86_64

# We do not ship debian-installer kernel and initrd on ISO.
# But we still need to be able to create ubuntu cobbler distro
# which requires kernel and initrd to be available. So, we
# just touch these files to work around cobbler's limitation.
touch ${repodir}/ubuntu/x86_64/images/linux
touch ${repodir}/ubuntu/x86_64/images/initrd.gz

# make links for backward compatibility
ln -s ${repodir}/centos ${wwwdir}/centos
ln -s ${repodir}/ubuntu ${wwwdir}/ubuntu
#Make a symlink for mos-centos in /var/www/nailgun in iso/ks.template
ln -s ${repodir}/mos-centos ${wwwdir}/mos-centos
ln -s ${repodir}/extra-repos ${wwwdir}/extra-repos

mkdir -p ${wwwdir}/targetimages

cp ${SOURCE}/send2syslog.py /bin/send2syslog.py
mkdir -p /var/lib/hiera
touch /var/lib/hiera/common.yaml /etc/puppet/hiera.yaml

# Prepare local repository specification
rm /etc/yum.repos.d/CentOS*.repo
cp ${SOURCE}/extra-repos/extra.repo /etc/yum.repos.d/
cat > /etc/yum.repos.d/nailgun.repo << EOF
[nailgun]
name=Nailgun Local Repo
baseurl=file:/var/www/nailgun/${OPENSTACK_VERSION}/centos/x86_64
gpgcheck=0
[mos]
name=MOS Local Repo
baseurl=file:/var/www/nailgun/${OPENSTACK_VERSION}/mos-centos/x86_64
gpgcheck=0
EOF
%end





%post --log=/root/anaconda-post-configure-sysconfig.log
#!/bin/bash
set -x

source "/root/anaconda.cmdline.vars"
SOURCE=/tmp/source

# Set correct docker volume group
echo "VG=docker" >> /etc/sysconfig/docker-storage-setup

# Disable create iptables rules by docker
echo "DOCKER_NETWORK_OPTIONS=--iptables=false" > /etc/sysconfig/docker-network

# Disable subscription-manager plugins
sed -i 's/^enabled.*/enabled=0/' /etc/yum/pluginconf.d/product-id.conf || :
sed -i 's/^enabled.*/enabled=0/' /etc/yum/pluginconf.d/subscription-manager.conf || :

# Disable GSSAPI in ssh server config
sed -i -e "/^\s*GSSAPICleanupCredentials yes/d" -e "/^\s*GSSAPIAuthentication yes/d" /etc/ssh/sshd_config

# Enable MOTD banner in sshd
sed -i -e "s/^\s*PrintMotd no/PrintMotd yes/g" /etc/ssh/sshd_config

# Add note regarding local repos creation to MOTD
cat >> /etc/motd << EOF

All environments use online repositories by default.
Use the following commands to create local repositories
on master node and change default repository settings:

* CentOS: fuel-mirror (see --help for options)
* Ubuntu: fuel-mirror (see --help for options)

Please refer to the following guide for more information:
https://docs.mirantis.com/openstack/fuel/fuel-7.0/reference-architecture.html#fuel-rep-mirror

EOF

# Install bootstrap_admin_node.sh and enabling it
install -m 0777 -D ${SOURCE}/bootstrap_admin_node.sh /usr/local/sbin/bootstrap_admin_node.sh
echo "ENABLED=1" > /etc/sysconfig/bootstrap_admin_node

# Copying version.yaml file. It contains COMMIT_SHA of last commit.
RELEASE=$(awk '/release/{gsub(/"/, "");print $2}' ${SOURCE}/version.yaml)
mkdir -p /etc/nailgun /etc/fuel/${RELEASE} /etc/fuel/release_versions
cp ${SOURCE}/version.yaml /etc/nailgun/version.yaml
cp ${SOURCE}/version.yaml /etc/fuel/${RELEASE}/version.yaml
ln -s /etc/fuel/${RELEASE}/version.yaml /etc/fuel/version.yaml
cp ${SOURCE}/version.yaml /etc/fuel/release_versions/`cat  ${SOURCE}/openstack_version`.yaml

# Generete Fuel UUID
uuidgen > /etc/fuel/fuel-uuid

# Prepare bootstrap_admin_node config
cat > /etc/fuel/bootstrap_admin_node.conf << EOF
#Set to yes to run Fuel Setup
#Set to no to accept default settings
ADMIN_INTERFACE=${adminif}
showmenu=${showmenu:-no}
wait_for_external_config=${wait_for_external_config:-no}
EOF

# Prepare custom /etc/issue logon banner and script for changing IP in it
# We can have several interface naming schemes applied and several interface
# UI will listen on
ipstr=""
NL=$'\n'
for ip in `ip -o -4 a | grep -e "e[nt][hopsx].*" | awk '{print \$4 }' | cut -d/ -f1`; do
  ipstr="${ipstr}https://${ip}:8443${NL}"
done
cat > /etc/issue <<EOF
#########################################
#       Welcome to the Fuel server      #
#########################################
Server is running on \m platform

Fuel UI is available on:
$ipstr
Default administrator login:    root
Default administrator password: r00tme

Default Fuel UI login: admin
Default Fuel UI password: admin

Please change root password on first login.

EOF

######### OPNFV addition BEGIN ############
# Copy data into /opt/opnfv
# TODO: This ought to be a package instead!
mkdir -p /opt/opnfv
cp -r ${SOURCE}/opnfv /opt
cp ${SOURCE}/gitinfo.txt /
######### OPNFV addition END ############

# Unmounting source
umount -f ${SOURCE}
rm -rf ${SOURCE}

umount -f ${FS} || true
rm -rf ${FS}

echo "tos orphan 7" >> /etc/ntp.conf

# Disabling splash
sed -i --follow-symlinks -e '/^\slinux16/ s/rhgb/debug/' /boot/grub2/grub.cfg

# Copying default bash settings to the root directory
cp -f /etc/skel/.bash* /root/

# Blacklist i2c_piix4 module for VirtualBox so it does not create kernel errors
(virt-what | fgrep -q "virtualbox") && echo "blacklist i2c_piix4" > /etc/modprobe.d/blacklist-i2c-piix4.conf

# Blacklist intel_rapl module for VirtualBox so it does not create kernel errors
(virt-what | fgrep -q "virtualbox") && echo "blacklist intel_rapl" > /etc/modprobe.d/blacklist-intel-rapl.conf

# Disable sshd until after Fuel Setup if not running on VirtualBox
# TODO(mattymo): Remove VBox exception after LP#1487047 is fixed
(virt-what | fgrep -q "virtualbox") || systemctl disable sshd

%end





%post --log=/root/anaconda-post-configure-autologon.log
#!/bin/bash
set -x

# Enable once root autologin for initial setup
mkdir -p /etc/systemd/system/getty@tty1.service.d/
cat > /etc/systemd/system/getty@tty1.service.d/autologin.conf << 'EOF'
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin root --noclear %I 115200 linux
EOF

# Exec bootstrap_admin_node.sh if autologin enabled
cat >> /root/.bashrc << 'EOF'
if [[ "$(tty)" == "/dev/tty1" && -f /etc/systemd/system/getty@tty1.service.d/autologin.conf ]]; then
	rm -Rf "/etc/systemd/system/getty@tty1.service.d"
	/bin/systemctl daemon-reload
	if [ -x /usr/local/sbin/bootstrap_admin_node.sh ]; then
		exec /usr/local/sbin/bootstrap_admin_node.sh
	fi
fi
EOF
%end


%post --nochroot --log=/mnt/sysimage/root/anaconda-post-interface-settings.log
#!/bin/bash
set -x

source "/mnt/sysimage/root/anaconda.cmdline.vars"

if [[ ! -z $adminif ]]; then
  rm -f /mnt/sysimage/etc/sysconfig/network-scripts/ifcfg-${ifname%%:*}
  sed "s/${ifname%%:*}/${adminif}/g" \
    /etc/sysconfig/network-scripts/ifcfg-${ifname%%:*} > \
    /mnt/sysimage/etc/sysconfig/network-scripts/ifcfg-${adminif}
fi
%end