jarosser06 / chef-sysdig

Install sysdig
4 stars 9 forks source link

apt_repository distribution value breaks "apt-get update" #12

Open jeremiahsnapp opened 7 years ago

jeremiahsnapp commented 7 years ago

https://github.com/jarosser06/chef-sysdig/blob/master/recipes/default.rb#L42-L47

Recent versions of Chef Client include a core apt_repository resource instead of requiring the resource that came with the apt cookbook. The new core resource calculates a default value for the distribution property, "yakkety" in my case, which results in a /etc/apt/sources.list.d/sysdig.list that looks like this.

deb      "http://download.draios.com/stable/deb" yakkety stable-$(ARCH)/

This causes the subsequent apt-get update to fail every time.

        Expected process to exit with [0], but received '100'
        ---- Begin output of apt-get -q update ----
        STDOUT: Hit:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu yakkety InRelease
        Hit:2 http://us-east-1.ec2.archive.ubuntu.com/ubuntu yakkety-updates InRelease
        Hit:3 http://us-east-1.ec2.archive.ubuntu.com/ubuntu yakkety-backports InRelease
        Get:4 http://security.ubuntu.com/ubuntu yakkety-security InRelease [102 kB]
        Ign:5 http://download.draios.com/stable/deb stable-amd64/ InRelease
        Ign:6 http://download.draios.com/stable/deb yakkety InRelease
        Hit:7 http://download.draios.com/stable/deb stable-amd64/ Release
        Ign:8 http://download.draios.com/stable/deb yakkety Release
        Get:9 http://download.draios.com/stable/deb stable-amd64/ Release.gpg [490 B]
        Ign:10 http://download.draios.com/stable/deb yakkety/stable-$(ARCH)/ all Packages
        Ign:11 http://download.draios.com/stable/deb yakkety/stable-$(ARCH)/ amd64 Packages
        Ign:12 http://download.draios.com/stable/deb yakkety/stable-$(ARCH)/ Translation-en
        Ign:10 http://download.draios.com/stable/deb yakkety/stable-$(ARCH)/ all Packages
        Ign:11 http://download.draios.com/stable/deb yakkety/stable-$(ARCH)/ amd64 Packages
        Ign:12 http://download.draios.com/stable/deb yakkety/stable-$(ARCH)/ Translation-en
        Ign:10 http://download.draios.com/stable/deb yakkety/stable-$(ARCH)/ all Packages
        Ign:11 http://download.draios.com/stable/deb yakkety/stable-$(ARCH)/ amd64 Packages
        Ign:12 http://download.draios.com/stable/deb yakkety/stable-$(ARCH)/ Translation-en
        Ign:10 http://download.draios.com/stable/deb yakkety/stable-$(ARCH)/ all Packages
        Ign:11 http://download.draios.com/stable/deb yakkety/stable-$(ARCH)/ amd64 Packages
        Ign:12 http://download.draios.com/stable/deb yakkety/stable-$(ARCH)/ Translation-en
        Ign:10 http://download.draios.com/stable/deb yakkety/stable-$(ARCH)/ all Packages
        Ign:11 http://download.draios.com/stable/deb yakkety/stable-$(ARCH)/ amd64 Packages
        Ign:12 http://download.draios.com/stable/deb yakkety/stable-$(ARCH)/ Translation-en
        Ign:10 http://download.draios.com/stable/deb yakkety/stable-$(ARCH)/ all Packages
        Err:11 http://download.draios.com/stable/deb yakkety/stable-$(ARCH)/ amd64 Packages
          403  Forbidden
        Ign:12 http://download.draios.com/stable/deb yakkety/stable-$(ARCH)/ Translation-en
        Fetched 103 kB in 0s (211 kB/s)
        Reading package lists...
        STDERR: W: The repository 'http://download.draios.com/stable/deb yakkety Release' does not have a Release file.
        E: Failed to fetch http://download.draios.com/stable/deb/dists/yakkety/stable-$(ARCH)//binary-amd64/Packages  403  Forbidden
        E: Some index files failed to download. They have been ignored, or old ones used instead.
        ---- End output of apt-get -q update ----
        Ran apt-get -q update returned 100

I found that when I set the distribution property to false I get the correct /etc/apt/sources.list.d/sysdig.list file which looks like this.

deb      "http://download.draios.com/stable/deb" stable-$(ARCH)/

And apt-get update no longer fails.

        [execute] Hit:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu yakkety InRelease
                  Get:2 http://us-east-1.ec2.archive.ubuntu.com/ubuntu yakkety-updates InRelease [102 kB]
                  Get:3 http://us-east-1.ec2.archive.ubuntu.com/ubuntu yakkety-backports InRelease [102 kB]
                  Ign:4 http://download.draios.com/stable/deb stable-amd64/ InRelease
                  Get:5 http://download.draios.com/stable/deb stable-amd64/ Release [756 B]
                  Get:6 http://security.ubuntu.com/ubuntu yakkety-security InRelease [102 kB]
                  Get:7 http://download.draios.com/stable/deb stable-amd64/ Release.gpg [490 B]
                  Get:8 http://download.draios.com/stable/deb stable-amd64/ Packages [2108 B]
                  Fetched 310 kB in 0s (638 kB/s)
                  Reading package lists...
       [2017-02-10T20:42:41+00:00] INFO: execute[apt-get -q update] ran successfully

Would you mind making your code look like this to fix the issue?

    apt_repository 'sysdig' do
      uri node['sysdig']['apt']['uri']
      components node['sysdig']['apt']['components']
      distribution false
      key node['sysdig']['apt']['key']
      not_if "apt-key list | grep -i #{node['sysdig']['apt']['key_id']}"
    end

Full disclosure, I haven't tested what impact this would have for anyone still using the old/deprecated apt_repository resource provided by the apt cookbook.

Thanks a lot!

jarosser06 commented 7 years ago

When I get a free moment I will take a look at this.