crowbar/crowbar-core

View on GitHub
chef/cookbooks/provisioner/templates/default/autoyast.xml.erb

Summary

Maintainability
Test Coverage
<?xml version="1.0"?>
<!DOCTYPE profile>
<profile xmlns="http://www.suse.com/1.0/yast2ns" xmlns:config="http://www.suse.com/1.0/configns">
  <deploy_image>
    <image_installation config:type="boolean">false</image_installation>
  </deploy_image>
  <general>
    <ask-list config:type="list"/>
    <mode>
      <confirm config:type="boolean">false</confirm>
      <final_halt config:type="boolean">false</final_halt>
      <final_reboot config:type="boolean">false</final_reboot>
      <halt config:type="boolean">false</halt>
      <second_stage config:type="boolean">true</second_stage>
    </mode>
    <mouse>
      <id>none</id>
    </mouse>
    <proposals config:type="list"/>
    <signature-handling>
      <accept_file_without_checksum config:type="boolean">true</accept_file_without_checksum>
      <accept_non_trusted_gpg_key config:type="boolean">true</accept_non_trusted_gpg_key>
      <accept_unknown_gpg_key config:type="boolean">true</accept_unknown_gpg_key>
      <accept_unsigned_file config:type="boolean">true</accept_unsigned_file>
      <accept_verification_failed config:type="boolean">true</accept_verification_failed>
      <import_gpg_key config:type="boolean">true</import_gpg_key>
    </signature-handling>
    <storage/>
  </general>
  <add-on>
    <add_on_products config:type="list">
    <% @repos.keys.sort.each do |name| %>
      <listentry>
        <name><%= name %></name>
        <product><%= name %></product>
        <product_dir>/</product_dir>
        <media_url><%= @repos[name][:url] %></media_url>
        <% unless @repos[name][:priority] == 99 -%>
        <priority><%= @repos[name][:priority] %></priority>
        <% end -%>
        <!-- See bnc#787157 for discussion on ask_on_error -->
        <ask_on_error config:type="boolean"><%= @repos[name][:ask_on_error] || 'false' %></ask_on_error>
      </listentry>
    <% end %>
    </add_on_products>
  </add-on>
  <users config:type="list">
      <user>
         <username>root</username>
<% if @rootpw_hash != "" %>
         <user_password><%= @rootpw_hash %></user_password>
         <encrypted config:type="boolean">true</encrypted>
<% end %>
         <forename/>
         <surname/>
      </user>
      <user>
        <username>glance</username>
        <user_password>!</user_password>
        <encrypted config:type="boolean">true</encrypted>
        <uid>200</uid>
        <gid>200</gid>
        <home>/var/lib/glance</home>
        <shell>/sbin/nologin</shell>
      </user>
      <user>
        <username>qemu</username>
        <user_password>!</user_password>
        <encrypted config:type="boolean">true</encrypted>
        <uid>201</uid>
        <gid>201</gid>
        <home>/</home>
        <shell>/sbin/nologin</shell>
      </user>
      <user>
        <username>cinder</username>
        <user_password>!</user_password>
        <encrypted config:type="boolean">true</encrypted>
        <uid>203</uid>
        <gid>203</gid>
        <home>/var/lib/cinder</home>
        <shell>/sbin/nologin</shell>
      </user>
  </users>
  <groups config:type="list">
    <!-- for making HA on shared NFS backend storage work -->
    <group>
      <gid>200</gid>
      <groupname>glance</groupname>
      <group_password>x</group_password>
      <userlist>glance</userlist>
    </group>
    <group>
      <gid>201</gid>
      <groupname>qemu</groupname>
      <group_password>x</group_password>
      <userlist/>
    </group>
    <group>
      <gid>202</gid>
      <groupname>kvm</groupname>
      <group_password>x</group_password>
      <userlist>qemu</userlist>
    </group>
    <group>
      <gid>203</gid>
      <groupname>cinder</groupname>
      <group_password>x</group_password>
      <userlist>cinder</userlist>
    </group>
  </groups>
  <networking>
    <keep_install_network config:type="boolean">true</keep_install_network>
    <dns>
      <dhcp_hostname config:type="boolean">true</dhcp_hostname>
      <domain><%= @domain_name %></domain>
      <hostname><%= @node_hostname %></hostname>
<% unless @nameservers.empty? -%>
      <nameservers config:type="list">
  <% @nameservers.each do |nameserver| -%>
        <nameserver><%= nameserver %></nameserver>
  <% end -%>
      </nameservers>
