ymotongpoo / setup

Yoshi's personal setup for development environment
Apache License 2.0
0 stars 0 forks source link

Add apt repository check #3

Open ymotongpoo opened 3 years ago

ymotongpoo commented 3 years ago

InSpec apt resource fails with hashicorp and docker apt repository settings.

  ×  apt-installation: apt installation check (4 failed)
     ×  Apt Repository https://download.docker.com/linux/debian is expected to exist
     expected Apt Repository https://download.docker.com/linux/debian to exist
     ×  Apt Repository https://download.docker.com/linux/debian is expected to be enabled
     expected that `Apt Repository https://download.docker.com/linux/debian` is enabled
     ×  Apt Repository https://apt.releases.hashicorp.com is expected to exist
     expected Apt Repository https://apt.releases.hashicorp.com to exist
     ×  Apt Repository https://apt.releases.hashicorp.com is expected to be enabled
     expected that `Apt Repository https://apt.releases.hashicorp.com` is enabled

The code to check apt repository is like this:

    repositories = [
        'https://download.docker.com/linux/debian',
        'https://apt.releases.hashicorp.com',
    ]

    repositories.each do |r|
        describe apt(r) do
            it { should exist }
            it { should be_enabled }
        end
    end
ymotongpoo commented 3 years ago

I confirmed they are in the files under /etc/apt/sources.list.d and listed up in apt-cache policy

🍡 apt-cache policy
Package files:
 100 /var/lib/dpkg/status
     release a=now
 500 http://packages.cloud.google.com/apt google-compute-engine-buster-stable/main amd64 Packages
     release o=google-compute-engine-buster-stable,a=google-compute-engine-buster-stable,n=google-compute-engine-buster-stable,l=google-compute-engine-buster-stable,c=main,b=amd64
     origin packages.cloud.google.com
 500 http://packages.cloud.google.com/apt google-cloud-packages-archive-keyring-buster/main amd64 Packages
     release o=google-cloud-packages-archive-keyring-jessie,a=google-cloud-packages-archive-keyring-buster,n=google-cloud-packages-archive-keyring-buster,l=google-cloud-packages-archive-keyring-jessie,c=main,b=amd64
     origin packages.cloud.google.com
 500 http://packages.cloud.google.com/apt cloud-sdk-buster/main amd64 Packages
     release o=cloud-sdk-buster,a=cloud-sdk-buster,n=cloud-sdk-buster,l=cloud-sdk-buster,c=main,b=amd64
     origin packages.cloud.google.com
 500 https://download.docker.com/linux/debian buster/stable amd64 Packages
     release o=Docker,a=buster,l=Docker CE,c=stable,b=amd64
     origin download.docker.com
 500 https://apt.releases.hashicorp.com buster/main amd64 Packages
     release o=Artifactory,a=buster,n=buster,l=Artifactory,c=main,b=amd64
     origin apt.releases.hashicorp.com
 100 http://deb.debian.org/debian buster-backports/main amd64 Packages
     release o=Debian Backports,a=buster-backports,n=buster-backports,l=Debian Backports,c=main,b=amd64
     origin deb.debian.org
 500 http://deb.debian.org/debian buster-updates/main amd64 Packages
     release o=Debian,a=stable-updates,n=buster-updates,l=Debian,c=main,b=amd64
     origin deb.debian.org
 500 http://security.debian.org/debian-security buster/updates/main amd64 Packages
     release v=10,o=Debian,a=stable,n=buster,l=Debian-Security,c=main,b=amd64
     origin security.debian.org
 500 http://deb.debian.org/debian buster/main amd64 Packages
     release v=10.8,o=Debian,a=stable,n=buster,l=Debian,c=main,b=amd64
     origin deb.debian.org
Pinned packages:
ymotongpoo commented 3 years ago

It fails with Debian standard package repositories as well:

🍡 rbenv exec inspec shell -t ssh://demo@XX.XX.XX.XX -i ~/.ssh/gcp_terraform
Welcome to the interactive InSpec Shell
To find out how to use it, type: help

You are currently running on:

    Name:      debian
    Families:  debian, linux, unix, os
    Release:   10.8
    Arch:      x86_64

inspec> describe apt 'http://packages.cloud.google.com/apt' do
inspec>   it { should exist }
inspec> end

Profile: inspec-shell
Version: (not specified)

  Apt Repository http://packages.cloud.google.com/apt
     ×  is expected to exist
     expected Apt Repository http://packages.cloud.google.com/apt to exist

Test Summary: 0 successful, 1 failure, 0 skipped
inspec> describe apt 'http://deb.debian.org/debian' do
inspec>   it { should exist }
inspec> end

Profile: inspec-shell
Version: (not specified)

  Apt Repository http://deb.debian.org/debian
     ×  is expected to exist
     expected Apt Repository http://deb.debian.org/debian to exist

Test Summary: 0 successful, 1 failure, 0 skipped
inspec> describe apt 'http://security.debian.org/debian-security' do
inspec>   it { should exist }
inspec> end

Profile: inspec-shell
Version: (not specified)

  Apt Repository http://security.debian.org/debian-security
     ×  is expected to exist
     expected Apt Repository http://security.debian.org/debian-security to exist

Test Summary: 0 successful, 1 failure, 0 skipped
ymotongpoo commented 3 years ago

The feature will be merged in 4.28.1.