首页 > 解决方案 > Puppet 无法获取 gpg 密钥

问题描述

我正在使用 puppet https://www.getenvoy.io/install/envoy/ubuntu/自动执行以下任务

curl -sL 'https://getenvoy.io/gpg' | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://dl.bintray.com/tetrate/getenvoy-deb \
$(lsb_release -cs) \
stable"
sudo apt-get update && sudo apt-get install -y getenvoy-envoy

我有以下木偶课

class envoy::install {

  apt::source { "envoy-${::lsbdistcodename}":
    location => 'https://dl.bintray.com/tetrate/getenvoy-deb',
    release  => $::lsbdistcodename,
    repos    => 'stable',
    key      => {
      'server' => 'https://getenvoy.io/gpg',
      'id'     => '5270CEAC57F63EBD9EA9005D0253D0B26FF974DB'
    }
  }

}

服务器 urlhttps://getenvoy.io/gpg似乎无效,因为模块返回

erver Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, 
assert_type(): expects a match for 
Pattern[/\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$/], got 'https://getenvoy.io/gpg' (file: /srv/puppetmaster/current/environments/envoy_apt/modules/apt/manifests/key.pp, line: 23, column: 5)

如果我更改https://getenvoy.io/gpghttps://getenvoy.io, puppet 不再出错,而是返回

Error: Execution of '/usr/bin/apt-key adv --keyserver https://getenvoy.io --recv-keys 5270CEAC57F63EBD9EA9005D0253D0B26FF974DB' returned 2: Warning: apt-key output should not be parsed (stdout is not a terminal)
Executing: /tmp/apt-key-gpghome.DYIyo3MINv/gpg.1.sh --keyserver https://getenvoy.io --recv-keys 5270CEAC57F63EBD9EA9005D0253D0B26FF974DB
gpg: no valid OpenPGP data found.

puppet 是否有机制支持未存储在网站根目录中的 gpg 密钥?我怎样才能在道路上获得apt::source支持?/gpg

更新

sudo apt-key adv --keyserver https://getenvoy.io/gpg --recv 6FF974DB
Executing: /tmp/apt-key-gpghome.7zAas2TfeV/gpg.1.sh --keyserver https://getenvoy.io/gpg --recv 6FF974DB
gpg: key 0253D0B26FF974DB: public key "GetEnvoy <getenvoy@tetrate.io>" imported
gpg: Total number processed: 1
gpg:               imported: 1

sudo apt-key adv --keyserver https://getenvoy.io --recv 6FF974DB
Executing: /tmp/apt-key-gpghome.DG7UFZ6Ogz/gpg.1.sh --keyserver https://getenvoy.io --recv 6FF974DB
gpg: no valid OpenPGP data found.
gpg: Total number processed: 0
sudo apt-key adv --keyserver https://getenvoy.io/gpg --recv 5270CEAC57F63EBD9EA9005D0253D0B26FF974DB
Executing: /tmp/apt-key-gpghome.eCuCy44ieF/gpg.1.sh --keyserver https://getenvoy.io/gpg --recv 5270CEAC57F63EBD9EA9005D0253D0B26FF974DB
gpg: key 0253D0B26FF974DB: "GetEnvoy <getenvoy@tetrate.io>" not changed
gpg: Total number processed: 1
gpg:              unchanged: 1

标签: puppetgnupgapt-key

解决方案


我能够通过拆分apt::sourceapt::key

  apt::key {'getenvoy':
    id      => '5270CEAC57F63EBD9EA9005D0253D0B26FF974DB',
    source  => 'https://getenvoy.io/gpg',
  }->
  apt::source { "envoy-${::lsbdistcodename}":
    location => 'https://dl.bintray.com/tetrate/getenvoy-deb',
    release  => $::lsbdistcodename,
    repos    => 'stable',
    notify   => [
      Class['apt::update'],
    ]
  }

推荐阅读