User Tools

Site Tools


environment_ansible

This is an old revision of the document!


Cenário

Vagrantfile
$ vim Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
 
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'libvirt'
 
vms = {
  'ansible-server' => {'memory' => '4096', 'cpus' => 2, 'ip' => '200', 'box' => 'g3anmart1ns/ubuntu22'},
  'ub-vm-01' => {'memory' => '2048', 'cpus' => 2, 'ip' => '201', 'box' => 'g3anmart1ns/ubuntu22'},
  'ol-vm-02' => {'memory' => '2048', 'cpus' => 2, 'ip' => '202', 'box' => 'g3anmart1ns/ol9'},
  'de-vm-03' => {'memory' => '2048', 'cpus' => 2, 'ip' => '203', 'box' => 'g3anmart1ns/debian11'}
}
 
Vagrant.configure('2') do |config|
 
  config.vm.box_check_update = false
 
  vms.each do |name, conf|
    config.vm.define "#{name}" do |k|
      k.vm.box = "#{conf['box']}"
      k.vm.hostname = "#{name}"
      k.vm.network 'private_network', ip: "10.240.0.#{conf['ip']}"
      k.vm.provider 'libvirt' do |lb|
        lb.memory = conf['memory']
        lb.cpus = conf['cpus']
      end
    end
  end
  config.vm.synced_folder ".", "/vagrant", disabled: true
end
$ vagrant up
$ vagrant status
Current machine states:
 
ansible-server            running (libvirt)
ub-vm-01                  running (libvirt)
ol-vm-02                  running (libvirt)
de-vm-03                  running (libvirt)

Referências

environment_ansible.1753560543.txt.gz · Last modified: by wikiadm