Add Vagrantfile for testing

Also fix some edge cases when testing
This commit is contained in:
Hoang Nguyen 2022-02-27 19:20:25 +07:00
parent 55fcacf5a0
commit 9796d5beb0
No known key found for this signature in database
GPG Key ID: 813CF484F4993419
7 changed files with 64 additions and 6 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.vagrant/
host_vars/

View File

@ -6,7 +6,7 @@ This is an Ansible playbook to deploy system configurations for desktop usage.
- Have a fresh installation of Alpine (after running `setup-alpine` and reboot)
- Install `ansible-core` and `git`
- Install `ansible` and `git`
- Clone this repository
@ -23,13 +23,32 @@ This is an Ansible playbook to deploy system configurations for desktop usage.
- Run the playbook:
```bash
ansible-playbook -i hosts setup.yml
ansible-playbook setup.yml
```
- Reboot and login as the newly created normal user
- Proceed with [dotfiles-ansible](https://git.disroot.org/FollieHiyuki/dotfiles-ansible) playbook
## ✔️ Testing
- You need to have [Vagrant](https://www.vagrantup.com/) installed, with [vagrant-libvirt](https://github.com/vagrant-libvirt/vagrant-libvirt) plugin.
- Run the playbook inside the VM:
```bash
# Start the VM and ssh into it
vagrant up
# ssh into the VM (requires OpenSSH)
# Alternatively run 'vagrant ssh-config' to get the machine IP address
# and manually ssh into it, e.g. 'dbclient -y vagrant@<ip_address>'
vagrant ssh
# Run the playbook as root
cd /vagrant
sudo ansible-playbook -v setup.yml
```
## 🖊️ Notes
- This playbook assumes that the person running it is me 😃. It might do specific tasks that you don't like. Use with your own risks.

26
Vagrantfile vendored Normal file
View File

@ -0,0 +1,26 @@
$provision_script = <<-SCRIPT
rc-service openntpd stop && rc-update del openntpd && apk del openntpd
apk add ansible grub
mkdir -pv /vagrant/host_vars
echo \"vault_password: \'123456\'\" > /vagrant/host_vars/localhost.yml
SCRIPT
Vagrant.configure("2") do |config|
config.vm.define :sysconfig do |sysconfig|
sysconfig.vm.box = "generic/alpine315"
sysconfig.vm.provider :libvirt do |libvirt|
libvirt.cpus = 2
libvirt.memory = 512
# Use the default NAT network of libvirt
libvirt.management_network_name = "default"
libvirt.management_network_address = "192.168.122.0/24"
end
sysconfig.vm.provision "shell", inline: $provision_script
end
config.vm.synced_folder ".", "/vagrant", type: "rsync",
rsync__exclude: [".git/", "Vagrantfile", ".gitignore"]
end

View File

@ -35,7 +35,6 @@ libvirt_daemons:
password: '{{ vault_password }}'
# Do NOT change these variables ───────────────────────────────────────────────
# elogind needs polkit to function

View File

@ -7,14 +7,18 @@
group: root
mode: 0644
- name: essential | Upgrade the system
apk:
available: yes
upgrade: yes
update_cache: yes
- name: essential | Install common dependencies
apk:
name: >-
doas, nftables, zstd, fish, dbus, terminus-font, apparmor-profiles,
apparmor, openresolv, libvirt-daemon, qemu-img, qemu-system-x86_64,
qemu-modules, shadow-login, unbound, dns-root-hints
available: yes
update_cache: yes
qemu-modules, shadow-login, unbound, dns-root-hints, eudev
state: present
- name: essential | Start services on runlevel 'default'

View File

@ -7,6 +7,14 @@
group: root
mode: 0644
- name: grub | Ensure fonts directory exists
file:
path: /boot/grub/fonts
state: directory
owner: root
group: root
mode: 0755
# Download a release from https://github.com/source-foundry/Hack
# Decompress the archive
# Run: grub-mkfont -o hack.pf2 -s 24 Hack-Regular.ttf