vagrantfile如何在vagrant机器中存储更改?

vagrantfile如何在vagrant机器中存储更改?,vagrant,vagrantfile,Vagrant,Vagrantfile,我正在用PhP开发一个应用程序,客户端要求我设置一台vagrant机器,并安装所有需要的扩展和模块,这样只需一个vagrant up命令,客户端就可以拥有与我相同的环境 我首先从lsit的一个盒子里安装了一台流浪机器 vagrant box add ubuntu1 http://goo.gl/KwQSa2 然后我运行以下命令: vagrant init ubuntu1 vagrant up 在我创建此文件的目录中,只有一个vagranrfile 问题是: 我需要知

我正在用PhP开发一个应用程序,客户端要求我设置一台vagrant机器,并安装所有需要的扩展和模块,这样只需一个vagrant up命令,客户端就可以拥有与我相同的环境

我首先从lsit的一个盒子里安装了一台流浪机器

  vagrant box add ubuntu1 http://goo.gl/KwQSa2
然后我运行以下命令:

      vagrant init ubuntu1
      vagrant up
在我创建此文件的目录中,只有一个vagranrfile 问题是: 我需要知道我是否对我的服务器进行了任何更改,例如,安装php或mysql,它将如何保存在设置中,这样,如果我将此文件交给我的客户机,他将能够在安装了所有内容的情况下拥有与我相同的机器

我的意思是会有任何变化,以流浪汉文件或我犯了一些错误,我必须安装一台机器与木偶


Vagrant文件是一个配方,告诉Vagrant如何设置您的机器。在某种程度上,它可以作为一个安装自动化工具(当然也可以做得更多)。如果在机器创建后对其进行任何更改,Vagrant将不会知道这一点

我要做的是创建Vagrant文件,并在其中指定一个shell脚本,在机器第一次启动后,Vagrant只执行一次

VAGRANTFILE_API_VERSION = "2"

$bootstrap = <<SCRIPT

# Installing all dependencies and other required software.
# Add "-y" switch to make sure installation is fully automatic.
apt-get install -y python-software-properties

# Any other stuff I might want to do (like edit conf files)
...

SCRIPT

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
     config.vm.box = "precise64"
     config.vm.provision "shell", inline: $bootstrap
end
VAGRANTFILE\u API\u VERSION=“2”
$bootstrap=Vagrant文件是一个告诉Vagrant如何设置您的机器的配方。在某种程度上,它可以作为一个安装自动化工具(当然也可以做得更多)。如果在机器创建后对其进行任何更改,Vagrant将不会知道这一点

我要做的是创建Vagrant文件,并在其中指定一个shell脚本,在机器第一次启动后,Vagrant只执行一次

VAGRANTFILE_API_VERSION = "2"

$bootstrap = <<SCRIPT

# Installing all dependencies and other required software.
# Add "-y" switch to make sure installation is fully automatic.
apt-get install -y python-software-properties

# Any other stuff I might want to do (like edit conf files)
...

SCRIPT

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
     config.vm.box = "precise64"
     config.vm.provision "shell", inline: $bootstrap
end
VAGRANTFILE\u API\u VERSION=“2”
$bootstrap=Vagrant文件是一个告诉Vagrant如何设置您的机器的配方。在某种程度上,它可以作为一个安装自动化工具(当然也可以做得更多)。如果在机器创建后对其进行任何更改,Vagrant将不会知道这一点

我要做的是创建Vagrant文件,并在其中指定一个shell脚本,在机器第一次启动后,Vagrant只执行一次

VAGRANTFILE_API_VERSION = "2"

$bootstrap = <<SCRIPT

# Installing all dependencies and other required software.
# Add "-y" switch to make sure installation is fully automatic.
apt-get install -y python-software-properties

# Any other stuff I might want to do (like edit conf files)
...

SCRIPT

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
     config.vm.box = "precise64"
     config.vm.provision "shell", inline: $bootstrap
end
VAGRANTFILE\u API\u VERSION=“2”
$bootstrap=Vagrant文件是一个告诉Vagrant如何设置您的机器的配方。在某种程度上,它可以作为一个安装自动化工具(当然也可以做得更多)。如果在机器创建后对其进行任何更改,Vagrant将不会知道这一点

