Adds VirtualBox Vagrant box build configuration

Also added the "upgrade_and_reboot" role that upgrades all
packages and reboots a VM if something has been upgraded.
pull/1/head
Eugene Zamriy 1 year ago
parent eef59510ca
commit ec903e2a0e
Signed by: ezamriy
GPG Key ID: 7EBF95C7DCFA496C

1
.gitignore vendored

@ -1,2 +1,3 @@
.vscode .vscode
*.box *.box
ansible/roles/ezamriy.vbox_guest

@ -65,6 +65,12 @@ variables.
### Building Vagrant boxes ### Building Vagrant boxes
VirtualBox Vagrant box build command:
```shell
$ packer build -only=virtualbox-iso.msvsphere-9-vagrant-x86_64 .
```
VMWare Vagrant box build command: VMWare Vagrant box build command:
```shell ```shell

@ -1,3 +1,4 @@
--- ---
collections: [] collections: []
roles: [] roles:
- name: ezamriy.vbox_guest

@ -0,0 +1,13 @@
# upgrade_and_reboot
An Ansible role that upgrades all packages to their latest versions and
reboots a host.
## Role Variables
Role variables and their default values are listed below:
* `reboot_connect_timeout: 5` - number of seconds to sleep before retrying check.
* `reboot_timeout: 600` - maximum number of seconds to wait for a host return.
* `reboot_post_reboot_delay: 15` - number of seconds to wait before starting checking.

@ -0,0 +1,5 @@
---
reboot_connect_timeout: 5
reboot_pre_reboot_delay: 60
reboot_post_reboot_delay: 60
reboot_timeout: 600

@ -0,0 +1,19 @@
galaxy_info:
role_name: upgrade_and_reboot
author: Eugene Zamriy
description: Upgrades all packages, reboots a host and waits for it to return
license: MIT
min_ansible_version: '2.7'
platforms:
- name: EL
versions:
- '8'
- '9'
galaxy_tags:
- reboot
- upgrade
dependencies: []

@ -0,0 +1,14 @@
---
- name: Upgrade packages
ansible.builtin.dnf:
name: '*'
state: latest
register: system_upgrade
- name: Reboot host
ansible.builtin.reboot:
connect_timeout: "{{ reboot_connect_timeout }}"
pre_reboot_delay: "{{ reboot_pre_reboot_delay }}"
post_reboot_delay: "{{ reboot_post_reboot_delay }}"
reboot_timeout: "{{ reboot_timeout }}"
when: system_upgrade.changed

@ -4,6 +4,9 @@
become: true become: true
roles: roles:
- upgrade_and_reboot
- role: ezamriy.vbox_guest
when: packer_provider == 'virtualbox-iso'
- role: vmware_guest - role: vmware_guest
when: packer_provider == 'vmware-iso' when: packer_provider == 'vmware-iso'
- nfs_client - nfs_client

@ -2,6 +2,32 @@
* Packer template for building MSVSphere 9 Vagrant boxes. * Packer template for building MSVSphere 9 Vagrant boxes.
*/ */
source "virtualbox-iso" "msvsphere-9-vagrant-x86_64" {
iso_url = var.iso_url_9_x86_64
iso_checksum = var.iso_checksum_9_x86_64
boot_command = var.vagrant_boot_cmd_9_x86_64_bios
boot_wait = var.boot_wait
cpus = var.cpus
memory = var.memory
disk_size = var.vagrant_disk_size
headless = var.headless
http_directory = var.http_directory
guest_os_type = "RedHat_64"
shutdown_command = var.vagrant_shutdown_command
ssh_username = var.vagrant_ssh_username
ssh_password = var.vagrant_ssh_password
ssh_timeout = var.ssh_timeout
hard_drive_interface = "sata"
iso_interface = "sata"
vboxmanage = [
["modifyvm", "{{.Name}}", "--nat-localhostreachable1", "on"],
]
vboxmanage_post = [
["modifyvm", "{{.Name}}", "--memory", var.post_memory],
["modifyvm", "{{.Name}}", "--cpus", var.post_cpus]
]
}
source "vmware-iso" "msvsphere-9-vagrant-x86_64" { source "vmware-iso" "msvsphere-9-vagrant-x86_64" {
iso_url = var.iso_url_9_x86_64 iso_url = var.iso_url_9_x86_64
iso_checksum = var.iso_checksum_9_x86_64 iso_checksum = var.iso_checksum_9_x86_64
@ -30,6 +56,7 @@ source "vmware-iso" "msvsphere-9-vagrant-x86_64" {
build { build {
sources = [ sources = [
"sources.virtualbox-iso.msvsphere-9-vagrant-x86_64",
"sources.vmware-iso.msvsphere-9-vagrant-x86_64" "sources.vmware-iso.msvsphere-9-vagrant-x86_64"
] ]

Loading…
Cancel
Save