puppetlabs/puppetlabs-apt — pull request #272 by fbarbeira (2014-03-20 13:15:30+00:00)
Title: Add "independent_key" function.

With this commit the apt module would implement the functionality of storing the gpg keys in different files instead of a unique one. I preffer the 'debian' way where they store each key in a separated files, example:

```
root@debian:~# apt-key list
/etc/apt/trusted.gpg.d//debian-archive-squeeze-automatic.gpg
------------------------------------------------------------
pub 4096R/473041FA 2010-08-27 [caduca: 2018-03-05]
uid Debian Archive Automatic Signing Key (6.0/squeeze)

/etc/apt/trusted.gpg.d//debian-archive-squeeze-stable.gpg
---------------------------------------------------------
pub 4096R/B98321F9 2010-08-07 [caduca: 2017-08-05]
uid Squeeze Stable Release Key

/etc/apt/trusted.gpg.d//debian-archive-wheezy-automatic.gpg
-----------------------------------------------------------
pub 4096R/46925553 2012-04-27 [caduca: 2020-04-25]
uid Debian Archive Automatic Signing Key (7.0/wheezy)

/etc/apt/trusted.gpg.d//debian-archive-wheezy-stable.gpg
--------------------------------------------------------
pub 4096R/65FFB764 2012-05-08 [caduca: 2019-05-07]
uid Wheezy Stable Release Key

/etc/apt/trusted.gpg.d//puppetlabs-keyring.gpg
----------------------------------------------
pub 4096R/4BD6EC30 2010-07-10 [caduca: 2016-07-08]
uid Puppet Labs Release Key (Puppet Labs Release Key)

root@debian:~# ls -la /etc/apt/trusted.gpg.d/
total 28
drwxr-xr-x 2 root root 4096 mar 13 10:29 .
drwxr-xr-x 6 root root 4096 mar 20 11:57 ..
-rw-r--r-- 1 root root 4084 jun 2 2012 debian-archive-squeeze-automatic.gpg
-rw-r--r-- 1 root root 2853 jun 2 2012 debian-archive-squeeze-stable.gpg
-rw-r--r-- 1 root root 3780 jun 2 2012 debian-archive-wheezy-automatic.gpg
-rw-r--r-- 1 root root 2851 jun 2 2012 debian-archive-wheezy-stable.gpg
-rw-r--r-- 1 root root 1182 jul 5 2012 puppetlabs-keyring.gpg
root@debian:~#
```
It's easier to manage in the 'debian way'. If you want to remove one of this keys you just have to remove the file. The 'ubuntu way' it's a little bit complicated because they don't use the functionality of the "trusted.gpg.d" directory. Example:

```
root@ubuntu:~# apt-key list
/etc/apt/trusted.gpg
--------------------
pub 1024D/437D05B5 2004-09-12
uid Ubuntu Archive Automatic Signing Key
sub 2048g/79164387 2004-09-12

pub 1024D/FBB75451 2004-12-30
uid Ubuntu CD Image Automatic Signing Key

pub 4096R/C0B21F32 2012-05-11
uid Ubuntu Archive Automatic Signing Key (2012)

pub 4096R/EFE21092 2012-05-11
uid Ubuntu CD Image Automatic Signing Key (2012)

/etc/apt/trusted.gpg.d//puppetlabs-keyring.gpg
----------------------------------------------
pub 4096R/4BD6EC30 2010-07-10 [[caduca: 2016-07-08]]
uid Puppet Labs Release Key (Puppet Labs Release Key)

root@ubuntu:~# ls -la /etc/apt/trusted.gpg.d/
total 12
drwxr-xr-x 2 root root 4096 ene 23 12:59 .
drwxr-xr-x 6 root root 4096 mar 20 14:00 ..
-rw-r--r-- 1 root root 1182 jul 5 2012 puppetlabs-keyring.gpg
root@ubuntu:~#
```

If we use debian machines with the 'puppetlabs-apt' module, we will break the debian paradigm.

I have tested this code with ubuntu (precise and lucid) and debian wheezy.