<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE profile>
<profile xmlns="http://www.suse.com/1.0/yast2ns" xmlns:config="http://www.suse.com/1.0/configns">
  <general>
    <mode>
      <confirm config:type="boolean">false</confirm>
      <final_reboot config:type="boolean">true</final_reboot>
    </mode>
  </general>
  <networking>
    <dns>
      <hostname>snapshot-ipv4-dhcp-el7</hostname>
      <resolv_conf_policy>auto</resolv_conf_policy>
      <searchlist config:type="list">
        <search>snap.example.com</search>
      </searchlist>
    </dns>
    <interfaces config:type="list">
      <interface>
        <bootproto>dhcp</bootproto>
        <device>eth0</device>
        <usercontrol>no</usercontrol>
        <startmode>auto</startmode>
      </interface>
    </interfaces>
  </networking>
  <ntp-client>
    <configure_dhcp config:type="boolean">false</configure_dhcp>
    <peers config:type="list">
      <peer>
        <address>0.opensuse.pool.ntp.org</address>
        <initial_sync config:type="boolean">true</initial_sync>
        <options></options>
        <type>server</type>
      </peer>
    </peers>
    <start_at_boot config:type="boolean">true</start_at_boot>
    <start_in_chroot config:type="boolean">true</start_in_chroot>
  </ntp-client>
  zerombr
