When Puppet fails to add new APT software repositories

What a day! Day in console, day with Debian, day with Puppet! The day when you get error from Puppet and search for solution just because you miss error or notice message.

What I do: I add few Debian APT repositories with Puppet for provisioning and then install software from those repositories on the same run. Nothing special… but I’m getting an error:

==> default: Error: /Stage[main]/Apt::Update/Exec[apt_update]: Failed to call refresh: /usr/bin/apt-get update returned 100 instead of one of [0]
==> default: Error: /Stage[main]/Apt::Update/Exec[apt_update]: /usr/bin/apt-get update returned 100 instead of one of [0]

Of course, everything fails.

If you search for solution over the Internet – you will find many different suggestions, but most of them go around executing apt-get update and playing around using custom Exec['apt_get_update'] but nothing helped in my situation.

After a short brake and rebooting the host I’ve tried one more time the same unchanged script. Yes, that sounds insane – running same failing script and wait for different result but this time I’ve read every notice and error from Puppet and found next notices:

==> default: Notice: /Stage[main]/Main/Apt::Source[nodesource]/Apt::Setting[list-nodesource]/File[/etc/apt/sources.list.d/nodesource.list]/ensure: created
==> default: Notice: /Stage[main]/Main/Apt::Source[mysql]/Apt::Setting[list-mysql]/File[/etc/apt/sources.list.d/mysql.list]/ensure: created
==> default: Notice: /Stage[main]/Main/Apt::Source[dotdeb]/Apt::Setting[list-dotdeb]/File[/etc/apt/sources.list.d/dotdeb.list]/ensure: created
==> default: Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns: E: The method driver /usr/lib/apt/methods/https could not be found.

That tiny notice I’ve missed is the root of all my problems. The package apt-transport-https was missing. Actually it was added using old Puppet syntax.

Adding: require => Package['apt-transport-https'] to apt::source that uses HTTPS solved the problem. No custom Exec['apt_get_update'] needed, everything works as described in Adding new sources or PPAs.

So, the lesson of the day: read all errors and notices and analyze them, update your Puppet modules and change your code according to changes in Puppet syntax.

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.