File: Vagrantfile

package info (click to toggle)
puppet-module-michaeltchapman-galera 0.7.1-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 316 kB
  • sloc: ruby: 453; sh: 79; makefile: 4
file content (132 lines) | stat: -rw-r--r-- 4,790 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# -*- mode: ruby -*-
# vi: set ft=ruby :

# Change this to swap between a centos and an ubuntu box
box = 'puppetlabs/centos-7.0-64-puppet'
#box = 'trusty64'

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.define "control1" do |control1|
    control1.vm.box = box
    control1.vm.network "private_network", ip: "192.168.99.101"
    control1.vm.provider "virtualbox" do |v|
      v.customize ['modifyvm', :id ,'--memory','1024']
    end
    control1.vm.hostname = 'control1'

    control1.vm.provision :shell do |shell|
      shell.inline = 'cp -r /vagrant/modules/* /etc/puppet/modules; ' +
               'ln -s /vagrant /etc/puppet/modules/galera'
    end

    if box == 'precise64' or box == 'trusty64'
      control1.vm.provision :shell do |shell|
        script =
        "if grep 127.0.1.1 /etc/hosts ; then \n" +
        " sed -i -e \"s/127.0.1.1.*/127.0.1.1 control1.domain.name control1/\" /etc/hosts\n" +
        "else\n" +
        "  echo '127.0.1.1 control1.domain.name control1' >> /etc/hosts\n" +
        "fi ;"
        shell.inline = script
      end
    elsif  (box == 'centos64' or box == 'puppetlabs/centos-7.0-64-puppet')
      control1.vm.provision :shell do |shell|
        shell.inline = "echo '192.168.99.101 control1.domain.name control1' > /etc/hosts;" +
                       "echo '127.0.0.1 control1 localhost localhost.localdomain localhost4 localhost4.localdomain4' >> /etc/hosts;" +
                       "echo '::1 localhost localhost.localdomain localhost6 localhost6.localdomain6' >> /etc/hosts;"
      end
    end

    if ENV['http_mirror']
        if box == 'precise64'
          control1.vm.provision :shell do |shell|
            shell.inline = "sed -i 's/us.archive.ubuntu.com/%s/g' /etc/apt/sources.list" % ENV['http_mirror']
          end
        end
    end

    if ENV['http_proxy']
        if box == 'precise64'
          control1.vm.provision :shell do |shell|
            shell.inline = 'echo "Acquire::http { Proxy \"http://%s\"; };" > /etc/apt/apt.conf.d/01apt-cacher-ng-proxy;' % ENV['http_proxy']
          end
      end
    end

    if  (box == 'centos64' or box == 'puppetlabs/centos-7.0-64-puppet')
      control1.vm.provision :shell do |shell|
        shell.inline = 'puppet apply /vagrant/examples/centos7.pp'
      end
    else
      control1.vm.provision :shell do |shell|
        shell.inline = 'puppet apply /vagrant/examples/site.pp'
      end
    end

  end

  config.vm.define "control2" do |control2|
    control2.vm.box = box
    control2.vm.network "private_network", ip: "192.168.99.102"
    control2.vm.provider "virtualbox" do |v|
      v.customize ['modifyvm', :id ,'--memory','1024']
    end

    control2.vm.hostname = 'control2'

    control2.vm.provision :shell do |shell|
      shell.inline = 'cp -r /vagrant/modules/* /etc/puppet/modules; ' +
               'ln -s /vagrant /etc/puppet/modules/galera'
    end

    if box == 'precise64' or box == 'trusty64'
      control2.vm.provision :shell do |shell|
        script =
        "if grep 127.0.1.1 /etc/hosts ; then \n" +
        " sed -i -e \"s/127.0.1.1.*/127.0.1.1 control2.domain.name control2/\" /etc/hosts\n" +
        "else\n" +
        "  echo '127.0.1.1 control2.domain.name control2' >> /etc/hosts\n" +
        "fi ;"
        shell.inline = script
      end
    end

    if (box == 'centos64' or box == 'puppetlabs/centos-7.0-64-puppet')
      control2.vm.provision :shell do |shell|
        shell.inline = "echo '192.168.99.102 control2.domain.name control2' > /etc/hosts;" +
                       "echo '127.0.0.1 control2 localhost localhost.localdomain localhost4 localhost4.localdomain4' >> /etc/hosts;" +
                       "echo '::1 localhost localhost.localdomain localhost6 localhost6.localdomain6' >> /etc/hosts;"
      end
    end

    if ENV['http_mirror']
        if box == 'precise64'
          control1.vm.provision :shell do |shell|
            shell.inline = "sed -i 's/us.archive.ubuntu.com/%s/g' /etc/apt/sources.list" % ENV['http_mirror']
          end
        end
    end

    if ENV['http_proxy']
        if box == 'precise64'
          control1.vm.provision :shell do |shell|
            shell.inline = 'echo "Acquire::http { Proxy \"http://%s\"; };" > /etc/apt/apt.conf.d/01apt-cacher-ng-proxy;' % ENV['http_proxy']
          end
      end
    end

    if  (box == 'centos64' or box == 'puppetlabs/centos-7.0-64-puppet')
      control2.vm.provision :shell do |shell|
        shell.inline = 'puppet apply /vagrant/examples/centos7.pp'
      end
    else
      control2.vm.provision :shell do |shell|
        shell.inline = 'puppet apply /vagrant/examples/site.pp'
      end
    end

  end
end