Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create images for Vagrant #15

Merged
merged 8 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
.vscode/
galaxy_roles/*
files/*
*.iso
*.box
*.ova
*.vdi
64 changes: 64 additions & 0 deletions Vagrantfile.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# To use these virtual machines install Vagrant and VirtualBox.
# vagrant up

Vagrant.require_version ">= 2.0.0"
Vagrant.configure(2) do |config|

# check for updates of the base image
config.vm.box_check_update = true
# wait a while longer
config.vm.boot_timeout = 1200

# disable update guest additions
if Vagrant.has_plugin?("vagrant-vbguest")
config.vbguest.auto_update = false
end

# enable ssh agent forwarding
config.ssh.forward_agent = true

# use the standard vagrant ssh key
config.ssh.insert_key = false

# Iterate through entries in JSON file

config.vm.box = "ansiblebook/controller"
config.vm.hostname = "controller"
config.vm.network "public_network", type: "dhcp", bridge: "Wi-Fi"
config.vm.network :forwarded_port, host: 8443, guest: 443

# set no_share to false to enable file sharing
config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true
config.vm.provider "hyperv" do |hyperv|
hyperv.cpus = 4
hyperv.memory = 4096
hyperv.vmname = "controller"
hyperv.enable_virtualization_extensions = true
hyperv.vm_integration_services = {
guest_service_interface: true,
heartbeat: true,
shutdown: true,
time_synchronization: true,
}
hyperv.linked_clone = true
end
config.vm.provider :vmware_desktop do |vmware|
vmware.gui = false
vmware.vmx['memsize'] = 4096
vmware.vmx['numvcpus'] = 4
end
config.vm.provider :virtualbox do |virtualbox|
virtualbox.customize ["modifyvm", :id,
"--audio-driver", "none",
"--cpus", 4,
"--memory", 4096,
"--natnet1", "192.168.33.0/24",
"--graphicscontroller", "VMSVGA",
"--vram", "64"
]
virtualbox.gui = false
virtualbox.name = "controller"
end
end
7 changes: 7 additions & 0 deletions controller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,11 @@ sudo pip3.12 install jmespath
ansible --version
(git clone https://github.com/playingfield/controller.git || /bin/true)
cd controller && source ansible.sh && ./prepare.sh
# export these variables!
if [ -z "${DB_PASS}" ]; then
export DB_PASS="your_database_password"
fi
if [ -z "${SSH_PASS}" ]; then
export SSH_PASS="KeyWillBeGeneratedWithAPassphrase"
fi
./provision.yml -v -e debug=true
146 changes: 146 additions & 0 deletions kickstart/ks.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# License agreement
eula --agreed
# Reboot after installation
reboot --eject
# Use text mode install
text
# Use CDROM installation media
cdrom

%pre --erroronfail
/usr/bin/dd bs=512 count=10 if=/dev/zero of=/dev/sda
/usr/sbin/parted -s /dev/sda mklabel gpt
/usr/sbin/parted -s /dev/sda print
%end

%post --erroronfail
rm -f /etc/dconf/db/gdm.d/00-security-settings

# /tmp is restricted by mount options
mkdir /var/tmp
chmod 1777 /var/tmp

# permit root login via SSH with password authentication
echo "PermitRootLogin yes" > /etc/ssh/sshd_config.d/01-permitrootlogin.conf

# For Ansible
sed -i "s/^.*requiretty/# Defaults requiretty/" /etc/sudoers

# remove random-seed so it's not the same every time
rm -f /var/lib/systemd/random-seed

# Remove machine-id on the pre generated images
cat /dev/null > /etc/machine-id

# Anaconda is writing to /etc/resolv.conf from the generating environment.
# The system should start out with an empty file.
truncate -s 0 /etc/resolv.conf

echo "Cleaning old yum repodata."
dnf clean all

# clean up installation logs"
rm -rf /var/log/yum.log
rm -rf /var/lib/yum/*
rm -rf /root/install.log
rm -rf /root/install.log.syslog
rm -rf /root/anaconda-ks.cfg
rm -rf /var/log/anaconda*

%end

%packages --ignoremissing --excludedocs --instLangs=en_US.UTF-8
@core
chrony
bash-completion
glibc-langpack-en
glibc-minimal-langpack
langtable
bzip2
tar
dhcp-client
git-core
# Make this image portable; rescue mode isn't useful here.
dracut-config-generic
dracut-norescue
# Boot config
grub2-pc
grub2-efi-modules
usermode
# Ansible
ansible-core
python3-jmespath
python3-libselinux
python3-policycoreutils
python3-rpm
# vmware
open-vm-tools
# hyperv
hyperv-daemons
hyperv-daemons-licence
hypervfcopyd
hypervkvpd
hypervvssd
# Add rng-tools as source of entropy
rng-tools
# Some things from @core we can do without in a minimal install
-biosdevname
-cockpit
# RHEL subscription
-dnf-plugin-spacewalk
-rhn*

-sqlite
-iprutils
-iwl*-firmware
-langpacks-*
-mdadm
-plymouth
%end

# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8

# Firewall configuration
firewall --disabled
# Network information
network --bootproto=dhcp --device=link --hostname=controller --activate

# System authorization information
authselect --enableshadow --passalgo=sha512 --kickstart
# SELinux configuration
selinux --permissive

firstboot --disabled
# Do not configure the X Window System
skipx
# System services
services --enabled="NetworkManager,sshd,chronyd"
ignoredisk --only-use=sda

# Partition information

zerombr
# net.ifnames are defined by the host
bootloader --location=boot --append="loglevel=3 audit=0 console=tty1 console=ttyS0 earlyprintk=ttyS0 rootdelay=300 no_timer_check net.ifnames=0"
clearpart --all --drives=sda --initlabel

# Create primary system partitions (required for installs)
part /boot/efi --fstype=efi --label EFI --size=512
part /boot --fstype=ext4 --label BOOT --size=512 --fsoptions="nodev,nosuid,noexec"
part /dev/shm --fstype=tmpfs --size=1024
part / --size=1 --ondrive=sda --grow --asprimary

# System timezone
timezone UTC

rootpw --iscrypted $6$hGuNal58RjvpKAqy$UPGgU7QRk0ZA.dcGO0xZwsAmPgDDjzDs9f3UV3X5.SYfRAQR2pwUAZEmj0WHLo2gQXT0mS4/Bzs9WuIW.hxUW.

# disable kdump service
%addon com_redhat_kdump --disable
%end

%anaconda
%end
Loading