clearpart --all    --initlabel
part /boot --fstype ext3 --size=100 --asprimary
part /     --fstype ext3 --size=1024 --grow
part swap  --recommended
  <runlevel>
    <default>3</default>
    <services config:type="list">
      <service>
        <service_name>sshd</service_name>
        <service_status>enable</service_status>
      </service>
    </services>
  </runlevel>
  <software>
    <patterns config:type="list">
      <pattern>Minimal</pattern>
    </patterns>
    <packages config:type="list">
      <package>lsb-release</package>
      <package>openssh</package>
      <package>rubygem-puppet</package>
    </packages>
  </software>
  <users config:type="list">
    <user>
      <username>root</username>
      <encrypted config:type="boolean">true</encrypted>
      <fullname>root</fullname>
      <gid>0</gid>
      <home>/root</home>
      <shell>/bin/bash</shell>
      <uid>0</uid>
      <user_password>$1$rtd8Ub7R$5Ohzuy8WXlkaK9cA2T1wb0</user_password>
    </user>
  </users>
  <scripts>
    <chroot-scripts config:type="list">
      <script>
        <filename>cp-resolv.sh</filename>
        <chrooted config:type="boolean">false</chrooted>
        <interpreter>shell</interpreter>
        <notification>Copying resolv.conf into chroot ...</notification>
        <source><![CDATA[
cp /etc/resolv.conf /mnt/etc
]]>
        </source>
      </script>
      <script>
        <filename>foreman.sh</filename>
        <chrooted config:type="boolean">true</chrooted>
        <interpreter>shell</interpreter>
        <notification>Setting up Puppet / Foreman ...</notification>
        <source><![CDATA[
/bin/hostname snapshot-ipv4-dhcp-el7



# Select package manager for the OS (sets the $PKG_MANAGER* variables)
if [ -z "$PKG_MANAGER" ]; then
  if [ -f /etc/os-release ] ; then
    . /etc/os-release
  fi
  
  if [ "${NAME%.*}" = 'FreeBSD' ]; then
    PKG_MANAGER='pkg'
    PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
    PKG_MANAGER_REMOVE="${PKG_MANAGER} delete -y"
    PKG_MANAGER_UPGRADE="${PKG_MANAGER} install -y"
  elif [ -f /etc/fedora-release -o -f /etc/redhat-release -o -f /etc/amazon-linux-release -o -f /etc/system-release ]; then
    PKG_MANAGER='dnf'
    if [ -f /etc/redhat-release -a "${VERSION_ID%.*}" -le 7 ]; then
      PKG_MANAGER='yum'
    elif [ -f /etc/system-release ]; then
      PKG_MANAGER='yum'
    fi
    PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
    PKG_MANAGER_REMOVE="${PKG_MANAGER} remove -y"
    PKG_MANAGER_UPGRADE="${PKG_MANAGER} upgrade -y"
  elif [ -f /etc/debian_version ]; then
    PKG_MANAGER='apt-get'
    PKG_MANAGER_INSTALL="${PKG_MANAGER} -o 'Dpkg::Options::=--force-confdef' -o 'Dpkg::Options::=--force-confold' install -y"
    PKG_MANAGER_REMOVE="${PKG_MANAGER} remove -y"
    PKG_MANAGER_UPGRADE="${PKG_MANAGER} -o 'Dpkg::Options::=--force-confdef' -o 'Dpkg::Options::=--force-confold' -o APT::Get::Upgrade-Allow-New='true' upgrade -y"
  elif [ -f /etc/arch-release ]; then
    PKG_MANAGER='pacman'
    PKG_MANAGER_INSTALL="${PKG_MANAGER} --noconfirm -S"
    PKG_MANAGER_REMOVE="${PKG_MANAGER} --noconfirm -R"
    PKG_MANAGER_UPGRADE="${PKG_MANAGER} --noconfirm -S"
  elif [ x$ID = xopensuse-tumbleweed -o x$ID = xsles ]; then
    PKG_MANAGER='zypper'
    PKG_MANAGER_INSTALL="${PKG_MANAGER} --non-interactive install --auto-agree-with-licenses"
    PKG_MANAGER_REMOVE="${PKG_MANAGER} --non-interactive remove"
    PKG_MANAGER_UPGRADE="${PKG_MANAGER} --non-interactive update"
  fi
fi



echo "blacklist amodule" >> /etc/modprobe.d/blacklist.conf



if [ -f /usr/bin/dnf ]; then
  dnf -y install puppet
else
  yum -t -y install puppet
fi

cat > /etc/puppet/puppet.conf << EOF
[main]
vardir = /var/lib/puppet
logdir = /var/log/puppet
rundir = /var/run/puppet
ssldir = \$vardir/ssl

[agent]
pluginsync      = true
report          = true
certname        = snapshot-ipv4-dhcp-el7

EOF


puppet_unit=puppet
/usr/bin/systemctl list-unit-files | grep -q puppetagent && puppet_unit=puppetagent
/usr/bin/systemctl enable ${puppet_unit}

# export a custom fact called 'is_installer' to allow detection of the installer environment in Puppet modules
export FACTER_is_installer=true
# passing a non-existent tag like "no_such_tag" to the puppet agent only initializes the node
# You can select specific tag(s) with the "run-puppet-in-installer-tags" parameter
# or set a full puppet run by setting "run-puppet-in-installer" = true
echo "Performing initial puppet run for --tags no_such_tag"
/usr/bin/puppet agent --config /etc/puppet/puppet.conf --onetime --tags no_such_tag  --no-daemonize




if [ -x /usr/bin/curl ]; then
  /usr/bin/curl -o /dev/null -H 'Content-Type: text/plain' --noproxy \* --silent 'http://foreman.example.com/unattended/built'
elif [ -x /usr/bin/wget ]; then
  /usr/bin/wget -q -O /dev/null --method POST --header 'Content-Type: text/plain' --no-proxy 'http://foreman.example.com/unattended/built'
else
  wget -q -O /dev/null --header 'Content-Type: text/plain' 'http://foreman.example.com/unattended/built'
fi

if [ -x "$(command -v subscription-manager)" ] ; then
  subscription-manager facts --update
fi

rm /etc/resolv.conf
]]>
        </source>
      </script>
    </chroot-scripts>
  </scripts>
  <keyboard>
    <keymap>english-us</keymap>
  </keyboard>
  <timezone>
    <hwclock>UTC</hwclock>
    <timezone>Etc/UTC</timezone>
  </timezone>
  <add-on>
    <add_on_products config:type="list">
      <listentry>
        <media_url><![CDATA[http://download.opensuse.org/repositories/systemsmanagement:/puppet/SLE_7/]]></media_url>
        <name>systemsmanagement_puppet</name>
        <product>systemsmanagement_puppet</product>
        <product_dir>/</product_dir>
        <signature-handling>
          <accept_non_trusted_gpg_key>
            <all config:type="boolean">false</all>
            <keys config:type="list">
              <keyid>2ABFA143A0E46E11</keyid>
            </keys>
          </accept_non_trusted_gpg_key>
          <import_gpg_key>
            <all config:type="boolean">false</all>
            <keys config:type="list">
              <keyid>2ABFA143A0E46E11</keyid>
            </keys>
          </import_gpg_key>
        </signature-handling>
      </listentry>
      <listentry>
        <media_url><![CDATA[http://download.opensuse.org/repositories/devel:languages:ruby:backports/SLE_7/]]></media_url>
        <name>devel_languages_ruby_backports</name>
        <product>devel_languages_ruby_backports</product>
        <product_dir>/</product_dir>
        <signature-handling>
          <accept_non_trusted_gpg_key>
            <all config:type="boolean">false</all>
            <keys config:type="list">
              <keyid>9AF0C9A20E9AF123</keyid>
            </keys>
          </accept_non_trusted_gpg_key>
          <import_gpg_key>
            <all config:type="boolean">false</all>
            <keys config:type="list">
              <keyid>9AF0C9A20E9AF123</keyid>
            </keys>
          </import_gpg_key>
        </signature-handling>
      </listentry>
      <listentry>
<!-- you have to update the next line with the actual URL of your SDK -->
        <media_url>http://<your_server_here>/iso/suse/SDK/7.0/x86_64/</media_url>
        <product>SuSE-Linux-SDK</product>
        <product_dir>/</product_dir>
        <name>SuSE-Linux-SDK</name>
      </listentry>
    </add_on_products>
  </add-on>
</profile>
