Vagrantfile 5.13 KB
Newer Older
Aecio Pires's avatar
   
Aecio Pires committed
1
# Informações
Aecio Pires's avatar
 
Aecio Pires committed
2
3
4
# autor: "Aécio Pires"
# email: http://blog.aeciopires.com/contato
#
Aecio Pires's avatar
   
Aecio Pires committed
5
# OBS.: Execute os comandos a seguir para instalar os plugins
Aecio Pires's avatar
 
Aecio Pires committed
6
7
8
# vagrant plugin install vagrant-disksize
# vagrant plugin install vagrant-vbguest
#
Aecio Pires's avatar
   
Aecio Pires committed
9
# Inicie as VMs com os seguintes comandos
Aecio Pires's avatar
 
Aecio Pires committed
10
11
12
# vagrant init
# vagrant up --provision
#
Aecio Pires's avatar
   
Aecio Pires committed
13
14
15
# Para acessar cada VM via SSH
# vagrant ssh server
# vagrant ssh node
Aecio Pires's avatar
 
Aecio Pires committed
16
17
# vagrant ssh prod
#
Aecio Pires's avatar
   
Aecio Pires committed
18
# Para desligar as VMs
Aecio Pires's avatar
 
Aecio Pires committed
19
20
# vagrant halt
#
Aecio Pires's avatar
   
Aecio Pires committed
21
# Para remover as VMs
Aecio Pires's avatar
 
Aecio Pires committed
22
23
24
# vagrant destroy
#

Aecio Pires's avatar
   
Aecio Pires committed
25
# Verificando e instalando as dependências de plugins do Vagrant
Aecio Pires's avatar
 
Aecio Pires committed
26
27
28
29
30
31
32
required_plugins = %w( vagrant-disksize vagrant-vbguest )
required_plugins.each do |plugin|
  system "vagrant plugin install #{plugin}" unless Vagrant.has_plugin? plugin
  raise "The plugin #{plugin} is required. Please run `vagrant plugin install #{plugin}`"  unless Vagrant.has_plugin? plugin
end

#------------------------------------------------#
Aecio Pires's avatar
   
Aecio Pires committed
33
# Declaração de variáveis
Aecio Pires's avatar
 
Aecio Pires committed
34
35
36
#------------------------------------------------#
Vagrant.require_version ">= 2.0.0"
VAGRANTFILE_API_VERSION = "2"
Aecio Pires's avatar
Aecio Pires committed
37
TIMEOUT = 600
Aecio Pires's avatar
 
Aecio Pires committed
38
39
40
41

# Nome da box (template do S.O) obtido em:
#  https://app.vagrantup.com/boxes/search
BOXNAME     = "aeciopires/ubuntu-18.04-64-puppet"
Aecio Pires's avatar
Aecio Pires committed
42
BOX_VERSION = "3.0.0"
Aecio Pires's avatar
 
Aecio Pires committed
43

Aecio Pires's avatar
   
Aecio Pires committed
44
# Endereço da rede das máquinas virtuais
Aecio Pires's avatar
 
Aecio Pires committed
45
46
47
NET_ADDRESS = "192.168.56"

# Tamanho do HD da VM
Aecio Pires's avatar
Aecio Pires committed
48
DISKSIZE = "30GB"
Aecio Pires's avatar
 
Aecio Pires committed
49

Aecio Pires's avatar
   
Aecio Pires committed
50
# Diretório de origem do seu host.
Aecio Pires's avatar
   
Aecio Pires committed
51
# Pode ser um diretório com path (caminho) relativo no qual está o arquivo Vagranfile
Aecio Pires's avatar
 
Aecio Pires committed
52
53
# ou pode ser um path (caminho) completo.
#
Aecio Pires's avatar
   
Aecio Pires committed
54
# O conteúdo das pastas será sincronizado após a execução de um dos comandos a seguir
Aecio Pires's avatar
 
Aecio Pires committed
55
56
57
58
# --> vagrant up
# --> vagrant reload
DIR_SOURCE = "data/"

Aecio Pires's avatar
   
Aecio Pires committed
59
# Diretório destino dentro da VM
Aecio Pires's avatar
 
Aecio Pires committed
60
61
DIR_DESTINY = "/vagrant"

Aecio Pires's avatar
   
Aecio Pires committed
62
# Diretório relativo dos manifests Puppet
Aecio Pires's avatar
 
Aecio Pires committed
63
64
DIR_MANIFESTS = "manifests_puppet"

Aecio Pires's avatar
   
Aecio Pires committed
65
# Nome do manifest Puppet
Aecio Pires's avatar
 
Aecio Pires committed
66
67
MANIFEST = "livro.pp"

Aecio Pires's avatar
   
Aecio Pires committed
68
# Definindo o locale da VM, independente do host hospedeiro
Aecio Pires's avatar
 
Aecio Pires committed
69
70
71
72
73
ENV["LC_ALL"] = "en_US.UTF-8"
#------------------------------------------------#