我要做的是创建Vagrant文件,并在其中指定一个shell脚本,在机器第一次启动后,Vagrant只执行一次

VAGRANTFILE_API_VERSION = "2"

$bootstrap = <<SCRIPT

# Installing all dependencies and other required software.
# Add "-y" switch to make sure installation is fully automatic.
apt-get install -y python-software-properties

# Any other stuff I might want to do (like edit conf files)
...

SCRIPT

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
     config.vm.box = "precise64"
     config.vm.provision "shell", inline: $bootstrap
end
VAGRANTFILE\u API\u VERSION=“2”
$bootstrap=不,在VM中安装东西时,vagrant文件不会更改

如果你想让你的客户机拥有与你相同的机器,你必须避免通过虚拟机外壳安装软件。您应该只对所有内容使用provisioner,,甚至mysql表、apache虚拟主机等

不要使用
vagrant框添加ubuntu1http://goo.gl/KwQSa2
,将框的url添加到Vagrant文件中,其中包含:

config.vm.box_url = "http://goo.gl/KwQSa2"
mysql/php服务器的木偶配置示例:

    group { 'puppet':
    ensure => 'present',
}

#
# Apache configuration
#
class { 'apache' :
    default_mods => false,
    default_confd_files => false,
    mpm_module => 'prefork',
    default_vhost => false,
    sendfile => 'Off'
}
class { 'apache::mod::php' : } # mod_php
class { 'apache::mod::rewrite' : } # mod_rewrite

# VHost configuration
apache::vhost { 'dev.XXX.fr' :
    port => '80',
    docroot => '/var/sites/myXXX/web',
    access_log => true,
    access_log_file => 'XXX_access.log',
    error_log => true,
    error_log_file => 'XXX_error.log',
    aliases => [{alias => '/myXXX', path => '/var/sites/toto/web'}],
    directories => [{path => '/var/sites/myXXX/web', 'allow_override' => ['FileInfo', 'Indexes']}, {path => '/var/sites/toto/web', 'allow_override' => ['FileInfo', 'Indexes']}]
}

#
# Mysql configuration
#
class { '::mysql::server' :
    root_password => 'XXX',
    databases => {
        'XXX' => {
            ensure => 'present',
            charset => 'utf8'
        }
    },
    users => {
        'XXX@localhost' => {
            ensure => 'present',
            password_hash => 'XXX' # XXXmdp
        }
    },
    grants => {
        'XXX@localhost/XXX' => {
            ensure => 'present',
            options => ['GRANT'],
            privileges => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'CREATE'],
            table      => 'XXX.*',
            user       => 'XXX@localhost'
        }
    }
}

class { '::mysql::client' : }

package { 'php5-mysql' :
    require => [Class['apache::mod::php'], Class['::mysql::server']],
    ensure => 'present'
}
您将需要以下模块:

  • 阿帕奇
  • 海螺
  • mysql
  • stdlib
上面的puppet配置只是一个示例,我强烈建议您阅读这些文档,它们做得非常好:

老实说,木偶是一个很好的工具,花点时间去学习吧


还有一件事,避免使用shell provisionner,每次运行“vagrant provision”时都会执行命令,puppet只执行更改。(我只使用shell provisionner进行apt-get-update和apt-get-upgrade)

不,在VM中安装东西时,vagrant文件不会更改

如果你想让你的客户机拥有与你相同的机器,你必须避免通过虚拟机外壳安装软件。您应该只对所有内容使用provisioner,,甚至mysql表、apache虚拟主机等

不要使用
vagrant框添加ubuntu1http://goo.gl/KwQSa2
,将框的url添加到Vagrant文件中,其中包含:

config.vm.box_url = "http://goo.gl/KwQSa2"
mysql/php服务器的木偶配置示例:

    group { 'puppet':
    ensure => 'present',
}

#
# Apache configuration
#
class { 'apache' :
    default_mods => false,
    default_confd_files => false,
    mpm_module => 'prefork',
    default_vhost => false,
    sendfile => 'Off'
}
class { 'apache::mod::php' : } # mod_php
class { 'apache::mod::rewrite' : } # mod_rewrite

