Add Archlinux

This commit is contained in:
Greg Hellings
2023-08-13 18:44:20 -05:00
parent 14413542f5
commit c2a53828a1
13 changed files with 225 additions and 40 deletions
+3 -36
View File
@@ -1,46 +1,13 @@
- name: install guest additions
hosts: default
vars:
ansible_remote_tmp: /tmp
pre_tasks:
- name: Pause for a moment in case we need cloud-init to finish
ansible.builtin.pause:
seconds: 20
- name: Update all the things
become: true
ansible.builtin.package: # noqa package-latest
name: "*"
state: latest
update_cache: true
when: ansible_facts.pkg_mgr not in ['atomic_container']
register: _update_all
retries: 3
until: _update_all is success
- name: Update atomic things
become: true
ansible.builtin.command: rpm-ostree upgrade
when: ansible_facts.pkg_mgr in ['atomic_container']
changed_when: false
register: _update_atomic
retries: 3
until: _update_atomic is success
- name: Reboot, but don't care if it doesn't
block:
- name: Restart the machine
become: true
ansible.builtin.reboot:
when: (_update_atomic is changed) or (_update_all is changed)
failed_when: false # This module is buggy and can't always understand a reboot
- name: Wait for reboot to finish
ansible.builtin.wait_for_connection:
delay: 15
rescue:
- name: Reboot failed? lol
ansible.builtin.debug:
msg: Reboot failed. lol.
roles:
- role: latest
- role: devroles.system.epel
- role: virtualbox
when: packer_builder_type == 'virtualbox-iso'
+6
View File
@@ -0,0 +1,6 @@
- name: Update on Arch
become: true
community.general.pacman:
upgrade: true
update_cache: true
state: latest
@@ -0,0 +1,7 @@
- name: Update atomic things
become: true
ansible.builtin.command: rpm-ostree upgrade
changed_when: false
register: _update_atomic
retries: 3
until: _update_atomic is success
+9
View File
@@ -0,0 +1,9 @@
- name: Update all the things
become: true
ansible.builtin.package: # noqa package-latest
name: "*"
state: latest
update_cache: true
register: _update_all
retries: 3
until: _update_all is success
+25
View File
@@ -0,0 +1,25 @@
- name: Load update sciprt for proper distro
ansible.builtin.include_tasks:
file: "{{ item }}"
with_first_found:
- files:
- "{{ role_path }}/tasks/{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_version'] }}.yml"
- "{{ role_path }}/tasks/{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_major_version'] }}.yml"
- "{{ role_path }}/tasks/{{ ansible_facts['distribution'] }}.yml"
- "{{ role_path }}/tasks/{{ ansible_facts['os_family'] }}.yml"
- "{{ role_path }}/tasks/default.yml"
- name: Reboot, but don't care if it doesn't
block:
- name: Restart the machine
become: true
ansible.builtin.reboot:
failed_when: false # This module is buggy and can't always understand a reboot
- name: Wait for reboot to finish
ansible.builtin.wait_for_connection:
delay: 15
rescue:
- name: Reboot failed? lol
ansible.builtin.debug:
msg: Reboot failed. lol.
+1
View File
@@ -54,6 +54,7 @@
ansible.builtin.package:
name: "{{ virtualbox_remove_packages | default([]) }}"
state: absent
when: virtualbox_remove_packages
- name: Remove file
ansible.builtin.file:
@@ -0,0 +1,6 @@
virtualbox_packages:
- virtualbox-guest-utils-nox
virtualbox_services:
- vboxservice
virtualbox_from_iso: false
virtualbox_remove_packages: []
+45
View File
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
set -ex
disk="${1}"
# Set locale info to reasonable defaults
ln -sf /usr/share/zoneinfo/UTC /etc/localtime
sed -i -E -e 's/#(en_US.UTF-8 UTF-8)/\1/' /etc/locale.gen
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
echo "KEYMAP=en" > /etc/vconsole.conf
echo "vagrant" > /etc/hostname
# Configure systems
echo 'vagrant ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/vagrant-nopasswd
echo 'Defaults !requiretty' >> /etc/sudoers
sed -i 's/.*UseDNS.*/UseDNS no/' /etc/ssh/sshd_config
cat > /etc/ssh/sshd_config.d/10-vagrant-insecure-rsa-key.conf <<EOF
# For now the vagrant insecure key is an rsa key
# https://github.com/hashicorp/vagrant/issues/11783
PubkeyAcceptedKeyTypes=+ssh-rsa
EOF
ssh-keygen -A
systemctl enable sshd
systemctl enable NetworkManager
# Configure and install grub
sed -i -E -e 's/GRUB_CMDLINE_LINUX="(.*)"/GRUB_CMDLINE_LINUX="\1 net.ifnames=0 biosdevnames=0"/' /etc/default/grub
grub-install --target=i386-pc "${disk}"
grub-mkconfig -o /boot/grub/grub.cfg
# Create and configure the vagrant user
groupadd vagrant
useradd vagrant -g vagrant -G wheel -d /home/vagrant
echo "vagrant:vagrant" | chpasswd
# Configure vagrant user's SSH key
mkdir -m 0700 -p ~vagrant/.ssh
cat > ~vagrant/.ssh/authorized_keys << EOKEYS
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key
EOKEYS
chmod 600 ~vagrant/.ssh/authorized_keys
chown -R vagrant:vagrant ~vagrant/
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
#vim: set ft=bash:
set -ex
port="${1}" # HTTP port that packer is running on
loadkeys en # Probably not necessary in a script, but here we are
if [ -e /dev/vda ]; then
disk="/dev/vda"
elif [ -e /dev/sda ]; then
disk="/dev/sda"
else
exit 1 # Need to teach the script which device to use in this case
fi
# The sed bit is just to strip out the extra fluff, like comments
sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk ${disk}
o # create new GPT partition table
n # new
p # primary partition
1 # part number
# default start
# default to full disk
p # print, for debugging
r # return to normal mode
w # write the partition table and exit
EOF
#t # set partition type
#1 # on partition 1
#4 # BIOS boot
# Format and mount partitions
mkfs.ext4 "${disk}1"
mount "${disk}1" /mnt
# Bootstrap system
pacstrap -K /mnt base linux nano sudo networkmanager openssh grub python3
genfstab -L /mnt >> /mnt/etc/fstab
# Run stuff in the chroot
curl -o /mnt/in-chroot.sh http://10.0.2.2:"${port}"/in-chroot.sh
arch-chroot /mnt /usr/bin/bash /in-chroot.sh "${disk}"
rm /mnt/in-chroot.sh
reboot
+54
View File
@@ -0,0 +1,54 @@
install
text
reboot
network --bootproto=dhcp --activate
url --url=http://mirror.centos.org/centos/7/os/x86_64/
repo --name=updates --baseurl=http://mirror.centos.org/centos/7/updates/x86_64/
lang en_US.UTF-8
keyboard us
timezone --utc Etc/UTC
rootpw --plaintext vagrant
user --name=vagrant --groups=vagrant --password=vagrant --plaintext
zerombr
clearpart --all --initlabel
autopart --type=plain
bootloader --timeout=1
%packages
@core
which
libselinux-python
# mandatory packages in the @core group
-btrfs-progs
-iprutils
-kexec-tools
-plymouth
# default packages in the @core group
-*-firmware
-dracut-config-rescue
-kernel-tools
-libsysfs
-microcode_ctl
-NetworkManager*
-postfix
-rdma
%end
%post --erroronfail
yum -y update
cat <<EOF > /etc/sudoers.d/vagrant
Defaults:vagrant !requiretty
vagrant ALL=(ALL) NOPASSWD: ALL
EOF
chmod 440 /etc/sudoers.d/vagrant
ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules
cat > /etc/sysconfig/network-scripts/ifcfg-eth0 <<EOF
DEVICE="eth0"
BOOTPROTO="dhcp"
ONBOOT="yes"
TYPE="Ethernet"
EOF
%end
@@ -0,0 +1,15 @@
distro = "arch"
version = "2023.08.01"
iso = {
url = "http://dfw.mirror.rackspace.com/archlinux/iso/2023.08.01/archlinux-x86_64.iso"
checksum = "3bf1287333de5c26663b70a17ce7573f15dc60780b140cbbd1c720338c0abac5"
}
boot_command = [
"<tab><wait> net.ifnames=0<wait> <wait>bi<wait>osdevnames=0<enter>",
"<wait60>", # Wait for system to come up?
"curl -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.sh<enter>",
"<wait5>",
"/usr/bin/bash /tmp/install.sh {{ .HTTPPort }}<enter>"
]
http_directory = "distros/arch/2023.08.01/http/"
boot_wait = "10s"
+5
View File
@@ -0,0 +1,5 @@
2023.08.01:
- arch: x86_64
provider: qemu
- arch: x86_64
provider: virtualbox-iso
+2 -4
View File
@@ -54,10 +54,8 @@ def main():
for box in g`output/**/*.box`:
p = pathlib.Path(box)
sed -e f's#@@BOX@@#file:///home/greg/src/vms/vms/{box}#' -e f's/@@BOX_NAME@@/{p.name}/' Vagrantfile.in > Vagrantfile
if str(p.parent.name) == "virtualbox":
vagrant up --provider virtualbox
elif str(p.parent.name) == "qemu":
vagrant up --provider libvirt
if str(p.parent.name) in ["virtualbox", "libvirt"]:
vagrant up --provider @(p.parent.name)
else:
print(f"Now whatcha wanna go and do that for? {box}")
continue