Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(MODULES-11173) Add per-host overrides for apt::proxy #1007

Merged
merged 1 commit into from
Sep 20, 2021

Conversation

maturnbull
Copy link

Add support for optional apt::proxy::perhost array to configure bypass (DIRECT) or alternative proxy for specific repository hosts.

Add support for optional apt::proxy::perhost array to configure bypass (DIRECT) or alternative proxy for specific repository hosts.
@maturnbull maturnbull requested a review from a team as a code owner August 25, 2021 21:28
@CLAassistant
Copy link

CLAassistant commented Aug 25, 2021

CLA assistant check
All committers have signed the CLA.

@puppet-community-rangefinder
Copy link

apt is a class

Breaking changes to this file WILL impact these 238 modules (exact match):
Breaking changes to this file MAY impact these 47 modules (near match):

This module is declared in 234 of 578 indexed public Puppetfiles.


These results were generated with Rangefinder, a tool that helps predict the downstream impact of breaking changes to elements used in Puppet modules. You can run this on the command line to get a full report.

Exact matches are those that we can positively identify via namespace and the declaring modules' metadata. Non-namespaced items, such as Puppet 3.x functions, will always be reported as near matches only.

@daianamezdrea
Copy link

Hello @maturnbull, this looks good ! Thank you for your contribution!

@daianamezdrea daianamezdrea merged commit d3aea9c into puppetlabs:main Sep 20, 2021
@maturnbull maturnbull deleted the proxy_per_host branch September 20, 2021 21:28
@lamaral
Copy link

lamaral commented Jan 5, 2022

It looks like this change breaks the module when you don't have a proxy set:

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Method call, The function 'each' was called with arguments it does not accept. It expects one of:
  (Hash hash, Callable[2, 2] block)
    rejected: parameter 'hash' expects a Hash value, got Undef
  (Hash hash, Callable[1, 1] block)
    rejected: parameter 'hash' expects a Hash value, got Undef
  (Iterable enumerable, Callable[2, 2] block)
    rejected: parameter 'enumerable' expects an Iterable value, got Undef
  (Iterable enumerable, Callable[1, 1] block)
    rejected: parameter 'enumerable' expects an Iterable value, got Undef (file: /etc/puppetlabs/code/environments/testing/modules/apt/templates/proxy.epp, line: 2, column: 23)
    ```

@maturnbull
Copy link
Author

@lamaral I can't reproduce the problem you're seeing - please can you share more details of the Hiera files and how you're testing? I've tried both with the entire perhost: structure missing, and also with an empty perhost:

@lamaral
Copy link

lamaral commented Jan 5, 2022

I don't have any apt setup done via Hiera.

I have a couple different repositories declared like this in classes:

apt::source { 'docker':
        location => 'https://download.docker.com/linux/debian',
        repos    => 'stable',
        key      => {
            id     => '9DC858229FC7DD38854AE2D88D81803C0EBFCD88',
            source => 'https://download.docker.com/linux/debian/gpg',
        },
    }

I have no proxy at all configured for them.

After downgrading my apt module from version 8.3.0 to version 8.2.0, the issue is gone.

@maturnbull
Copy link
Author

I've tried to reproduce in a clean container, but I don't get the error you're seeing:

% docker run -ti --rm --entrypoint /bin/bash puppet/puppet-agent-ubuntu 
root@25e533fa99e0:/# apt-get -qq update
root@25e533fa99e0:/# apt-get -qq install gpg
<...snip...>

root@25e533fa99e0:/# puppet module install puppetlabs-apt
Notice: Preparing to install into /etc/puppetlabs/code/environments/production/modules ...
Notice: Downloading from https://forgeapi.puppet.com ...
Notice: Installing -- do not interrupt ...
/etc/puppetlabs/code/environments/production/modules
└─┬ puppetlabs-apt (v8.3.0)
  └── puppetlabs-stdlib (v8.1.0)

root@25e533fa99e0:/# cat > test.pp << EOF
> notify { 'testing': }
> 
> apt::source { 'docker':
>     location => 'https://download.docker.com/linux/debian',
>     repos    => 'stable',
>     key      => {
>         id     => '9DC858229FC7DD38854AE2D88D81803C0EBFCD88',
>         source => 'https://download.docker.com/linux/debian/gpg',
>     },
> }
> EOF

root@25e533fa99e0:/# puppet apply --test test.pp 
Info: Loading facts
Info: Loading facts
Notice: Compiled catalog for 25e533fa99e0 in environment production in 0.29 seconds
Info: Using environment 'production'
Info: Applying configuration version '1641425150'
Notice: testing
Notice: /Stage[main]/Main/Notify[testing]/message: defined 'message' as 'testing'
Notice: /Stage[main]/Apt/File[preferences]/ensure: created
Info: /Stage[main]/Apt/File[preferences]: Scheduling refresh of Class[Apt::Update]
Notice: /Stage[main]/Apt/Apt::Setting[conf-update-stamp]/File[/etc/apt/apt.conf.d/15update-stamp]/ensure: defined content as '{sha256}2e6eb1f5f20262bfc6b7dfb26a302f00b4ab5fee803abd9e07ad8378cce067d5'
Info: /Stage[main]/Apt/Apt::Setting[conf-update-stamp]/File[/etc/apt/apt.conf.d/15update-stamp]: Scheduling refresh of Class[Apt::Update]
Notice: /Stage[main]/Main/Apt::Source[docker]/Apt::Key[Add key: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88 from Apt::Source docker]/Apt_key[Add key: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88 from Apt::Source docker]/ensure: created
Notice: /Stage[main]/Main/Apt::Source[docker]/Apt::Setting[list-docker]/File[/etc/apt/sources.list.d/docker.list]/ensure: defined content as '{sha256}3b763fab36a791b0d8063919462aa38dc61fe3dd4be8acb4900bbe8f31ce0118'
Info: /Stage[main]/Main/Apt::Source[docker]/Apt::Setting[list-docker]/File[/etc/apt/sources.list.d/docker.list]: Scheduling refresh of Class[Apt::Update]
Info: Class[Apt::Update]: Scheduling refresh of Exec[apt_update]
Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns: Hit:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns: Hit:2 http://archive.ubuntu.com/ubuntu bionic InRelease
Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns: Hit:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns: Hit:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns: Ign:5 https://download.docker.com/linux/debian bionic InRelease
Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns: Err:6 https://download.docker.com/linux/debian bionic Release
Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns:   404  Not Found [IP: 216.137.44.72 443]
Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns: Hit:7 http://apt.puppetlabs.com bionic InRelease
Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns: Reading package lists...
Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns: E: The repository 'https://download.docker.com/linux/debian bionic Release' does not have a Release file.
Error: /Stage[main]/Apt::Update/Exec[apt_update]: Failed to call refresh: '/usr/bin/apt-get update' returned 100 instead of one of [0]
Error: /Stage[main]/Apt::Update/Exec[apt_update]: '/usr/bin/apt-get update' returned 100 instead of one of [0]
Info: Stage[main]: Unscheduling all events on Stage[main]
Notice: Applied catalog in 5.43 seconds

root@25e533fa99e0:/# exit
exit
% 

The catalog compiles and applies fine, the error is only because the repo isn't quite right but that's not relevant to the problem you're seeing. What distribution/version are you using?

@lamaral
Copy link

lamaral commented Jan 9, 2022

I had this with Debian Buster and Puppet 7.13.1.

Oddly enough, now that I unpinned the version and redownloaded the module, I cant reproduce it either.
Thanks for checking it out.

@maturnbull
Copy link
Author

No problem, glad it's working now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants