【问题标题】:Error to cloning project with puppet on vagrant在 vagrant 上使用 puppet 克隆项目时出错
【发布时间】:2016-08-08 16:29:18
【问题描述】:

我正在尝试安装 django 并使用 puppet 脚本克隆一个 github 项目。我使用的模块如下:

  • 文件
    • (空目录)
  • 清单
    • nodes.pp
    • web.pp
  • 模块
    • django
      • 清单
        • init.pp
      • 文件
        • (空目录)
    • 混帐
      • 清单
        • init.pp
      • 文件
        • (空目录)
    • postgres

web.pp 文件中我有:

import ' nodes.pp '

nodes.pp 文件中我有:

node default {
        include postgres
        include git
        include django
    }

在 git 文件夹内的 Manifests 文件夹中的 init.pp 文件中,我有以下代码:

class git{
    include git::install
}

class git::install{
    package { 'git:':
        ensure => present
    }
}

define git::clone ( $path, $dir){
    exec { "clone-$name-$path":
        command => "/usr/bin/git clone git@github.com:$name $path/$dir",
        creates => "$path/$dir",
        require => [Class["git"], File[$path]],
    }
}

在 django 文件夹内的 Manifests 文件夹中的 init.pp 文件中,我有以下代码:

class django{
    include django::install, django::clone, django::environment
}

class django::install {
    package { [ "python", "python-dev", "python-virtualenv", "python-pip",
                "python-psycopg2", "python-imaging"]:
        ensure => present,
    }
}

class django::clone {
    git::clone { 'My GitHub repository name':
        path => '/home/vagrant/',
        dir => 'django',
    }
}

 define django::virtualenv( $path ){
     exec { "create-ve-$path":
         command => "/usr/bin/virtualenv -q $name",
         cwd => $path,
         creates => "$path/$name",
         require => [Class["django::install"]],
     }
 }

class django::environment {
    django::virtualenv{ 've':
        path => '/usr/local/app',
    }
}

要运行脚本木偶,我使用以下命令:

sudo puppet apply --modulepath=/vagrant/modules /vagrant/manifests/web.pp

并运行此命令,我得到以下 错误

Could not find dependency File[/home/vagrant/] for 
Exec[clone-My GitHub repository name-/home/vagrant/] at 
/vagrant/modules/git/manifests/init.pp:16

注意:“我的 GitHub 存储库名称”在哪里,我的 github 存储库的名称是正确的。

出了什么问题,我该如何解决这个问题?

【问题讨论】:

    标签: django git vagrant puppet


    【解决方案1】:

    在您定义的 git::clone 中,您确定为 $path 声明文件资源吗?

    你应该有:

    file { $path: ensure => directory }
    

    你不能要求你没有特别注意的资源

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-27
      • 2018-07-21
      • 2019-01-09
      • 2023-03-25
      • 2011-06-21
      • 1970-01-01
      • 2016-01-05
      • 2019-07-14
      相关资源
      最近更新 更多