Ubuntu 20.04 on QEmu working
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
output_*
|
||||
*.box
|
||||
*.iso
|
||||
.vagrant
|
||||
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
||||
# configures the configuration version (we support older styles for
|
||||
# backwards compatibility). Please don't change it unless you know what
|
||||
# you're doing.
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.box = "test"
|
||||
|
||||
# Create a private network, which allows host-only access to the machine
|
||||
# using a specific IP.
|
||||
# config.vm.network "private_network", ip: "192.168.33.10"
|
||||
|
||||
# Share an additional folder to the guest VM. The first argument is
|
||||
# the path on the host to the actual folder. The second argument is
|
||||
# the path on the guest to mount the folder. And the optional third
|
||||
# argument is a set of non-required options.
|
||||
config.vm.synced_folder ".", "/vagrant", disabled: true
|
||||
|
||||
# Provider-specific configuration so you can fine-tune various
|
||||
# backing providers for Vagrant. These expose provider-specific options.
|
||||
# Example for VirtualBox:
|
||||
#
|
||||
# config.vm.provider "virtualbox" do |vb|
|
||||
# # Display the VirtualBox GUI when booting the machine
|
||||
# vb.gui = true
|
||||
#
|
||||
# # Customize the amount of memory on the VM:
|
||||
# vb.memory = "1024"
|
||||
# end
|
||||
#
|
||||
# View the documentation for the provider you are using for more
|
||||
# information on available options.
|
||||
|
||||
# Enable provisioning with a shell script. Additional provisioners such as
|
||||
# Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
|
||||
# documentation for more information about their specific syntax and use.
|
||||
config.vm.provision "shell", inline: <<-SHELL
|
||||
set -ex
|
||||
ls -l /
|
||||
SHELL
|
||||
end
|
||||
@@ -0,0 +1,24 @@
|
||||
- name: install guest additions
|
||||
hosts: default
|
||||
pre_tasks:
|
||||
- name: update all the things
|
||||
become: true
|
||||
package:
|
||||
name: "*"
|
||||
state: latest
|
||||
when: ansible_facts.pkg_mgr not in ['atomic_container']
|
||||
|
||||
- name: update atomic things
|
||||
become: true
|
||||
command: rpm-ostree upgrade
|
||||
when: ansible_facts.pkg_mgr in ['atomic_container']
|
||||
roles:
|
||||
- role: virtualbox
|
||||
when: packer_builder_type == 'virtualbox-iso'
|
||||
- role: vmware
|
||||
when: packer_builder_type == 'vmware-iso'
|
||||
- role: init
|
||||
- role: epel
|
||||
- role: locale
|
||||
- role: vagrant
|
||||
- role: cleanup
|
||||
@@ -0,0 +1,7 @@
|
||||
- name: clean yum history
|
||||
become: true
|
||||
shell: |-
|
||||
set -e
|
||||
yum --enablerepo=epel clean all
|
||||
yum history new
|
||||
truncate -c -s 0 /var/log/yum.log
|
||||
@@ -0,0 +1,8 @@
|
||||
- name: remove unnecessesary packages
|
||||
become: true
|
||||
package:
|
||||
name:
|
||||
- perl
|
||||
- gcc
|
||||
- kernel-devel
|
||||
state: absent
|
||||
@@ -0,0 +1,11 @@
|
||||
- name: remove unnecessesary packages
|
||||
become: true
|
||||
package:
|
||||
name:
|
||||
- make
|
||||
- perl
|
||||
- gcc
|
||||
- kernel-devel
|
||||
- net-tools
|
||||
- bzip2
|
||||
state: absent
|
||||
@@ -0,0 +1,4 @@
|
||||
- name: clean up Fedora
|
||||
become: true
|
||||
command: dnf clean all
|
||||
when: ansible_facts.pkg_mgr not in ['atomic_container']
|
||||
@@ -0,0 +1,3 @@
|
||||
- name: clean apt files
|
||||
become: true
|
||||
command: apt-get clean
|
||||
@@ -0,0 +1,8 @@
|
||||
- name: cleanup
|
||||
include_tasks: "{{ distro }}"
|
||||
loop:
|
||||
- "{{ role_path }}/tasks/{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_major_version'] }}.yml"
|
||||
- "{{ role_path }}/tasks/{{ ansible_facts['distribution'] }}.yml"
|
||||
when: distro is file
|
||||
loop_control:
|
||||
loop_var: distro
|
||||
@@ -0,0 +1,16 @@
|
||||
- become: true
|
||||
block:
|
||||
- name: install epel-release
|
||||
package:
|
||||
name: epel-release
|
||||
state: present
|
||||
|
||||
- name: disable epel
|
||||
ini_file:
|
||||
path: /etc/yum.repos.d/epel.repo
|
||||
section: epel
|
||||
option: enabled
|
||||
value: "0"
|
||||
create: false
|
||||
when: >
|
||||
ansible_facts['distribution'] in ['CentOS', 'RHEL']
|
||||
@@ -0,0 +1,16 @@
|
||||
- name: load version information
|
||||
include_vars: "{{ item }}"
|
||||
loop:
|
||||
- "{{ role_path }}/vars/{{ ansible_facts['os_family'] }}.yml"
|
||||
- "{{ role_path }}/vars/{{ ansible_facts['distribution'] }}.yml"
|
||||
- "{{ role_path }}/vars/{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_major_version'] }}.yml"
|
||||
- "{{ role_path }}/vars/{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_version'] }}.yml"
|
||||
when: item is file
|
||||
|
||||
- name: modify init file
|
||||
become: true
|
||||
replace:
|
||||
path: "{{ init_file }}"
|
||||
replace: "{{ init_replace }}"
|
||||
regexp: "{{ init_regexp }}"
|
||||
when: init_file is defined
|
||||
@@ -0,0 +1,3 @@
|
||||
init_file: /etc/sysconfig/init
|
||||
init_regexp: "^ACTIVE_CONSOLES=.*$"
|
||||
init_replace: ACTIVE_CONSOLES=/dev/tty1
|
||||
@@ -0,0 +1,3 @@
|
||||
init_file: /etc/default/console-setup
|
||||
init_regexp: '^(ACTIVE_CONSOLES="/dev/tty).*'
|
||||
init_replace: \g<1>1
|
||||
@@ -0,0 +1,9 @@
|
||||
- name: update locale info
|
||||
become: true
|
||||
shell: |
|
||||
set -e
|
||||
localedef --list-archive | grep -a -v en_US.utf8 | xargs sudo localedef --delete-from-archive
|
||||
cp /usr/lib/locale/locale-archive{,.tmpl}
|
||||
build-locale-archive
|
||||
when: >
|
||||
ansible_facts['distribution'] in ['CentOS']
|
||||
@@ -0,0 +1,69 @@
|
||||
- name: load vars, if needed
|
||||
include_vars: "{{ item }}"
|
||||
loop:
|
||||
- "{{ role_path }}/vars/default.yml"
|
||||
- "{{ role_path }}/vars/{{ ansible_facts.distribution }}.yml"
|
||||
- "{{ role_path }}/vars/{{ ansible_facts.distribution }}_{{ ansible_facts.distribution_major_version }}.yml"
|
||||
when: item is file
|
||||
|
||||
- name: remove cloud-init
|
||||
become: true
|
||||
package:
|
||||
name: cloud-init
|
||||
state: absent
|
||||
when: ansible_facts.pkg_mgr not in ['atomic_container']
|
||||
|
||||
- name: get build time
|
||||
become: true
|
||||
copy:
|
||||
content: "{{ ansible_facts.date_time.date }}"
|
||||
dest: /etc/vagrant_box_build_time
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
|
||||
- name: create .ssh directory
|
||||
file:
|
||||
path: "{{ ansible_user_dir }}/.ssh"
|
||||
state: directory
|
||||
mode: "0700"
|
||||
|
||||
- name: fetch authorized_keys
|
||||
get_url:
|
||||
mode: "0600"
|
||||
dest: "{{ ansible_user_dir }}/.ssh/authorized_keys"
|
||||
url: https://raw.githubusercontent.com/hashicorp/vagrant/master/keys/vagrant.pub
|
||||
|
||||
- block:
|
||||
- name: configure sshd
|
||||
lineinfile:
|
||||
line: UseDNS no
|
||||
path: /etc/ssh/sshd_config
|
||||
|
||||
- name: check for the sshd_config.d directory
|
||||
stat:
|
||||
path: /etc/ssh/sshd_config.d
|
||||
register: _vagrant_sshd_config_d
|
||||
|
||||
- name: be sure that sshd is configured properly to accept the pubkey
|
||||
copy:
|
||||
content: PubkeyAcceptedKeyTypes +ssh-rsa
|
||||
mode: "0600"
|
||||
owner: root
|
||||
group: root
|
||||
dest: /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf
|
||||
when: _vagrant_sshd_config_d.stat.exists
|
||||
|
||||
- name: enable sshd
|
||||
service:
|
||||
name: "{{ vagrant_ssh_service_name }}"
|
||||
state: started
|
||||
enabled: true
|
||||
# Fedora 31 has a bug in systemd with kernel >= 5.8 that makes us
|
||||
# unable to determine state of the service. However, if we were able
|
||||
# to connect to it to run this Ansible, then we clearly are up
|
||||
# and running and we can safely ignore this error
|
||||
ignore_errors: >-
|
||||
{{ ansible_facts.distribution == 'Fedora' and
|
||||
ansible_facts.distribution_major_version == '31' }}
|
||||
become: true
|
||||
@@ -0,0 +1 @@
|
||||
vagrant_ssh_service_name: ssh
|
||||
@@ -0,0 +1 @@
|
||||
vagrant_ssh_service_name: sshd
|
||||
@@ -0,0 +1,27 @@
|
||||
- name: install build deps for virtualbox addons
|
||||
become: true
|
||||
package:
|
||||
name: "{{ virtualbox_packages }}"
|
||||
state: present
|
||||
|
||||
- name: start services
|
||||
become: true
|
||||
service:
|
||||
name: "{{ item }}"
|
||||
state: started
|
||||
enabled: true
|
||||
loop: "{{ virtualbox_services }}"
|
||||
|
||||
- name: mount iso file
|
||||
become: true
|
||||
command: "{{ item }}"
|
||||
changed_when: false
|
||||
loop:
|
||||
- mount -o loop,ro {{ ansible_user_dir }}/VBoxGuestAdditions.iso /mnt
|
||||
- /mnt/VBoxLinuxAdditions.run
|
||||
- umount /mnt
|
||||
|
||||
- name: remove iso
|
||||
file:
|
||||
name: "{{ ansible_user_dir }}/VBoxGuestAdditions.iso"
|
||||
state: absent
|
||||
@@ -0,0 +1,8 @@
|
||||
virtualbox_packages:
|
||||
- bzip2
|
||||
- dkms
|
||||
- kernel-devel
|
||||
- make
|
||||
- perl
|
||||
virtualbox_services:
|
||||
- dkms
|
||||
@@ -0,0 +1,7 @@
|
||||
virtualbox_packages:
|
||||
- bzip2
|
||||
- dkms
|
||||
- kernel-devel
|
||||
- make
|
||||
virtualbox_services:
|
||||
- dkms
|
||||
@@ -0,0 +1,5 @@
|
||||
virtualbox_packages:
|
||||
- dkms
|
||||
- make
|
||||
virtualbox_services:
|
||||
- dkms
|
||||
@@ -0,0 +1,5 @@
|
||||
- name: create hgfs dir
|
||||
become: true
|
||||
file:
|
||||
state: directory
|
||||
path: /mnt/hgfs
|
||||
@@ -0,0 +1,45 @@
|
||||
- name: create mount point
|
||||
become: true
|
||||
file:
|
||||
path: /mnt/vmware
|
||||
state: directory
|
||||
|
||||
- name: mount iso file
|
||||
become: true
|
||||
command: mount -o loop,ro {{ ansible_user_dir }}/linux.iso /mnt/vmware
|
||||
|
||||
- name: create tmp dir
|
||||
file:
|
||||
path: /tmp/vmware
|
||||
state: directory
|
||||
|
||||
- name: untar tools
|
||||
command: |
|
||||
set -ex
|
||||
tar zxf /mnt/vmware/VMWareTools-*.tar.gz -C /tmp/vmware
|
||||
sudo /tmp/vmware/vmware-tools-distrib/vmware-install.pl --default --force-install
|
||||
rm -r /tmp/vmware
|
||||
sudo umount /mnt/vmware
|
||||
changed_when: false
|
||||
|
||||
- name: remove files
|
||||
become: true
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
loop:
|
||||
- /mnt/vmware
|
||||
- "{{ ansible_user_dir }}/linux.iso"
|
||||
|
||||
- name: add content to /etc/vmware-tools/locations
|
||||
blockinfile:
|
||||
block: |
|
||||
remove_answer ENABLE_VGAUTH
|
||||
answer ENABLE_VGAUTH no
|
||||
remove_answer ENABLE_VMBLOCK
|
||||
answer ENABLE_VMBLOCK no
|
||||
|
||||
- name: finish up installs
|
||||
become: true
|
||||
command: /usr/bin/vmware-config-tools.pl --default --skip-stop-abort
|
||||
changed_when: false
|
||||
@@ -0,0 +1,25 @@
|
||||
- name: read variables
|
||||
include_vars: "{{ item }}"
|
||||
loop:
|
||||
- "{{ role_path }}/vars/{{ ansible_facts.distribution }}.yml"
|
||||
- "{{ role_path }}/vars/{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml"
|
||||
when: item is file
|
||||
|
||||
- name: install vmware related packages
|
||||
become: true
|
||||
package:
|
||||
name: "{{ vmware_packages }}"
|
||||
state: present
|
||||
|
||||
- name: modern systems
|
||||
import_tasks: has_package.yml
|
||||
when: >-
|
||||
ansible_distribution_name == 'fedora' or
|
||||
(ansible_distribution_name == 'debian' and
|
||||
ansible_distribution_major_version > '8')
|
||||
|
||||
- name: legacy builds
|
||||
import_tasks: legacy.yml
|
||||
when: >-
|
||||
(ansible_distribution_name == 'debian' and
|
||||
ansible_distribution_major_version <= '8')
|
||||
@@ -0,0 +1,6 @@
|
||||
vmware_packages:
|
||||
- perl
|
||||
- net-tools
|
||||
- make
|
||||
- gcc
|
||||
- kernel-devel
|
||||
@@ -0,0 +1,2 @@
|
||||
vmware_packages:
|
||||
- open-vm-tools
|
||||
@@ -0,0 +1,4 @@
|
||||
vmware_packages:
|
||||
- perl
|
||||
- make
|
||||
- linux-headers-{{ ansible_architecture }}
|
||||
@@ -0,0 +1,2 @@
|
||||
vmware_packages:
|
||||
- open-vm-tools
|
||||
@@ -0,0 +1,2 @@
|
||||
vmware_packages:
|
||||
- open-vm-tools
|
||||
@@ -0,0 +1,2 @@
|
||||
vmware_packages:
|
||||
- open-vm-tools
|
||||
@@ -0,0 +1,13 @@
|
||||
distro = "ubuntu"
|
||||
arch = "x86_64"
|
||||
version = "20.04"
|
||||
iso = {
|
||||
url = "https://releases.ubuntu.com/20.04/ubuntu-20.04.4-live-server-amd64.iso"
|
||||
checksum = "28ccdb56450e643bad03bb7bcf7507ce3d8d90e8bf09e38f6bd9ac298a98eaad"
|
||||
}
|
||||
boot_wait = "3s"
|
||||
boot_command = [
|
||||
"<enter><enter><wait1><f6><esc><wait><bs><bs><bs><bs>",
|
||||
"autoinstall ds=nocloud-net;s=http://{{.HTTPIP}}:{{.HTTPPort}}/ubuntu/20.04/<enter><wait>"
|
||||
]
|
||||
ssh_handshake_attempts = 1000
|
||||
@@ -0,0 +1 @@
|
||||
d-i preseed/include string ../preseed.cfg
|
||||
@@ -0,0 +1,3 @@
|
||||
d-i preseed/include string ../preseed.cfg
|
||||
|
||||
d-i debian-installer/add-kernel-opts string net.ifnames=0 biosdevname=0
|
||||
@@ -0,0 +1,19 @@
|
||||
d-i preseed/include string /preseed/ubuntu-server-minimalvm.seed
|
||||
d-i preseed/include string ../preseed.cfg
|
||||
|
||||
d-i debian-installer/locale string en_US.UTF-8
|
||||
d-i debian-installer/language string en
|
||||
d-i debian-installer/country string US
|
||||
|
||||
d-i console-setup/ask_detect boolean false
|
||||
|
||||
d-i keyboard-configuration/model select USA
|
||||
d-i keyboard-configuration/layout select USA
|
||||
d-i keyboard-configuration/variant select USA
|
||||
|
||||
d-i grub-installer/bootdev string /dev/vda
|
||||
|
||||
d-i netcfg/choose_interface select auto
|
||||
|
||||
d-i mirror/http/mirror select us.archive.ubuntu.com
|
||||
d-i mirror/http/proxy string
|
||||
@@ -0,0 +1,96 @@
|
||||
#cloud-config
|
||||
# vim: set ft=yaml:
|
||||
autoinstall:
|
||||
version: 1
|
||||
network: # Should disable networking, workaround for unattended-updates failing in install
|
||||
version: 2
|
||||
refresh-installer:
|
||||
update: yes
|
||||
keyboard:
|
||||
layout: us
|
||||
storage:
|
||||
config:
|
||||
- id: drive
|
||||
type: disk
|
||||
ptable: gpt
|
||||
name: hard-drive
|
||||
preserve: false
|
||||
grub_device: true
|
||||
wipe: superblock
|
||||
- id: bios-grub
|
||||
type: partition
|
||||
device: drive
|
||||
size: 1M
|
||||
flag: bios_grub
|
||||
- id: boot-partition
|
||||
type: partition
|
||||
device: drive
|
||||
size: 200M
|
||||
name: boot
|
||||
- id: swap-partition
|
||||
type: partition
|
||||
device: drive
|
||||
size: 10%
|
||||
name: swap
|
||||
flag: swap
|
||||
- id: root-partition
|
||||
type: partition
|
||||
device: drive
|
||||
name: root
|
||||
size: -1
|
||||
- id: boot-format
|
||||
type: format
|
||||
fstype: ext4
|
||||
volume: boot-partition
|
||||
label: boot
|
||||
preserve: false
|
||||
- id: swap-format
|
||||
type: format
|
||||
fstype: swap
|
||||
volume: swap-partition
|
||||
label: swap
|
||||
preserve: false
|
||||
- id: root-format
|
||||
type: format
|
||||
fstype: ext4
|
||||
volume: root-partition
|
||||
label: root
|
||||
preserve: false
|
||||
- type: mount
|
||||
id: root-mount
|
||||
device: root-format
|
||||
path: /
|
||||
- type: mount
|
||||
id: boot-mount
|
||||
device: boot-format
|
||||
path: /boot
|
||||
- type: mount
|
||||
id: swap-mount
|
||||
device: swap-format
|
||||
path: none
|
||||
identity:
|
||||
hostname: vagrant
|
||||
username: vagrant
|
||||
password: $6$rounds=4096$mJTRlY/vwPMquLe0$s4Ld3ZnvF.pM86xzbAgQD7Xpi/NMVgyQNb5CEfabFgL6nLRsP56WtwA.o.Jg/xC6HaJmM2p5fCGIo37jmKVRI0
|
||||
ssh:
|
||||
install-server: yes
|
||||
authorized_keys:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key
|
||||
allow-pw: yes
|
||||
user-data:
|
||||
disable_root: false
|
||||
late-commands:
|
||||
- echo 'Defaults:vagrant !requiretty' > /target/etc/sudoers.d/vagrant
|
||||
- echo 'vagrant ALL=(ALL) NOPASSWD:ALL' >> /target/etc/sudoers.d/vagrant
|
||||
- chmod 440 /target/etc/sudoers.d/vagrant
|
||||
# Restore network after bypassing unattended updates
|
||||
- "echo -n 'network:\n version: 2\n ethernets:\n eth0:\n dhcp4: true\n dhcp-identifier: mac' > /target/etc/netplan/00-installer-config.yaml"
|
||||
- netplan apply
|
||||
- sed -i -E -e 's/GRUB_CMDLINE_LINUX="(.*)"/GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevnames=0\1"/' /target/etc/default/grub
|
||||
- mount -o bind /dev /target/dev
|
||||
- mount -o bind /sys /target/sys
|
||||
- mount -o bind /proc /target/proc
|
||||
- chroot /target /usr/sbin/update-grub
|
||||
packages:
|
||||
- curl
|
||||
- sudo
|
||||
@@ -0,0 +1,60 @@
|
||||
d-i debian-installer/locale string en_US
|
||||
d-i time/zone string UTC
|
||||
|
||||
d-i keyboard-configuration/xkb-keymap select us
|
||||
|
||||
d-i clock-setup/utc boolean true
|
||||
d-i clock-setup/utc-auto boolean true
|
||||
|
||||
d-i debian-installer/missing-provide select ${DEFAULT}
|
||||
|
||||
d-i partman-auto/method string regular
|
||||
d-i partman-auto/expert_recipe string \
|
||||
scheme :: \
|
||||
200 0 200 ext4 \
|
||||
$primary{ } \
|
||||
$bootable{ } \
|
||||
method{ format } \
|
||||
format{ } \
|
||||
use_filesystem{ } \
|
||||
filesystem{ ext4 } \
|
||||
mountpoint{ /boot } . \
|
||||
200% 0 200% linux-swap \
|
||||
$primary{ } \
|
||||
method{ swap } \
|
||||
format{ } . \
|
||||
1 0 -1 ext4 \
|
||||
$primary{ } \
|
||||
method{ format } \
|
||||
format{ } \
|
||||
use_filesystem{ } \
|
||||
filesystem{ ext4 } \
|
||||
mountpoint{ / } .
|
||||
d-i partman-partitioning/confirm_write_new_label boolean true
|
||||
d-i partman/choose_partition select finish
|
||||
d-i partman/confirm boolean true
|
||||
d-i partman/confirm_nooverwrite boolean true
|
||||
|
||||
d-i base-installer/excludes string laptop-detect
|
||||
|
||||
d-i passwd/root-password-again password vagrant
|
||||
d-i passwd/root-password password vagrant
|
||||
d-i passwd/user-fullname string vagrant
|
||||
d-i passwd/username string vagrant
|
||||
d-i passwd/user-password password vagrant
|
||||
d-i passwd/user-password-again password vagrant
|
||||
d-i user-setup/allow-password-weak boolean true
|
||||
|
||||
d-i pkgsel/include string curl openssh-server sudo
|
||||
d-i pkgsel/language-packs multiselect
|
||||
d-i pkgsel/upgrade select full-upgrade
|
||||
d-i pkgsel/update-policy select none
|
||||
tasksel tasksel/first multiselect ubuntu-server
|
||||
|
||||
d-i finish-install/reboot_in_progress note
|
||||
|
||||
d-i preseed/late_command string \
|
||||
echo 'Defaults:vagrant !requiretty' > /target/etc/sudoers.d/vagrant; \
|
||||
echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /target/etc/sudoers.d/vagrant; \
|
||||
chmod 440 /target/etc/sudoers.d/vagrant; \
|
||||
in-target update-initramfs -u
|
||||
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
rm -rf /home/vagrant/.ansible
|
||||
sudo rm -rf /root/.ansible
|
||||
|
||||
#if [[ "${PACKER_BUILD_NAME}" != *"silverblue"* ]]; then
|
||||
sudo dd if=/dev/zero of=/var/EMPTY bs=1M || :
|
||||
sync
|
||||
sudo rm /var/EMPTY
|
||||
sync
|
||||
#fi
|
||||
|
||||
# In CentOS 7, blkid returns duplicate devices
|
||||
swap_device_uuid=`sudo /sbin/blkid -t TYPE=swap -o value -s UUID | uniq`
|
||||
swap_device_label=`sudo /sbin/blkid -t TYPE=swap -o value -s LABEL | uniq`
|
||||
if [ -n "$swap_device_uuid" ]; then
|
||||
swap_device=`readlink -f /dev/disk/by-uuid/"$swap_device_uuid"`
|
||||
elif [ -n "$swap_device_label" ]; then
|
||||
swap_device=`readlink -f /dev/disk/by-label/"$swap_device_label"`
|
||||
fi
|
||||
|
||||
if [ ! -z "${swap_device}" -a -e "${swap_device}" ]; then
|
||||
sudo /sbin/swapoff "$swap_device"
|
||||
sudo dd if=/dev/zero of="$swap_device" bs=1M || :
|
||||
sudo /sbin/mkswap ${swap_device_label:+-L "$swap_device_label"} ${swap_device_uuid:+-U "$swap_device_uuid"} "$swap_device"
|
||||
fi
|
||||
@@ -0,0 +1,113 @@
|
||||
variable "iso" {
|
||||
type = map(string)
|
||||
description = "A map containing the URL and checksum for the ISO file"
|
||||
}
|
||||
|
||||
variable "distro" {
|
||||
type = string
|
||||
default = "unknown"
|
||||
}
|
||||
|
||||
variable "arch" {
|
||||
type = string
|
||||
default = "x86_64"
|
||||
}
|
||||
|
||||
variable "version" {
|
||||
type = string
|
||||
description = "The distro version being specified"
|
||||
}
|
||||
|
||||
variable "boot_wait" {
|
||||
type = string
|
||||
default = "20s"
|
||||
description = "Length of time to wait before entering boot commands"
|
||||
}
|
||||
|
||||
variable "ssh" {
|
||||
type = map(string)
|
||||
default = {
|
||||
username = "vagrant"
|
||||
password = "vagrant"
|
||||
}
|
||||
}
|
||||
|
||||
variable "boot_command" {
|
||||
type = list(string)
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "ssh_handshake_attempts" {
|
||||
type = number
|
||||
default = 100
|
||||
}
|
||||
|
||||
variable "shutdown_command" {
|
||||
type = string
|
||||
default = "sudo systemctl poweroff"
|
||||
}
|
||||
|
||||
variable "disk_size" {
|
||||
type = string
|
||||
default = "20G"
|
||||
}
|
||||
|
||||
variable "headless" {
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
locals {
|
||||
name = "${var.distro}-${var.version}-${var.arch}"
|
||||
}
|
||||
|
||||
source "qemu" "x86_64" {
|
||||
iso_url = var.iso.url
|
||||
iso_checksum = var.iso.checksum
|
||||
output_directory = "output_${local.name}"
|
||||
vm_name = "packer-${local.name}"
|
||||
disk_size = var.disk_size
|
||||
boot_wait = var.boot_wait
|
||||
ssh_timeout = "358m"
|
||||
ssh_username = var.ssh.username
|
||||
ssh_password = var.ssh.password
|
||||
headless = var.headless
|
||||
boot_command = var.boot_command
|
||||
http_directory = "http"
|
||||
ssh_handshake_attempts = var.ssh_handshake_attempts
|
||||
accelerator = "kvm"
|
||||
cpus = 2
|
||||
memory = 2048
|
||||
qemuargs = [["-serial", "stdio"]]
|
||||
shutdown_command = var.shutdown_command
|
||||
}
|
||||
|
||||
build {
|
||||
sources = ["source.qemu.x86_64"]
|
||||
|
||||
provisioner "ansible" {
|
||||
playbook_file = "ansible/playbook.yml"
|
||||
}
|
||||
|
||||
provisioner "shell" {
|
||||
scripts = [
|
||||
"scripts/minimize.sh"
|
||||
]
|
||||
}
|
||||
|
||||
post-processors {
|
||||
post-processor "vagrant" {
|
||||
keep_input_artifact = true
|
||||
compression_level = 9
|
||||
output = "${local.name}.box"
|
||||
vagrantfile_template = "vagrant/${var.arch}.rb"
|
||||
}
|
||||
|
||||
post-processor "vagrant-cloud" {
|
||||
name = "upload"
|
||||
box_tag = "greg-hellings/${local.name}"
|
||||
version = "{{isotime \"2006010203\"}}"
|
||||
version_description = templatefile("../README.box.md")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#!env bash
|
||||
|
||||
set -exo pipefail
|
||||
|
||||
build="${1}"
|
||||
|
||||
#packer build -var-file distros/${build}.pkrvars.hcl -except=upload sources/qemu.pkr.hcl
|
||||
vagrant box add -f --name test ${build}.box
|
||||
vagrant up
|
||||
vagrant ssh -c "ls -la ~/"
|
||||
@@ -0,0 +1,13 @@
|
||||
Vagrant.configure('2') do |config|
|
||||
config.vm.provider :libvirt do |v, override|
|
||||
override.vm.synced_folder '', '/vagrant', disabled: true
|
||||
v.driver = 'qemu'
|
||||
v.machine_arch = 'ppc64'
|
||||
v.machine_type = 'pseries'
|
||||
v.cpu_mode = 'custom'
|
||||
v.cpu_model = 'POWER8'
|
||||
v.video_type = 'vga'
|
||||
#v.qemuargs :value => '-nodefaults'
|
||||
#v.qemuargs :value => '-nographic'
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
Vagrant.configure('2') do |c|
|
||||
c.vm.synced_folder ".", "/home/vagrant/vagrant", type: "rsync"
|
||||
# Set some basic overrides
|
||||
c.vm.provider :libvirt do |v, override|
|
||||
v.driver = 'kvm'
|
||||
v.connect_via_ssh = false
|
||||
v.username = 'root'
|
||||
end
|
||||
c.vm.provider :virtualbox do |v|
|
||||
v.gui = false
|
||||
end
|
||||
c.vm.provider :vmware_fusion do |v|
|
||||
v.gui = false
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
Vagrant.configure('2') do |c|
|
||||
c.vm.synced_folder ".", "/vagrant", type: "rsync"
|
||||
# Set some basic overrides
|
||||
c.vm.provider :libvirt do |v, override|
|
||||
v.driver = 'kvm'
|
||||
v.connect_via_ssh = false
|
||||
v.username = 'root'
|
||||
end
|
||||
c.vm.provider :virtualbox do |v|
|
||||
v.gui = false
|
||||
end
|
||||
c.vm.provider :vmware_fusion do |v|
|
||||
v.gui = false
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user