#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=sda
# 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.
{%- if hostvars[ks_host].hive_bond | default(False) -%}
{%- set target = "bond0" -%}
{%- set bond_slave0 = hostvars[ks_host].hive_ks_interfaces[0] -%}
{%- set bond_slave1 = hostvars[ks_host].hive_ks_interfaces[1] -%}
{%- set bond_options = '--bondslaves=' + bond_slave0 + ',' + bond_slave1 + ' --bondopts=miimon=100,mode=802.3ad,updelay=600' -%}
{%- else -%}
{%- set target = hostvars[ks_host].hive_ks_interfaces[0] -%}
{%- set bond_options = '' -%}
{%- endif -%}
# add a device
network --bootproto=static --device="{{ target }}" --gateway={{ hive_cidr | ipaddr(1) | ipaddr('address') }} --ip={{ hostvars[ks_host].hive_private_ip }} --netmask={{ hostvars[ks_host].hive_netmask }} --noipv6 {{ bond_options }} --nameserver {{ hive_nameservers | join(',')}}

# 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 Asia/Tokyo --isUtc

# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
# Partition clearing information
clearpart --all --initlabel --drives=sda
# Disk partitioning information
{% for part in hostvars[ks_host].hive_ks_partitions %}
part {{part.path}} --fstype="{{part.fstype}}" --ondisk=sda --size={{part.size}}
{% endfor -%}

%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
