benbaker76 / k8s-cluster

A collection of Ansible scripts I wrote for creating a k8s cluster
10 stars 6 forks source link

Vagrantfile #1

Open jeremy-donson opened 1 year ago

jeremy-donson commented 1 year ago

Is there an accompanying Vagrantfile for local efforts using VirtualBox?

? If so, then we would use the vagrant features that support ansible....

node.vm.provision "ansible" do |ansible|

Useful Reference

Separating master and worker ansible playbooks also seems wise.

EG:

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "geerlingguy/ubuntu1404"
  config.vbguest.auto_update = false
  config.ssh.insert_key = false

  config.vm.provider :virtualbox do |v|
    v.name = "gogs"
    v.memory = 512
    v.cpus = 2
    v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
    v.customize ["modifyvm", :id, "--ioapic", "on"]
  end

  config.vm.hostname = "gogs"
  config.vm.network :private_network, ip: "192.168.56.23"

  # Set the name of the VM. See: http://stackoverflow.com/a/17864388/100134
  config.vm.define :gogs do |gogs|
  end

  # Ansible provisioner.
  config.vm.provision "ansible" do |ansible|
    ansible.compatibility_mode = "2.0"
    ansible.playbook = "provisioning/playbook.yml"
    ansible.inventory_path = "provisioning/inventory"
    ansible.become = true
  end

end
benbaker76 commented 1 year ago

I was looking into using Terraform and terraform-provider-libvirt but Vagrant looks interesting.

I do have master and worker playbooks separated.

The way I'm provisioning infrastructure is in my k8s-vm repo which uses a shell script to call virt-install along with a custom version of Ubuntu 22.04 iso configured using cloud-config (which also allows me to have pre-installed ssh keys).

I'll take a look at converting my libvirt virt-install.sh script to a Vagrantfile. Once I get that working I can look into VirtualBox.

benbaker76 commented 1 year ago

I've created a Vagrantfile for libvirt. For now I haven't added support for calling the Ansible playbooks. Feel free to do a pull request for a VirtualBox version.