zoukankan      html  css  js  c++  java
  • Create Virtual Machines with Vagrant and Puppet

    Create the following puppet manifest and start VM with vagrant, you get a base production environment.

    $ pwd
    
    /home/chad/docs/vagrant-prj/gcpserver
    
    
    
    $ cat Vagrantfile|grep -v '^s*#'
    
    VAGRANTFILE_API_VERSION = "2"
    
    Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    
      config.vm.box = "precise64"
    
      config.vm.network :public_network
    
      config.vm.provision "puppet"
    
    end
    
    
    
    $ cat manifests/default.pp
    
    package { 'vsftpd':
    
      ensure => installed,
    
    }
    
    service { 'vsftpd':
    
      ensure => running,
    
      require => Package['vsftpd'],
    
    }
    
    user { "gcp":
    
      ensure     => "present",
    
      password   => 'gcp',
    
      managehome => true,
    
    }
    
    
    
    $ vagrant init
    
    $ vagrant up
    

    But the password doesn't work, see User Password Management Fails in Puppet for reason.

    You have to modify password for user 'gcp' manually.

    The type of network is written as "bridged" in api version 1 style.

    Create multiple VMs

    To specify hostname, memory size and some other parameters of each VM, modify Vagrantfile like this:

    $ cat Vagrantfile|grep -v '^s*#'
    
    VAGRANTFILE_API_VERSION = "2"
    
    Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    
      config.vm.box = "precise64"
    
    
    
      config.vm.define "bvtserver" do |bvtserver|
    
        bvtserver.vm.hostname = "bvt-server"
    
        bvtserver.vm.network :public_network
    
        bvtserver.vm.provision :shell, path: "bvtprov.sh"
    
      end
    
    
    
      config.vm.define "production" do |production|
    
        production.vm.hostname = "gcp-server"
    
        production.vm.network :public_network
    
        production.vm.provision :puppet
    
        production.vm.provider :virtualbox do |vbox|
    
          vbox.customize ["modifyvm", :id, "--name", "ProductEnv", "--memory", 1024]
    
        end
    
      end
    
    end
    

    And add a shell script for provisioning of bvt server:

    $ cat bvtprov.sh
    
    echo "You can do some provisioning here"
    

    Ref:

    http://stackoverflow.com/questions/16740397/vagrant-network-type-bridged-is-invalid-please-use-a-valid-network-type

    http://stackoverflow.com/questions/18700060/seting-up-vm-hostname-undefined-method-hostname

  • 相关阅读:
    C# TCP/IP 服务端 和 客户端
    (trigger)触发器的定义和作用
    AD账号登陆验证
    DES加密&解密字符串
    机器视觉(工业视觉)需要什么技能
    机器视觉对位贴合
    Halcon blob分析基本处理步骤
    cross_val_score 交叉验证与 K折交叉验证,嗯都是抄来的,自己作个参考
    50道SQL练习题及答案与详细分析(MySQL)
    MySQL8.0 ROW_NUMBER、RANK、DENSE_RANK窗口函数 分组排序排名
  • 原文地址:https://www.cnblogs.com/darkmatter/p/3606800.html
Copyright © 2011-2022 走看看