无法在我的Puppet代码上安装依赖项

时间:2019-03-29 19:49:39

标签: vagrant puppet devops vagrantfile

我正在学习一本有关DevOps的书,并且正在锁定插入Vagrantfile文件中的代码。我试图以几种方式解决它,但是我没有成功。我没有解决问题的办法,这是我大学工作的基础。 有趣的是,我正在使用Puppet

在我的木偶代码下面:

exec { "apt-update":
    command => "/usr/bin/apt-get update"
}
package { "mysql-server":
    ensure => installed,
    require => Exec["apt-update"],
}

file { "/etc/mysql/conf.d/allow_external.cnf":
    owner => mysql,
    group => mysql,
    mode => 0644,
    content => template("/vagrant/manifests/allow_ext.cnf"),
    require => Package["mysql-server"],
    notify => Service["mysql"],
}

service { "mysql":
    ensure => running,
    enable => true,
    hasstatus => true,
    hasrestart => true,
    require => Package["mysql-server"],
}

exec { "loja-schema":
    unless => "mysql -uroot loja_schema",
    command => "mysqladmin -uroot create loja_schema",
    path => "/usr/bin/",
    require => Service["mysql"],
}
exec { "remove-anonymous-user":
    command => "mysql -uroot -e \"DELETE FROM mysql.user \
                                                                WHERE user=’’; \
                                                                FLUSH PRIVILEGES\"",
    onlyif => "mysql -u’ ’",
    path => "/usr/bin",
    require => Service["mysql"],
}
exec { "loja-user":
    unless => "mysql -uloja -plojasecret loja_schema",
    command => "mysql -uroot -e \"GRANT ALL PRIVILEGES ON \
                                                            loja_schema.* TO ’loja’@’%’ \
                                                            IDENTIFIED BY ’lojasecret’;\"",
    path => "/usr/bin/",
    require => Exec["loja-schema"],
}

0 个答案:

没有答案