# VHost configuration
apache::vhost { 'dev.XXX.fr' :
    port => '80',
    docroot => '/var/sites/myXXX/web',
    access_log => true,
    access_log_file => 'XXX_access.log',
    error_log => true,
    error_log_file => 'XXX_error.log',
    aliases => [{alias => '/myXXX', path => '/var/sites/toto/web'}],
    directories => [{path => '/var/sites/myXXX/web', 'allow_override' => ['FileInfo', 'Indexes']}, {path => '/var/sites/toto/web', 'allow_override' => ['FileInfo', 'Indexes']}]
}

#
# Mysql configuration
#
class { '::mysql::server' :
    root_password => 'XXX',
    databases => {
        'XXX' => {
            ensure => 'present',
            charset => 'utf8'
        }
    },
    users => {
        'XXX@localhost' => {
            ensure => 'present',
            password_hash => 'XXX' # XXXmdp
        }
    },
    grants => {
        'XXX@localhost/XXX' => {
            ensure => 'present',
            options => ['GRANT'],
            privileges => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'CREATE'],
            table      => 'XXX.*',
            user       => 'XXX@localhost'
        }
    }
}

class { '::mysql::client' : }

package { 'php5-mysql' :
    require => [Class['apache::mod::php'], Class['::mysql::server']],
    ensure => 'present'
}
您将需要以下模块:

  • 阿帕奇
  • 海螺
  • mysql
  • stdlib
上面的puppet配置只是一个示例,我强烈建议您阅读这些文档,它们做得非常好:

老实说,木偶是一个很好的工具,花点时间去学习吧


还有一件事,避免使用shell provisionner,每次运行“vagrant provision”时都会执行命令,puppet只执行更改。(我只使用shell provisionner进行apt-get-update和apt-get-upgrade)

不,在VM中安装东西时,vagrant文件不会更改

如果你想让你的客户机拥有与你相同的机器,你必须避免通过虚拟机外壳安装软件。您应该只对所有内容使用provisioner,,甚至mysql表、apache虚拟主机等

不要使用
vagrant框添加ubuntu1http://goo.gl/KwQSa2
,将框的url添加到Vagrant文件中,其中包含:

config.vm.box_url = "http://goo.gl/KwQSa2"
mysql/php服务器的木偶配置示例:

    group { 'puppet':
    ensure => 'present',
}

#
# Apache configuration
#
class { 'apache' :
    default_mods => false,
    default_confd_files => false,
    mpm_module => 'prefork',
    default_vhost => false,
    sendfile => 'Off'
}
class { 'apache::mod::php' : } # mod_php
class { 'apache::mod::rewrite' : } # mod_rewrite

# VHost configuration
apache::vhost { 'dev.XXX.fr' :
    port => '80',
    docroot => '/var/sites/myXXX/web',
    access_log => true,
    access_log_file => 'XXX_access.log',
    error_log => true,
    error_log_file => 'XXX_error.log',
    aliases => [{alias => '/myXXX', path => '/var/sites/toto/web'}],
    directories => [{path => '/var/sites/myXXX/web', 'allow_override' => ['FileInfo', 'Indexes']}, {path => '/var/sites/toto/web', 'allow_override' => ['FileInfo', 'Indexes']}]
}

#
# Mysql configuration
#
class { '::mysql::server' :
    root_password => 'XXX',
    databases => {
        'XXX' => {
            ensure => 'present',
            charset => 'utf8'
        }
    },
    users => {
        'XXX@localhost' => {
            ensure => 'present',
            password_hash => 'XXX' # XXXmdp
        }
    },
    grants => {
        'XXX@localhost/XXX' => {
            ensure => 'present',
            options => ['GRANT'],
            privileges => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'CREATE'],
            table      => 'XXX.*',
            user       => 'XXX@localhost'
        }
    }
}

class { '::mysql::client' : }

package { 'php5-mysql' :
    require => [Class['apache::mod::php'], Class['::mysql::server']],
    ensure => 'present'
}
您将需要以下模块:

  • 阿帕奇
  • 海螺
  • mysql
  • stdlib
上面的puppet配置只是一个示例,我强烈建议您阅读这些文档,它们做得非常好:

老实说,木偶是一个很好的工具,花点时间去学习吧

还有一件事,避免使用shell provisionner,每次运行“vagrant provision”时都会执行命令,puppet只执行更改。(我仅将shell provisionner用于