<% end -%>
      <resolv_conf_policy>auto</resolv_conf_policy>
      <write_hostname config:type="boolean">false</write_hostname>
    </dns>
    <managed config:type="boolean">false</managed>
    <routing>
      <ip_forward config:type="boolean">false</ip_forward>
    </routing>
  </networking>
  <partitioning config:type="list">
    <% if @raid_type == "single" -%>
      <drive>
        <% if @boot_device %>
          <device>/dev/<%= @boot_device %></device>
        <% end %>
        <initialize config:type="boolean">true</initialize>
        <type config:type="symbol">CT_DISK</type>
        <disklabel>gpt</disklabel>
        <partitions config:type="list">
          <% if @use_uefi %>
          <partition>
            <create config:type="boolean">true</create>
            <format config:type="boolean">true</format>
            <filesystem config:type="symbol">vfat</filesystem>
            <partition_id config:type="integer">259</partition_id>
            <mount>/boot/efi</mount>
            <size>128M</size>
          </partition>
          <% end %>
          <partition>
            <create config:type="boolean">true</create>
            <partition_id config:type="integer">263</partition_id>
            <size>10M</size>
          </partition>
          <partition>
            <create config:type="boolean">true</create>
            <filesystem config:type="symbol">swap</filesystem>
            <format config:type="boolean">true</format>
            <mount>swap</mount>
            <size>auto</size>
          </partition>
          <partition>
            <create config:type="boolean">true</create>
            <format config:type="boolean">true</format>
            <mount>/</mount>
            <size>auto</size>
          </partition>
        </partitions>
        <use>all</use>
      </drive>
    <% else -%>
      <% @raid_disks.each do |disk| -%>
        <drive>
          <device><%= disk %></device>
          <type config:type="symbol">CT_DISK</type>
          <initialize config:type="boolean">true</initialize>
          <partitions config:type="list">
            <% if @use_uefi %>
            <partition>
              <create config:type="boolean">true</create>
              <format config:type="boolean">true</format>
              <filesystem config:type="symbol">vfat</filesystem>
              <partition_id config:type="integer">259</partition_id>
              <mount>/boot/efi</mount>
              <size>128M</size>
            </partition>
            <% end %>
            <partition>
              <create config:type="boolean">true</create>
              <partition_id config:type="integer">263</partition_id>
              <size>10M</size>
            </partition>
            <partition>
              <mount>swap</mount>
              <size>auto</size>
            </partition>
            <partition>
              <partition_id config:type="integer">253</partition_id>
              <format config:type="boolean">false</format>
              <raid_name>/dev/md0</raid_name>
              <raid_type>raid</raid_type>
              <size>200M</size>
            </partition>
            <partition>
              <partition_id config:type="integer">253</partition_id>
              <format config:type="boolean">false</format>
              <raid_name>/dev/md1</raid_name>
              <raid_type>raid</raid_type>
              <size>max</size>
            </partition>
          </partitions>
          <use>all</use>
        </drive>
      <% end -%>
      <drive>
        <device>/dev/md</device>
        <type config:type="symbol">CT_MD</type>
        <initialize config:type="boolean">true</initialize>
        <partitions config:type="list">
          <partition>
            <filesystem config:type="symbol">ext3</filesystem>
            <format config:type="boolean">true</format>
            <mount>/boot</mount>
            <partition_id config:type="integer">131</partition_id>
            <partition_nr config:type="integer">0</partition_nr>
            <raid_options>
              <raid_type>raid1</raid_type>
            </raid_options>
          </partition>
          <partition>
            <filesystem config:type="symbol"><%= @default_fs %></filesystem>
            <format config:type="boolean">true</format>
            <mount>/</mount>
            <partition_id config:type="integer">131</partition_id>
            <partition_nr config:type="integer">1</partition_nr>
            <raid_options>
              <raid_type><%= @raid_type %></raid_type>
            </raid_options>
          </partition>
        </partitions>
        <use>all</use>
      </drive>
    <% end -%>
  </partitioning>
  <timezone>
    <hwclock>UTC</hwclock>
    <timezone><%=@timezone%></timezone>
  </timezone>
  <% if @platform == "suse" && @target_platform_version.to_f >= 12 || @platform == "opensuse" -%>
  <services-manager>
    <services>
      <enable config:type="list">
        <service>sshd</service>
      </enable>
    </services>
  </services-manager>
  <% end %>
  <scripts>
    <% if @platform == "suse" && @target_platform_version.to_f >= 12 || @platform == "opensuse" -%>
      <pre-scripts config:type="list">
        <script>
            <debug config:type="boolean">true</debug>
            <filename>filesystem_default</filename>
            <source>