#*******************************#
Aecio Pires's avatar
   
Aecio Pires committed
74
# Início das configurações das VMs
Aecio Pires's avatar
 
Aecio Pires committed
75
76
77
78
79
80
81
82
#*******************************#

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  #---------------------------------------
  # Criando a VM ci-server
  config.vm.define :server, primary: true do |server_config|
    server_config.vm.provider "virtualbox" do |vb|
Aecio Pires's avatar
Aecio Pires committed
83
        vb.memory = '4096'
Aecio Pires's avatar
 
Aecio Pires committed
84
85
        vb.cpus   = '1'
        vb.name   = 'ci-server.domain.com.br'
86
        #vb.customize ["modifyvm", :id, "--ioapic", "on"]
87
        vb.customize [ "modifyvm", :id, "--uartmode1", "disconnected" ]
Aecio Pires's avatar
 
Aecio Pires committed
88
89
    end

Aecio Pires's avatar
Aecio Pires committed
90
    server_config.disksize.size       = DISKSIZE
Aecio Pires's avatar
 
Aecio Pires committed
91
92
    server_config.vm.hostname         = 'ci-server.domain.com.br'
    server_config.vm.box              = BOXNAME
Aecio Pires's avatar
Aecio Pires committed
93
    server_config.vm.boot_timeout     = TIMEOUT
Aecio Pires's avatar
 
Aecio Pires committed
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
    server_config.vm.box_check_update = true
    server_config.vm.box_version      = BOX_VERSION
    server_config.vm.network "private_network", ip: "#{NET_ADDRESS}.10"
    server_config.vm.synced_folder DIR_SOURCE, DIR_DESTINY

    config.vm.provision "puppet" do |puppet|
      puppet.manifests_path = DIR_MANIFESTS
      puppet.manifest_file  = MANIFEST
      puppet.options        = "--verbose --debug"
    end
  end

  #---------------------------------------
  # Criando a VM node-ubuntu
  config.vm.define :node, primary: true do |node_config|
    node_config.vm.provider "virtualbox" do |vb|
        vb.memory = '2048'
        vb.cpus   = '1'
        vb.name   = 'node-ubuntu.domain.com.br'
113
        #vb.customize ["modifyvm", :id, "--ioapic", "on"]
114
        vb.customize [ "modifyvm", :id, "--uartmode1", "disconnected" ]
Aecio Pires's avatar
 
Aecio Pires committed
115
116
    end

Aecio Pires's avatar
Aecio Pires committed
117
    node_config.disksize.size       = DISKSIZE
Aecio Pires's avatar
 
Aecio Pires committed
118
119
    node_config.vm.hostname         = 'node-ubuntu.domain.com.br'
    node_config.vm.box              = BOXNAME
Aecio Pires's avatar
Aecio Pires committed
120
    node_config.vm.boot_timeout     = TIMEOUT
Aecio Pires's avatar
 
Aecio Pires committed
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
    node_config.vm.box_check_update = true
    node_config.vm.box_version      = BOX_VERSION
    node_config.vm.network "private_network", ip: "#{NET_ADDRESS}.11"
    node_config.vm.synced_folder DIR_SOURCE, DIR_DESTINY

    config.vm.provision "puppet" do |puppet|
      puppet.manifests_path = DIR_MANIFESTS
      puppet.manifest_file  = MANIFEST
      puppet.options        = "--verbose --debug"
    end
  end

  #---------------------------------------
  # Criando a VM prod
  config.vm.define :prod, primary: true do |prod_config|
    prod_config.vm.provider "virtualbox" do |vb|
        vb.memory = '1024'
        vb.cpus   = '1'
        vb.name   = 'prod.domain.com.br'
140
        #vb.customize ["modifyvm", :id, "--ioapic", "on"]
141
        vb.customize [ "modifyvm", :id, "--uartmode1", "disconnected" ]
Aecio Pires's avatar
 
Aecio Pires committed
142
143
    end

Aecio Pires's avatar
Aecio Pires committed
144
    prod_config.disksize.size       = DISKSIZE
Aecio Pires's avatar
 
Aecio Pires committed
145
146
    prod_config.vm.hostname         = 'prod.domain.com.br'
    prod_config.vm.box              = BOXNAME
Aecio Pires's avatar
Aecio Pires committed
147
    prod_config.vm.boot_timeout     = TIMEOUT
Aecio Pires's avatar
 
Aecio Pires committed
148
149
150
151
152
153
154
155
156
157
158
159
160
    prod_config.vm.box_check_update = true
    prod_config.vm.box_version      = BOX_VERSION
    prod_config.vm.network "private_network", ip: "#{NET_ADDRESS}.12"
    prod_config.vm.synced_folder DIR_SOURCE, DIR_DESTINY

    config.vm.provision "puppet" do |puppet|
      puppet.manifests_path = DIR_MANIFESTS
      puppet.manifest_file  = MANIFEST
      puppet.options        = "--verbose --debug"
    end
  end

end