This repository has been archived by the owner on Nov 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 60f3265
Showing
8 changed files
with
465 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Cache objects | ||
packer_cache/ | ||
output-virtualbox-iso/ | ||
output-vmware-iso/ | ||
|
||
# For built boxes | ||
*.box |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 eaksel | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# packer-Rocky8 | ||
|
||
## What is packer-Rocky8 ? | ||
|
||
packer-Rocky8 is a set of configuration files used to build an automated Rocky Linux 8 virtual machine images using [Packer](https://www.packer.io/). | ||
This Packer configuration file allows you to build images for VMware Workstation and Oracle VM VirtualBox. | ||
|
||
## Prerequisites | ||
|
||
- [Packer](https://www.packer.io/downloads.html) | ||
- <https://www.packer.io/intro/getting-started/install.html> | ||
- A Hypervisor | ||
- [VMware Workstation](https://www.vmware.com/products/workstation-pro.html) | ||
- [Oracle VM VirtualBox](https://www.virtualbox.org/) | ||
|
||
## How to use Packer | ||
|
||
Commands to create an automated VM image: | ||
|
||
To create a Rocky Linux 8 VM image using VMware Workstation use the following commands: | ||
|
||
```cmd | ||
cd c:\packer-Rocky8 | ||
packer build -only=vmware-iso rocky8.json | ||
packer build -only=vmware-iso rocky8_uefi.json | ||
``` | ||
|
||
To create a Rocky Linux 8 VM image using Oracle VM VirtualBox use the following commands: | ||
|
||
```cmd | ||
cd c:\packer-Rocky8 | ||
packer build -only=virtualbox-iso rocky8.json | ||
packer build -only=virtualbox-iso rocky8_uefi.json | ||
``` | ||
|
||
*If you omit the keyword "-only=" both the Workstation and Virtualbox VMs will be created.* | ||
|
||
By default the .iso of Rocky Linux 8 is pulled from <https://download.rockylinux.org/pub/rocky/8.3/isos/x86_64/Rocky-8.3-x86_64-boot.iso> | ||
|
||
You can change the URL to one closer to your build server. To do so change the **"iso_url"** parameter in the **"variables"** section of the rocky8.json file. | ||
|
||
```json | ||
{ | ||
"variables": { | ||
"iso_url": "https://download.rockylinux.org/pub/rocky/8.3/isos/x86_64/Rocky-8.3-x86_64-boot.iso" | ||
} | ||
``` | ||
|
||
## Keyboard configuration | ||
|
||
By default the keyboard is set to be US qwerty. | ||
To switch it to something else edit the following file: | ||
|
||
- ./http/ks.cfg | ||
|
||
Set the `keyboard` parameter as desired, for example: `keyboard --vckeymap=fr --xlayouts='fr'` | ||
|
||
## Default credentials | ||
|
||
The default credentials for this VM image are: | ||
|
||
|Username|Password| | ||
|--------|--------| | ||
|packer|packer| | ||
|root|packer| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/performing_an_advanced_rhel_installation/kickstart-commands-and-options-reference_installing-rhel-as-an-experienced-user | ||
|
||
# Set the authentication options for the system | ||
auth --passalgo=sha512 --useshadow | ||
# Install OS instead of upgrade | ||
install | ||
# License agreement | ||
eula --agreed | ||
# Use network installation | ||
url --url="https://download.rockylinux.org/pub/rocky/8/BaseOS/x86_64/os/" | ||
repo --name="AppStream" --baseurl=https://download.rockylinux.org/pub/rocky/8/AppStream/x86_64/os/ | ||
# Use text mode install | ||
text | ||
# Disable Initial Setup on first boot | ||
firstboot --disable | ||
# Keyboard layout | ||
keyboard --vckeymap=us --xlayouts='us' | ||
# System language | ||
lang en_US.UTF-8 | ||
# Network information | ||
network --bootproto=dhcp --device=link --activate | ||
network --hostname=rocky8.localdomain | ||
# Root password | ||
rootpw $1$+xLTvuVv$vAMwt4RuJqO3qp9nLQj1U0 --iscrypted | ||
# SELinux configuration | ||
selinux --enforcing | ||
# Do not configure the X Window System | ||
skipx | ||
# System timezone | ||
timezone Europe/Paris --isUtc | ||
# Add a user named packer | ||
user --groups=wheel --name=packer --password=$6$Jaa5U0EwAPMMp3.5$m29yTwr0q9ZJVJGMXvOnm9q2z13ldUFTjB1sxPHvaiW4upMSwQ50181wl7SjHjh.BTH7FGHx37wrX..SM0Bqq. --iscrypted --gecos="packer" | ||
# System bootloader configuration | ||
bootloader --location=mbr --append="crashkernel=auto" | ||
# Clear the Master Boot Record | ||
zerombr | ||
# Remove partitions | ||
clearpart --all --initlabel | ||
# Automatically create partitions using LVM | ||
autopart --type=lvm | ||
# Reboot after successful installation | ||
reboot | ||
|
||
%packages --ignoremissing | ||
# dnf group info minimal-environment | ||
@^minimal-environment | ||
# Exclude unnecessary firmwares | ||
-iwl*firmware | ||
%end | ||
|
||
%post --nochroot --logfile=/mnt/sysimage/root/ks-post.log | ||
# Disable quiet boot and splash screen | ||
sed --follow-symlinks -i "s/ rhgb quiet//" /mnt/sysimage/etc/default/grub | ||
sed --follow-symlinks -i "s/ rhgb quiet//" /mnt/sysimage/boot/grub2/grubenv | ||
|
||
# Passwordless sudo for the user 'packer' | ||
echo "packer ALL=(ALL) NOPASSWD: ALL" >> /mnt/sysimage/etc/sudoers.d/packer | ||
%end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
{ | ||
"variables": { | ||
"boot_wait": "5s", | ||
"disk_size": "40960", | ||
"iso_checksum": "7a0c39ec8c271c6112ea37ed9767d4ab98107a6c778e03d34d16cd5e4e0285f0", | ||
"iso_url": "https://download.rockylinux.org/pub/rocky/8.3/isos/x86_64/Rocky-8.3-x86_64-boot.iso", | ||
"memsize": "1024", | ||
"numvcpus": "1", | ||
"ssh_password" : "packer", | ||
"ssh_username" : "packer", | ||
"vm_name": "Rocky-8.3-x86_64" | ||
}, | ||
"builders": [ | ||
{ | ||
"type": "vmware-iso", | ||
"boot_command": [ | ||
"<tab><bs><bs><bs><bs><bs>text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg<enter><wait>" | ||
], | ||
"boot_wait": "{{ user `boot_wait` }}", | ||
"disk_size": "{{ user `disk_size` }}", | ||
"disk_type_id": "0", | ||
"guest_os_type": "centos-64", | ||
"headless": false, | ||
"http_directory": "http", | ||
"iso_checksum": "{{ user `iso_checksum` }}", | ||
"iso_url": "{{ user `iso_url` }}", | ||
"shutdown_command": "echo 'packer'|sudo -S /sbin/halt -h -p", | ||
"ssh_password": "{{ user `ssh_password` }}", | ||
"ssh_port": 22, | ||
"ssh_username": "{{ user `ssh_username` }}", | ||
"ssh_timeout": "30m", | ||
"vm_name": "{{ user `vm_name` }}", | ||
"vmx_data": { | ||
"memsize": "{{ user `memsize` }}", | ||
"numvcpus": "{{ user `numvcpus` }}", | ||
"virtualHW.version": "14" | ||
} | ||
}, | ||
{ | ||
"type": "virtualbox-iso", | ||
"boot_command": [ | ||
"<tab><bs><bs><bs><bs><bs>text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg<enter><wait>" | ||
], | ||
"boot_wait": "{{ user `boot_wait` }}", | ||
"disk_size": "{{ user `disk_size` }}", | ||
"guest_os_type": "RedHat_64", | ||
"headless": false, | ||
"http_directory": "http", | ||
"iso_checksum": "{{ user `iso_checksum` }}", | ||
"iso_url": "{{ user `iso_url` }}", | ||
"shutdown_command": "echo 'packer'|sudo -S /sbin/halt -h -p", | ||
"ssh_password": "{{ user `ssh_password` }}", | ||
"ssh_port": 22, | ||
"ssh_username": "{{ user `ssh_username` }}", | ||
"ssh_timeout": "30m", | ||
"vm_name": "{{ user `vm_name` }}", | ||
"vboxmanage": [ | ||
["modifyvm", "{{.Name}}", "--memory", "{{ user `memsize` }}"], | ||
["modifyvm", "{{.Name}}", "--cpus", "{{ user `numvcpus` }}"] | ||
] | ||
} | ||
], | ||
"provisioners": [ | ||
{ | ||
"type": "shell", | ||
"execute_command": "echo 'packer'|{{.Vars}} sudo -S -E bash '{{.Path}}'", | ||
"inline": [ | ||
"dnf -y update", | ||
"dnf -y install python3", | ||
"alternatives --set python /usr/bin/python3", | ||
"python3 -m pip install -U pip", | ||
"pip3 install ansible" | ||
] | ||
}, | ||
{ | ||
"type": "ansible-local", | ||
"playbook_file": "scripts/setup.yml" | ||
}, | ||
{ | ||
"type": "shell", | ||
"execute_command": "echo 'packer'|{{.Vars}} sudo -S -E bash '{{.Path}}'", | ||
"scripts": [ | ||
"scripts/cleanup.sh" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
{ | ||
"variables": { | ||
"boot_wait": "5s", | ||
"disk_size": "40960", | ||
"iso_checksum": "7a0c39ec8c271c6112ea37ed9767d4ab98107a6c778e03d34d16cd5e4e0285f0", | ||
"iso_url": "https://download.rockylinux.org/pub/rocky/8.3/isos/x86_64/Rocky-8.3-x86_64-boot.iso", | ||
"memsize": "1024", | ||
"numvcpus": "1", | ||
"ssh_password" : "packer", | ||
"ssh_username" : "packer", | ||
"vm_name": "Rocky-8.3-x86_64" | ||
}, | ||
"builders": [ | ||
{ | ||
"type": "vmware-iso", | ||
"boot_command": ["e<down><down><end><bs><bs><bs><bs><bs>text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg<leftCtrlOn>x<leftCtrlOff>"], | ||
"boot_wait": "{{ user `boot_wait` }}", | ||
"disk_size": "{{ user `disk_size` }}", | ||
"disk_type_id": "0", | ||
"guest_os_type": "centos-64", | ||
"headless": false, | ||
"http_directory": "http", | ||
"iso_checksum": "{{ user `iso_checksum` }}", | ||
"iso_url": "{{ user `iso_url` }}", | ||
"shutdown_command": "echo 'packer'|sudo -S /sbin/halt -h -p", | ||
"ssh_password": "{{ user `ssh_password` }}", | ||
"ssh_port": 22, | ||
"ssh_username": "{{ user `ssh_username` }}", | ||
"ssh_timeout": "30m", | ||
"vm_name": "{{ user `vm_name` }}", | ||
"vmx_data": { | ||
"memsize": "{{ user `memsize` }}", | ||
"numvcpus": "{{ user `numvcpus` }}", | ||
"virtualHW.version": "14", | ||
"firmware": "efi" | ||
} | ||
}, | ||
{ | ||
"type": "virtualbox-iso", | ||
"boot_command": ["e<down><down><end><bs><bs><bs><bs><bs>text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg<leftCtrlOn>x<leftCtrlOff>"], | ||
"boot_wait": "{{ user `boot_wait` }}", | ||
"disk_size": "{{ user `disk_size` }}", | ||
"guest_os_type": "RedHat_64", | ||
"headless": false, | ||
"http_directory": "http", | ||
"iso_checksum": "{{ user `iso_checksum` }}", | ||
"iso_url": "{{ user `iso_url` }}", | ||
"shutdown_command": "echo 'packer'|sudo -S /sbin/halt -h -p", | ||
"ssh_password": "{{ user `ssh_password` }}", | ||
"ssh_port": 22, | ||
"ssh_username": "{{ user `ssh_username` }}", | ||
"ssh_timeout": "30m", | ||
"vm_name": "{{ user `vm_name` }}", | ||
"iso_interface": "sata", | ||
"vboxmanage": [ | ||
["modifyvm", "{{.Name}}", "--memory", "{{ user `memsize` }}"], | ||
["modifyvm", "{{.Name}}", "--cpus", "{{ user `numvcpus` }}"], | ||
["modifyvm", "{{.Name}}", "--firmware", "EFI"] | ||
] | ||
} | ||
], | ||
"provisioners": [ | ||
{ | ||
"type": "shell", | ||
"execute_command": "echo 'packer'|{{.Vars}} sudo -S -E bash '{{.Path}}'", | ||
"inline": [ | ||
"dnf -y update", | ||
"dnf -y install python3", | ||
"alternatives --set python /usr/bin/python3", | ||
"python3 -m pip install -U pip", | ||
"pip3 install ansible" | ||
] | ||
}, | ||
{ | ||
"type": "ansible-local", | ||
"playbook_file": "scripts/setup.yml" | ||
}, | ||
{ | ||
"type": "shell", | ||
"execute_command": "echo 'packer'|{{.Vars}} sudo -S -E bash '{{.Path}}'", | ||
"scripts": [ | ||
"scripts/cleanup.sh" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash -eux | ||
|
||
pip3 uninstall -y ansible | ||
|
||
dnf clean all | ||
|
||
# Zero out the rest of the free space using dd, then delete the written file. | ||
dd if=/dev/zero of=/EMPTY bs=1M | ||
rm -f /EMPTY | ||
|
||
# Add `sync` so Packer doesn't quit too early, before the large file is deleted. | ||
sync |
Oops, something went wrong.