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

Use upstream apt module, expand Ubuntu support - #4 #10

Merged
merged 2 commits into from
Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ fixtures:
stdlib: "puppetlabs/stdlib"
augeas_core: "puppetlabs/augeas_core"
yumrepo: "puppetlabs/yumrepo_core"
apt: "puppetlabs/apt"
38 changes: 13 additions & 25 deletions manifests/apt.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,19 @@
}
}

package { $::duo_unix::duo_package:
ensure => $package_state,
require => [
File[$repo_file],
Exec['Duo Security GPG Import'],
Exec['duo-security-apt-update']
]
}

file { $repo_file:
owner => 'root',
group => 'root',
mode => '0644',
content => "deb ${repo_uri}/${facts['operatingsystem']} ${facts['lsbdistcodename']} main",
notify => Exec['duo-security-apt-update']
}

exec { 'duo-security-apt-update':
command => '/usr/bin/apt-get update',
refreshonly => true
}
if $::duo_unix::manage_repo {
initrd marked this conversation as resolved.
Show resolved Hide resolved
apt::source { 'duosecurity':
location => $repo_uri,
repos => 'main',
key => {
'id' => '08C2A645DDF240B85844068D7A450864C1A07A85',
initrd marked this conversation as resolved.
Show resolved Hide resolved
'source' => 'https://duo.com/DUO-GPG-PUBLIC-KEY.asc'
}
}

exec { 'Duo Security GPG Import':
command => "/usr/bin/apt-key add ${::duo_unix::gpg_file}",
unless => '/usr/bin/apt-key list | grep "Duo Security"',
notify => Exec['duo-security-apt-update']
package { $::duo_unix::duo_package:
ensure => $package_state,
require => Apt::Source['duosecurity'],
}
}
}
3 changes: 1 addition & 2 deletions manifests/generic.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
group => 'root',
mode => '0644',
# Updated 2020-03, see https://help.duo.com/s/article/5503
source => 'puppet:///modules/duo_unix/DUO-GPG-PUBLIC-KEY',
notify => Exec['Duo Security GPG Import'];
source => "puppet:///modules/${module_name}/DUO-GPG-PUBLIC-KEY",
initrd marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
8 changes: 1 addition & 7 deletions manifests/yum.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,12 @@
}

if $facts['os']['family'] == 'RedHat' and $::duo_unix::manage_repo {
exec { 'Duo Security GPG Import':
command => "/bin/rpm --import ${::duo_unix::gpg_file}",
unless => "/bin/rpm -q gpg-pubkey-`echo $(gpg --throw-keyids < ${::duo_unix::gpg_file}) | cut --characters=11-18 | tr [A-Z] [a-z]`",
before => Yumrepo['duosecurity'],
require => File[$::duo_unix::gpg_file];
}

yumrepo { 'duosecurity':
descr => 'Duo Security Repository',
baseurl => "${repo_uri}/${os}/${releasever}/\$basearch",
gpgcheck => '1',
enabled => '1',
gpgkey => "file://${::duo_unix::gpg_file}",
before => Package[$::duo_unix::duo_package],
require => File[$::duo_unix::gpg_file];
}
Expand Down
4 changes: 3 additions & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"14.04"
"14.04",
initrd marked this conversation as resolved.
Show resolved Hide resolved
"16.04",
"18.04"
]
}
],
Expand Down
3 changes: 2 additions & 1 deletion spec/classes/duo_unix_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
case facts[:osfamily]
when 'Debian'
it { is_expected.to contain_class('duo_unix::apt') }
it { is_expected.to contain_file('/etc/apt/DUO-GPG-PUBLIC-KEY') }
it { is_expected.to contain_apt__source('duosecurity').that_comes_before('Package[duo-unix]') }
it { is_expected.to contain_package('duo-unix').with_ensure('installed') }
it {
is_expected.to contain_service('ssh').with(
Expand All @@ -35,7 +37,6 @@
when 'RedHat'
it { is_expected.to contain_class('duo_unix::yum') }
it { is_expected.to contain_file('/etc/pki/rpm-gpg/DUO-GPG-PUBLIC-KEY') }
it { is_expected.to contain_yumrepo('duosecurity') }
gcoxmoz marked this conversation as resolved.
Show resolved Hide resolved
it { is_expected.to contain_yumrepo('duosecurity').that_comes_before('Package[duo_unix]') }
it { is_expected.to contain_package('duo_unix').with_ensure('installed') }
it {
Expand Down