0

私はさまざまな仮想ボックスを試し、大量の構成を変更しました (おそらく、再作成、再ロード、および再プロビジョニングを 50 ~ 100 回行いました)。これは、Puppet の MySQL モジュールに関係しています。だから私がしていることは間違っています。

VagrantFile

# -*- mode: ruby -*-
# vi: set ft=ruby :

# 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|
  # Every Vagrant virtual environment requires a box to build off of.
  config.vm.box = "puppetlabs/ubuntu-14.04-64-puppet"

  # Was necessary
  #vagrant plugin install vagrant-vbguest

  # Networking
  config.vm.network "forwarded_port", guest: 80, host: 8000
  # config.vm.network "private_network", ip: "192.168.33.10"

  # Synced folders
  config.vm.synced_folder ".", "/var/www"

  # Update
  config.vm.provision "shell", inline: "apt-get -y update"

  # Provisioning
   config.vm.provision :shell do |shell|
    shell.inline = "mkdir -p /etc/puppet/modules;
                    (puppet module install example42-puppi; true)
                    (puppet module install example42-apache; true)
                    (puppet module install example42-php; true)
                    (puppet module install puppetlabs-stdlib; true)
                    (puppet module install puppetlabs-mysql; true)
                    (puppet module install saz-vim; true)
                    (puppet module install saz-timezone; true)
                    (puppet module install puppetlabs-git; true)
                    (puppet module install tPl0ch-composer; true)
                     "
  end

  config.vm.provision "puppet" do |puppet|
      puppet.facter = {
        "fqdn" => "development.mydomain.com",
        "aliases" => "*.development.mydomain.com",
        "hostname" => "www",
        "docroot" => '/var/www/html/',
      }
      puppet.hiera_config_path = "manifests/hiera.yaml"
      puppet.working_directory = "/etc/puppet"
    end
end

パペットファイル: default.pp

###########################
# MySite Puppet Config    #
###########################
# OS          : Ubuntu 14 #
# Database    : MySQL 5   #
# Web Server  : Apache 2  #
# PHP version : 5.4       #
###########################

# Vim
class { 'vim': }

# Set Timezone
class { 'timezone':
    timezone => 'America/Chicago',
}

# Puppi
class { 'puppi': }

# Apache setup
class { "apache":
  puppi        => true,
  puppi_helper => "myhelper",
}

apache::vhost { $fqdn :
  docroot => $docroot,
  server_name => $fqdn,
  serveraliases => $aliases,
  priority            => '',
  template            => 'apache/virtualhost/vhost.conf.erb',
}

apache::module { 'rewrite': }
apache::module { 'headers': }

# PHP Extensions
class {"php":}

php::module { ['xdebug', 'mysql', 'curl', 'gd', 'mcrypt']:
  notify => Service['apache2']
}

# MySQL Server
class { '::mysql::server':
  package_ensure  => present,
  root_password     => '[root_password]',
  override_options  => { 'mysqld' => { 'default_time_zone' => 'America/Chicago' } },
}

class { 'mysql::client':}

mysql::db { '[db_name]':
  user     => '[user]',
  password => '[password]',
  host     => 'localhost',
  grant    => ['ALL'],
  charset => 'utf8',
}

exec { "database_import":
  timeout => 300,
  command => "/bin/gzip -dc /vagrant/manifests/provision.sql.gz | /usr/bin/mysql -u root -p[root_password]";
}

mysql::db { '[db_test]':
  user     => '[user_test]',
  password => '[password_test]',
  host     => 'localhost',
  grant    => ['ALL'],
  charset => 'utf8',
  sql  => "/var/www/test/db-schema.sql",
}

# Install Composer components
include composer

composer::exec { 'install':
    cmd                  => 'install',  # REQUIRED
    cwd                  => '/var/www', # REQUIRED
    dev                  => true, # Install dev dependencies
}

# Git
include git

# MySite Setup
file { $docroot:
  ensure  => 'directory',
}

$writeable_dirs = ["${docroot}cache/", "${docroot}cache/css/", "${docroot}cache/css/js/"]

file { $writeable_dirs:
  ensure => "directory",
  mode   => '0777',
  require => File[$docroot],
}

file { '/var/www/cl/':
  ensure  => directory
}

file { 'errors_log':
  path    => "/var/www/cl/errors.log",
  ensure  => present,
  mode    => 0777,
}

# Cron Jobs
cron { thirty_minutes:
  command => "/usr/bin/php ${docroot}cl-load.php crons/thirty_minutes/",
  user  => root,
  minute => '*/30'
}

cron { hourly:
  command => "/usr/bin/php ${docroot}cl-load.php crons/hourly/",
  user  => root,
  hour => '*',
  minute => 0,
}

cron { four_hours:
  command => "/usr/bin/php ${docroot}cl-load.php crons/four_hours/",
  user  => root,
  hour => '*/4',
  minute => 0,
}

cron { daily:
  command => "/usr/bin/php ${docroot}cl-load.php crons/daily/",
  user  => root,
  monthday => '*',
  hour => '0',
  minute => 0,
}

これが私が受け取っているエラーメッセージです(最初):

==> ==> default: Error: Could not start Service[mysqld]: Execution of '/sbin/start mysql' returned 1:
4

1 に答える 1

0

MySQL サーバー パッケージをインストールする前に、Puppet がデータベースをインポートしようとしているようです。

Puppet は、最初にどのリソースを書き込むかを気にしないことに注意してください。特定の順序で何かを管理する必要がある場合は、関係を明示的に宣言する必要があります。したがって、あなたの場合、次のステートメント:

exec { "database_import":
  timeout => 300,
  command => "/bin/gzip -dc /vagrant/manifests/provision.sql.gz | /usr/bin/mysql -u root -p[root_password]",
  require => Class['::mysql::server']
}

そのリソースの正しい順序を設定できました。おそらく、同様の方法で追加の関係を宣言する必要があります。

于 2014-07-03T08:44:50.417 に答える