# Apt\_repository resource causes chef run failure

**URL:** <https://discourse.chef.io/t/apt-repository-resource-causes-chef-run-failure/21760>\
**Category:** Chef Infra Client\
**Created:** [January 19, 2023, 1:26pm UTC](https://discourse.chef.io/t/apt-repository-resource-causes-chef-run-failure/21760 "2023-01-19T13:26:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![blackknight36](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/blackknight36/32/3333_2.png) [@blackknight36](https://discourse.chef.io/u/blackknight36)\
**Post date:** [January 19, 2023, 1:26pm UTC](https://discourse.chef.io/t/apt-repository-resource-causes-chef-run-failure/21760/1 "2023-01-19T13:26:17Z")

</div>

After adding a apt\_repository resource to one of our recipes client nodes are now returning a chef failure as follows.

```auto
================================================================================
    Error executing action `add` on resource 'apt_repository[ffmpeg4-repository]'
    ================================================================================
    
    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    execute[install-key 374C7797FB006459] (/opt/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.6.18/lib/chef/resource/apt_repository.rb line 305) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '2'
    ---- Begin output of apt-key adv --no-tty --recv --keyserver hkp://keyserver.ubuntu.com:80 374C7797FB006459 ----
    STDOUT: Executing: /tmp/apt-key-gpghome.eaZG1jysyT/gpg.1.sh --no-tty --recv --keyserver hkp://keyserver.ubuntu.com:80 374C7797FB006459
    STDERR: Warning: apt-key output should not be parsed (stdout is not a terminal)
    gpg: keyserver receive failed: No data
    ---- End output of apt-key adv --no-tty --recv --keyserver hkp://keyserver.ubuntu.com:80 374C7797FB006459 ----
    Ran apt-key adv --no-tty --recv --keyserver hkp://keyserver.ubuntu.com:80 374C7797FB006459 returned 2

```

Is there a way to avoid this? The apt-key is required for installation and we do not want to disable gpg checks. The resources are defined as follows.

```auto
apt_repository 'ffmpeg4-repository' do
  uri node['ffmpeg4']['apt_uri']
  distribution node['foo']['dist_release']
  components %w(main)
  key '374C7797FB006459'
  keyserver 'keyserver.ubuntu.com'
  action :add
end

apt_repository 'ffmpeg5-repository' do
  uri node['ffmpeg5']['apt_uri']
  distribution node['foo']['dist_release']
  components %w(main)
  key '374C7797FB006459'
  keyserver 'keyserver.ubuntu.com'
  action :add
end

```