<![CDATA[
# Change the default FS YaST will use for partitions
sed -i s/"^[[:space:]]*DEFAULT_FS=.*"/DEFAULT_FS=\"<%= @default_fs %>\"/ /etc/sysconfig/storage
]]>
            </source>
        </script>
      </pre-scripts>
    <% end %>
    <chroot-scripts config:type="list">
        <script>
            <chrooted config:type="boolean">true</chrooted>
            <debug config:type="boolean">true</debug>
            <filename>crowbar_post</filename>
            <source>
<![CDATA[
export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): '
HTTP_SERVER="<%= @admin_node_ip %>:<%= @web_port %>"
HOSTNAME="<%= @node_fqdn %>"

cat <<EOF > /etc/crowbarrc
[default]
server = <%= @crowbar_protocol %>://<%= @admin_node_ip %>
username = <%= @crowbar_client_username %>
password = <%= @crowbar_client_password %>
<% unless @crowbar_verify_ssl %>
verify_ssl = 0
<% end %>
EOF

mkdir -p /root/.ssh
chmod 700 /root/.ssh
if ! curl -s -o /root/.ssh/authorized_keys.wget \
    http://$HTTP_SERVER/authorized_keys ||\
    grep -q "Error 404" /root/.ssh/authorized_keys.wget; then
    rm -f /root/.ssh/authorized_keys.wget
else
    chmod 644 /root/.ssh/authorized_keys
    cat /root/.ssh/authorized_keys.wget >> /root/.ssh/authorized_keys
    rm -f /root/.ssh/authorized_keys.wget
fi

curl -s -o /usr/sbin/crowbar_join <%= @crowbar_join %>
chmod +x /usr/sbin/crowbar_join

mkdir -p /var/log/crowbar
crowbarctl restricted transition $HOSTNAME "installed"

# Wait for DHCP to update - this is mainly for virtual environments or really large deploys
sleep 30
sync
]]>
            </source>
        </script>
    </chroot-scripts>
    <init-scripts config:type="list">
      <!-- bugfix bnc#886238: https://bugzilla.novell.com/show_bug.cgi?id=886238 -->
      <script>
       <filename>autoyast_set_hostentries.sh</filename>
       <source>
        <![CDATA[
        echo "<%= @node_ip %> <%= @node_fqdn %> <%= @node_hostname %>" >> /etc/hosts
        ]]>
       </source>
      </script>
      <!-- /bugfix bnc#886238: https://bugzilla.novell.com/show_bug.cgi?id=886238 -->
      <script>
        <source>
<![CDATA[
/usr/sbin/crowbar_join --setup --verbose
]]>
        </source>
      </script>
    </init-scripts>
  </scripts>
  <software>
    <packages config:type="list">
      <package>autoyast2-installation</package>
<% if @architecture == "x86_64" -%>
      <package>biosdevname</package>
<% end -%>
<% if @platform == "suse" && @cpu_model == "intel" -%>
      <package>ucode-intel</package>
<% elsif @platform == "suse" && @cpu_model == "amd" -%>
      <package>ucode-amd</package>
<%end -%>
      <package>netcat-openbsd</package>
      <package>ruby2.1-rubygem-chef</package>
      <package>ruby2.1-rubygem-crowbar-client</package>
  <% if @platform == "suse" && @target_platform_version == "11.3" -%>
      <package>suse-sle11-openstack-cloud-release</package>
  <% elsif @platform == "suse" && @target_platform_version.to_f >= 12.1 -%>
      <package>suse-openstack-cloud-crowbar-release</package>
      <package>supportutils-plugin-suse-openstack-cloud</package>
  <% end -%>
<% if @platform == "opensuse" -%>
      <package>rsyslog</package>
<% end -%>
<% @packages.each do |package| -%>
      <package><%= package %></package>
<% end -%>
    </packages>
    <patterns config:type="list">
<% if @platform == "suse" -%>
      <pattern>Minimal</pattern>
<% elsif @platform == "opensuse" -%>
      <pattern>enhanced_base</pattern>
      <pattern>sw_management</pattern>
      <!-- not required, might be nice <pattern>yast2_basis</pattern> -->
<% end -%>
      <pattern>base</pattern>
    </patterns>
  </software>
</profile>