Puppet 代理考虑使用 exec 安装的旧版本包

Puppet agent considers old version of package installed using exec

我正在尝试通过从源代码构建来安装 autoconf 版本 2.69。安装 autoconf 后,我打算从其源代码构建另一个名为 crmsh 的包。我想使用 Puppet 执行此操作。

我已经编写了一些 classes 使我能够使用 puppet 执行此操作。 class内容如下。

从源下载 autoconf

    class custom-autoconf {
    require custom-packages-1
        exec { "download_autoconf" :
            command => "wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz ; \
                tar xvfvz autoconf-2.69.tar.gz; ",
            path => ["/bin","/usr/bin","/sbin","/usr/sbin"],
            cwd => '/root',
            unless => "test -e /root/autoconf-2.69.tar.gz",
            provider => shell,
    }
    notify { 'autoconf_download' :
        withpath => true,
        name => "download_autoconf",
        message => "Execution of autoconf download completed. "
    }
}

构建 autoconf

    class custom-autoconf::custom-autoconf-2 {
    require custom-autoconf
    exec { "install_autoconf" :
        command => "sh configure ; \
            make && make install ; \
            sleep 5 ; \
            autoconf --version",
        path => ["/bin","/usr/bin","/sbin","/usr/sbin"],
        timeout => 1800,
        logoutput => true,
        cwd => '/root/autoconf-2.69',
        onlyif => "test -d /root/autoconf-2.69",
    provider => shell,
    }
    notify { 'autoconf_install' :
        withpath => true,
        name => "install_autoconf",
        message => "Execution of autoconf install completed. Requires custom-autoconf class completion "
    }
}

下载 crmsh 源

    class custom-autoconf::custom-crmsh {
    require custom-autoconf::custom-autoconf-2
    exec { "clone_crmsh" :
        command => "git clone https://github.com/crmsh/crmsh.git ; ",
        path => ["/bin","/usr/bin","/sbin","/usr/sbin"],
        cwd => '/root',
        unless => "test -d /root/crmsh",
        provider => shell,
    }
    notify { 'crmsh_clone' :
        withpath => true,
        name => "clone_crmsh",
        message => "Execution of git clone https://github.com/crmsh/crmsh.git completed. Requires custom-autoconf-2 "
    }
}

构建 crmsh

    class custom-autoconf::custom-crmsh-1 {
    require custom-autoconf::custom-crmsh
    exec {"build_crmsh" :
        command => "pwd ; \
            autoconf --version ; \
            sleep 5 ; \
            autoconf --version ; \
            sh autogen.sh ; \
            sh configure ; \
            make && make install ; ",
        path => ["/bin","/usr/bin","/sbin","/usr/sbin"],
        require => Class['custom-autoconf::custom-crmsh'],
        cwd => '/root/crmsh',
        onlyif => "test -d /root/crmsh",
        provider => shell,
    }
    notify { 'crmsh_build' :
        withpath => true,
        name => "build_crmsh",
        message => "Execution of crmsh build is complete. Depends on custom-crmsh"
    }
}

问题是 crmsh 构建失败,提示 autoconf 版本为 2.63。注意:/Stage[main]/Custom-autoconf::Custom-crmsh-1/Exec[build_crmsh]/returns: configure.ac:11: error: Autoconf version 2.69 or higher is required

当 puppet 执行完成并出现此故障时,我看到 autoconf 版本为 2.69(这意味着 autoconf 的初始构建成功)。

有人能告诉我为什么 Puppet 认为 autoconf 版本是 2.63 而在系统中是 2.69。或者,我在这里遗漏了什么吗?

其实是我的错。事实证明,autoconf 二进制文件存在于 /usr/bin 和 /usr/local/bin 中。自定义 autoconf 构建在 /usr/local/bin 中创建二进制文件,这在 "path =>" 部分中未提及。由于缺少它,puppet 正在执行 /usr/bin 中存在的 autoconf。在路径中添加 /usr/local/bin 解决了问题。

感谢您的帮助。