|
| 1 | +# -*- mode: ruby -*- |
| 2 | +# vi: set ft=ruby : |
| 3 | + |
| 4 | +VAGRANTFILE_API_VERSION = "2" |
| 5 | + |
| 6 | +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| |
| 7 | + config.vm.box = "centos/stream9" |
| 8 | + config.vm.box_url = "https://cloud.centos.org/centos/9-stream/x86_64/images/CentOS-Stream-Vagrant-9-latest.x86_64.vagrant-libvirt.box" |
| 9 | + #config.vm.box_url = "file:///$VagrantProjectHome/../CentOS-Stream-Vagrant-8-latest.x86_64.vagrant-libvirt.box" |
| 10 | + |
| 11 | + |
| 12 | + # Forward traffic on the host to the development server on the guest |
| 13 | + config.vm.network "forwarded_port", guest: 5000, host: 5000 |
| 14 | + # Forward traffic on the host to Redis on the guest |
| 15 | + config.vm.network "forwarded_port", guest: 6379, host: 6379 |
| 16 | + # Forward traffic on the host to the SSE server on the guest |
| 17 | + config.vm.network "forwarded_port", guest: 8080, host: 8080 |
| 18 | + |
| 19 | + |
| 20 | + if Vagrant.has_plugin?("vagrant-hostmanager") |
| 21 | + config.hostmanager.enabled = true |
| 22 | + config.hostmanager.manage_host = true |
| 23 | + end |
| 24 | + |
| 25 | + # Vagrant can share the source directory using rsync, NFS, or SSHFS (with the vagrant-sshfs |
| 26 | + # plugin). By default it rsyncs the current working directory to /vagrant. |
| 27 | + # |
| 28 | + # If you would prefer to use NFS to share the directory uncomment this and configure NFS |
| 29 | + # config.vm.synced_folder ".", "/vagrant", type: "nfs", nfs_version: 4, nfs_udp: false |
| 30 | + config.vm.synced_folder "..", "/vagrant" |
| 31 | + # config.vm.synced_folder ".", "/vagrant", disabled: true |
| 32 | + # config.vm.synced_folder ".", "/srv/pagure", |
| 33 | + # ssh_opts_append: "-o IdentitiesOnly=yes", |
| 34 | + # type: "sshfs" |
| 35 | + |
| 36 | + # To cache update packages (which is helpful if frequently doing `vagrant destroy && vagrant up`) |
| 37 | + # you can create a local directory and share it to the guest's DNF cache. The directory needs to |
| 38 | + # exist, so create it before you uncomment the line below. |
| 39 | + #Dir.mkdir('.dnf-cache') unless File.exists?('.dnf-cache') |
| 40 | + #config.vm.synced_folder ".dnf-cache", "/var/cache/dnf", |
| 41 | + # type: "sshfs", |
| 42 | + # sshfs_opts_append: "-o nonempty" |
| 43 | + |
| 44 | + # Comment this line if you would like to disable the automatic update during provisioning |
| 45 | + # config.vm.provision "shell", inline: "sudo dnf -y --disablerepo '*' --enablerepo=extras swap centos-linux-repos centos-stream-repos" |
| 46 | + |
| 47 | + # !!!!!!! resize disk image !!!!!!!!! |
| 48 | + config.vm.provision "shell", inline: "sudo dnf install -y cloud-utils-growpart" |
| 49 | + config.vm.provision "shell", inline: "sudo growpart /dev/vda 1" |
| 50 | + config.vm.provision "shell", inline: "sudo resize2fs /dev/vda1" |
| 51 | + # config.vm.provision "shell", inline: "sudo xfs_growfs /dev/vda1" # this was for CentOS Stream 8 |
| 52 | + |
| 53 | + # bootstrap and run with ansible |
| 54 | + config.vm.provision "ansible" do |ansible| |
| 55 | + # ansible.verbose = "-vvv" |
| 56 | + ansible.verbose = true |
| 57 | + ansible.playbook = "../playbooks/oc-cluster-setup.yml" |
| 58 | + ansible.extra_vars = {"user": "vagrant"} |
| 59 | + end |
| 60 | + config.vm.provision "ansible" do |ansible| |
| 61 | + # ansible.verbose = "-vvv" |
| 62 | + ansible.verbose = true |
| 63 | + ansible.playbook = "../playbooks/oc-cluster-run.yml" |
| 64 | + ansible.raw_arguments = ['--extra-vars', 'user=vagrant', '--extra-vars', '@../secrets/openshift-local-pull-secret.yml'] |
| 65 | + end |
| 66 | + config.vm.provision "ansible" do |ansible| |
| 67 | + # ansible.verbose = "-vvv" |
| 68 | + ansible.become = true |
| 69 | + ansible.become_user = "root" |
| 70 | + ansible.verbose = true |
| 71 | + ansible.playbook = "../playbooks/oc-cluster-tests-setup.yml" |
| 72 | + end |
| 73 | + |
| 74 | + # Create the box |
| 75 | + config.vm.define "packit-oc-cluster" do |oc| |
| 76 | + oc.vm.host_name = "packit-oc-cluster.example.com" |
| 77 | + |
| 78 | + oc.vm.provider :libvirt do |domain| |
| 79 | + # Season to taste |
| 80 | + domain.cpus = 6 |
| 81 | + domain.graphics_type = "spice" |
| 82 | + domain.memory = 14336 |
| 83 | + domain.video_type = "qxl" |
| 84 | + domain.machine_virtual_size = 100 |
| 85 | + |
| 86 | + # Uncomment the following line if you would like to enable libvirt's unsafe cache |
| 87 | + # mode. It is called unsafe for a reason, as it causes the virtual host to ignore all |
| 88 | + # fsync() calls from the guest. Only do this if you are comfortable with the possibility of |
| 89 | + # your development guest becoming corrupted (in which case you should only need to do a |
| 90 | + # vagrant destroy and vagrant up to get a new one). |
| 91 | + # |
| 92 | + # domain.volume_cache = "unsafe" |
| 93 | + end |
| 94 | + end |
| 95 | +end |
0 commit comments