-
Notifications
You must be signed in to change notification settings - Fork 123
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
Made some changes to how this is laid out so it will work on Atlas #41
base: master
Are you sure you want to change the base?
Changes from 50 commits
092782f
27728cf
538835f
ac4f1da
aa13b62
68072ae
66a70e1
cb2d473
3a38be8
f19d323
feebe7b
89ecac4
b586335
e699982
38f1d97
fa6ec67
3459d33
4875bd8
3ff2228
7b4f455
e5962ad
bad8ccc
39b8902
91c4ef7
b04f690
db44e1c
7b302c3
2d6e393
8c75143
d3bba1b
f253ade
ec70b6f
fa865c2
89417f2
11f3df6
f616487
4adbab1
ca1e5e7
0026a6b
ffc79c5
d494fc2
979b156
ad893ee
979cf7f
824e9dc
2e3e5ea
e71fdae
e96c4f1
411f2b9
c732535
47be70e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
packer_arch_*.box | ||
packer_cache | ||
output-vmware | ||
*.un~ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is also json file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call, I had removed the extension when pushing to packer because it was building Parallels, but afterwards noticed that I hadn't actually removed it from the base template which meant the extension wasn't the problem. |
||
"variables": { | ||
"atlas_token": "{{ env `ATLAS_TOKEN` }}", | ||
"atlas_username": "{{env `ATLAS_USERNAME`}}", | ||
"atlas_name": "{{env `ATLAS_NAME`}}", | ||
"atlas_version": "{{env `ATLAS_BUILD_NUMBER`}}", | ||
"install_script": "install-arch-base.sh", | ||
"iso_url": "https://mirrors.kernel.org/archlinux/iso/2016.01.01/archlinux-2016.01.01-dual.iso", | ||
"iso_checksum": "ff79a9629a83dfedad6c3a58e2e7838c86282315", | ||
"iso_checksum_type": "sha1", | ||
"ssh_timeout": "20m" | ||
}, | ||
"builders": [ | ||
{ | ||
"type": "parallels-iso", | ||
"parallels_tools_flavor": "lin", | ||
"parallels_tools_mode": "attach", | ||
"guest_os_type": "linux-2.6", | ||
"iso_url": "{{user `iso_url`}}", | ||
"iso_checksum": "{{user `iso_checksum`}}", | ||
"iso_checksum_type": "{{user `iso_checksum_type`}}", | ||
"http_directory": ".", | ||
"boot_wait": "5s", | ||
"boot_command": [ | ||
"<enter><wait10><wait10>", | ||
"/usr/bin/curl -O http://{{.HTTPIP}}:{{.HTTPPort}}/{{user `install_script`}}<enter><wait5>", | ||
"/usr/bin/curl -O http://{{.HTTPIP}}:{{.HTTPPort}}/poweroff.timer<enter><wait5>", | ||
"/usr/bin/curl -O http://{{.HTTPIP}}:{{.HTTPPort}}/parallels_tools.sh<enter><wait5>", | ||
"/usr/bin/bash ./{{user `install_script`}}<enter>" | ||
], | ||
"disk_size": 20480, | ||
"ssh_username": "vagrant", | ||
"ssh_password": "vagrant", | ||
"ssh_timeout": "{{user `ssh_timeout`}}", | ||
"shutdown_command": "sudo systemctl start poweroff.timer" | ||
} | ||
], | ||
"provisioners": [ | ||
{ | ||
"execute_command": "echo '{{ user `ssh_password` }}' | {{.Vars}} sudo -E -S bash '{{.Path}}'", | ||
"only": ["parallels-iso"], | ||
"script": "scripts/parallels.sh", | ||
"type": "shell" | ||
}, | ||
{ | ||
"execute_command": "echo '{{ user `ssh_password` }}' | {{.Vars}} sudo -E -S bash '{{.Path}}'", | ||
"scripts": [ | ||
"custom-script.sh", | ||
"scripts/cleanup.sh" | ||
], | ||
"type": "shell" | ||
} | ||
], | ||
"post-processors": [ | ||
[{ | ||
"type": "vagrant", | ||
"output": "packer_arch_{{.Provider}}.box" | ||
} | ||
] | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/usr/bin/env bash | ||
|
||
DISK='/dev/sda' | ||
FQDN='vagrant-arch.vagrantup.com' | ||
KEYMAP='us' | ||
LANGUAGE='en_US.UTF-8' | ||
PASSWORD=$(/usr/bin/openssl passwd -crypt 'vagrant') | ||
TIMEZONE='UTC' | ||
|
||
CONFIG_SCRIPT='/usr/local/bin/arch-config.sh' | ||
ROOT_PARTITION="${DISK}1" | ||
TARGET_DIR='/mnt' | ||
|
||
echo "==> clearing partition table on ${DISK}" | ||
/usr/bin/sgdisk --zap ${DISK} | ||
|
||
echo "==> destroying magic strings and signatures on ${DISK}" | ||
/usr/bin/dd if=/dev/zero of=${DISK} bs=512 count=2048 | ||
/usr/bin/wipefs --all ${DISK} | ||
|
||
echo "==> creating /root partition on ${DISK}" | ||
/usr/bin/sgdisk --new=1:0:0 ${DISK} | ||
|
||
echo "==> setting ${DISK} bootable" | ||
/usr/bin/sgdisk ${DISK} --attributes=1:set:2 | ||
|
||
echo '==> creating /root filesystem (ext4)' | ||
/usr/bin/mkfs.ext4 -F -m 0 -q -L root ${ROOT_PARTITION} | ||
|
||
echo "==> mounting ${ROOT_PARTITION} to ${TARGET_DIR}" | ||
/usr/bin/mount -o noatime,errors=remount-ro ${ROOT_PARTITION} ${TARGET_DIR} | ||
|
||
echo '==> bootstrapping the base installation' | ||
/usr/bin/pacstrap ${TARGET_DIR} base base-devel | ||
/usr/bin/arch-chroot ${TARGET_DIR} pacman -S --noconfirm gptfdisk openssh syslinux | ||
/usr/bin/arch-chroot ${TARGET_DIR} syslinux-install_update -i -a -m | ||
/usr/bin/sed -i 's/sda3/sda1/' "${TARGET_DIR}/boot/syslinux/syslinux.cfg" | ||
/usr/bin/sed -i 's/TIMEOUT 50/TIMEOUT 10/' "${TARGET_DIR}/boot/syslinux/syslinux.cfg" | ||
|
||
echo '==> generating the filesystem table' | ||
/usr/bin/genfstab -p ${TARGET_DIR} >> "${TARGET_DIR}/etc/fstab" | ||
|
||
echo '==> generating the system configuration script' | ||
/usr/bin/install --mode=0755 /dev/null "${TARGET_DIR}${CONFIG_SCRIPT}" | ||
|
||
cat <<-EOF > "${TARGET_DIR}${CONFIG_SCRIPT}" | ||
echo '${FQDN}' > /etc/hostname | ||
/usr/bin/ln -s /usr/share/zoneinfo/${TIMEZONE} /etc/localtime | ||
echo 'KEYMAP=${KEYMAP}' > /etc/vconsole.conf | ||
/usr/bin/sed -i 's/#${LANGUAGE}/${LANGUAGE}/' /etc/locale.gen | ||
/usr/bin/locale-gen | ||
/usr/bin/mkinitcpio -p linux | ||
/usr/bin/usermod --password ${PASSWORD} root | ||
# https://wiki.archlinux.org/index.php/Network_Configuration#Device_names | ||
/usr/bin/ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules | ||
/usr/bin/ln -s '/usr/lib/systemd/system/[email protected]' '/etc/systemd/system/multi-user.target.wants/[email protected]' | ||
/usr/bin/sed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config | ||
/usr/bin/systemctl enable sshd.service | ||
|
||
# Vagrant-specific configuration | ||
/usr/bin/groupadd vagrant | ||
/usr/bin/useradd --password ${PASSWORD} --comment 'Vagrant User' --create-home --gid users --groups vagrant vagrant | ||
echo 'Defaults env_keep += "SSH_AUTH_SOCK"' > /etc/sudoers.d/10_vagrant | ||
echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers.d/10_vagrant | ||
/usr/bin/chmod 0440 /etc/sudoers.d/10_vagrant | ||
/usr/bin/install --directory --owner=vagrant --group=users --mode=0700 /home/vagrant/.ssh | ||
/usr/bin/curl --output /home/vagrant/.ssh/authorized_keys --location https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub | ||
/usr/bin/chown vagrant:users /home/vagrant/.ssh/authorized_keys | ||
/usr/bin/chmod 0600 /home/vagrant/.ssh/authorized_keys | ||
|
||
# clean up | ||
rm -rf /var/log/journal/* /var/log/old/* /var/log/faillog /var/log/lastlog /var/log/pacman.log | ||
rm -f /home/vagrant/.bash_history | ||
rm -f /root/.bash_history | ||
/usr/bin/pacman -Rcns --noconfirm gptfdisk | ||
/usr/bin/pacman -Scc --noconfirm | ||
EOF | ||
|
||
echo '==> entering chroot and configuring system' | ||
/usr/bin/arch-chroot ${TARGET_DIR} ${CONFIG_SCRIPT} | ||
rm "${TARGET_DIR}${CONFIG_SCRIPT}" | ||
|
||
# http://comments.gmane.org/gmane.linux.arch.general/48739 | ||
echo '==> adding workaround for shutdown race condition' | ||
/usr/bin/install --mode=0644 poweroff.timer "${TARGET_DIR}/etc/systemd/system/poweroff.timer" | ||
|
||
echo '==> installation complete!' | ||
/usr/bin/sleep 3 | ||
/usr/bin/umount ${TARGET_DIR} | ||
|
||
cd /root | ||
dd if=/dev/zero of=zerofillfile bs=1M | ||
rm -f zerofillfile | ||
history -c | ||
/usr/bin/systemctl reboot |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,7 +69,10 @@ cat <<-EOF > "${TARGET_DIR}${CONFIG_SCRIPT}" | |
|
||
# clean up | ||
/usr/bin/pacman -Rcns --noconfirm gptfdisk | ||
/usr/bin/yes | /usr/bin/pacman -Scc | ||
/usr/bin/pacman -Scc --noconfirm | ||
rm -rf /var/log/journal/* /var/log/old/* /var/log/faillog /var/log/lastlog /var/log/pacman.log | ||
rm -f /home/vagrant/.bash_history | ||
rm -f /root/.bash_history | ||
EOF | ||
|
||
echo '==> entering chroot and configuring system' | ||
|
@@ -83,4 +86,9 @@ echo '==> adding workaround for shutdown race condition' | |
echo '==> installation complete!' | ||
/usr/bin/sleep 3 | ||
/usr/bin/umount ${TARGET_DIR} | ||
|
||
cd /root | ||
dd if=/dev/zero of=zerofillfile bs=1M | ||
rm -f zerofillfile | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reducing VagrantBox size is really good! 👍 |
||
history -c | ||
/usr/bin/systemctl reboot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we publish an 'official' packer-arch vagrant files here, rather than use @dragon788's version?
This way, @dragon788 can do his thing without worrying about messing up the upstream project.