#version=RHEL7
# System authorization information
auth --enableshadow --passalgo=sha512
# Use text install
text
repo --name="AppStream" --baseurl=file:///run/install/repo/AppStream
# Use CDROM installation media
cdrom
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use={{ hive_ks_target }}
# Keyboard layouts
keyboard --vckeymap=jp --xlayouts='jp'
# System language
lang ja_JP.UTF-8

# Network information
# CAUTION: All static networking configuration information must be specified on one line; you cannot wrap lines using a backslash, for example.
# add networks
{% for network in hive_kickstart_config.networks %}
  {%- set options = '' -%}
  {% if network.gateway is defined %}
    {%- set options = options + ' --gateway=' + network.gateway -%}
  {%- endif -%}
  {% if network.nameservers is defined %}
    {%- set options = options + ' --nameserver=' + network.nameservers | join(',') -%}
  {%- endif -%}
  {% if network.ips is defined %}
    {%- set options = options + ' --ip=' + network.ips[ks_idx] + ' --netmask=' + network.netmask -%}
  {% else %}
    {%- set options = options + ' --noipv4' -%}
  {%- endif -%}
  {% if network.vlanid is defined %}
    {%- set options = options + ' --vlanid ' + (network.vlanid | string)-%}
  {%- endif -%}
  {%- if network.bonding_interfaces is defined -%}
    {%- set options = options + ' --bondslaves=' + (network.bonding_interfaces | join(',')) + ' --bondopts=miimon=100,mode=802.3ad,updelay=600' -%}
  {%- endif -%}
network --bootproto=static --device={{ network.interface }} --noipv6{{ options }}
{% endfor %}
# Root password
rootpw "{{ lookup('password', hive_context_dir + '/registry_password length=15 chars=ascii_letters,digits') }}"
user --name={{ hive_safe_admin }} --password="{{ lookup('password', hive_context_dir + '/registry_password length=15 chars=ascii_letters,digits') }}"
# System timezone
timezone {{ hive_ks_timezone }} --isUtc
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive={{ hive_ks_target }}
# Partition clearing information
clearpart --all --initlabel --drives={{ hive_ks_target }}
# Disk partitioning information
part /boot/efi --fstype=efi --ondisk={{ hive_ks_target }} --size=200
part swap --fstype=swap --ondisk={{ hive_ks_target }} --size={{ hostvars[ks_host].hive_memory_size | default('1024') }}
part / --fstype=xfs --ondisk={{ hive_ks_target }} --size={{ hostvars[ks_host].hive_disk_size * 1024 | default('10240') }}

%packages
@core
kexec-tools
%end

%addon com_redhat_kdump --enable --reserve-mb='auto'
%end

%post --log=/root/ks-post.log
#!/bin/bash
set -x
mkdir -p /home/{{ hive_safe_admin }}/.ssh
chmod 0700 /home/{{ hive_safe_admin }}/.ssh
echo '{{ lookup('file', hostvars[ks_host].hive_safe_public_key_path) }}'  > /home/{{ hive_safe_admin }}/.ssh/authorized_keys
chmod 0600 /home/{{ hive_safe_admin }}/.ssh/authorized_keys
chown -R {{ hive_safe_admin }}.{{ hive_safe_admin }} /home/{{ hive_safe_admin }}/.ssh
echo "%{{ hive_safe_admin }} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/{{ hive_safe_admin }}
%end

poweroff
