Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 8 additions & 0 deletions lib/facter/ipa_facts.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
require 'facter'
require 'resolv'

Facter.add('ipa_client_version') do
setcode do
if Facter::Util::Resolution.which('ipa-client-install')
Facter::Util::Resolution.exec('ipa-client-install --version')
end
end
end

if File.exist?('/etc/sssd/sssd.conf') && sssd = File.readlines('/etc/sssd/sssd.conf')
sssd.each do |line|
case line
Expand Down
37 changes: 28 additions & 9 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
# $sshd:: Enable SSHD Integration
# Default: true
#
# $subid:: Use SSSD as subid provider
# Default: false
#
# $sudo:: Enable sudoers management
# Default: true
#
Expand Down Expand Up @@ -102,19 +105,22 @@
$ntp = $ipaclient::params::ntp,
$options = $ipaclient::params::options,
$package = $ipaclient::params::package,
$package_options = $ipaclient::params::package_options,
$password = $ipaclient::params::password,
$principal = $ipaclient::params::principal,
$realm = $ipaclient::params::realm,
$server = $ipaclient::params::server,
$ssh = $ipaclient::params::ssh,
$sshd = $ipaclient::params::sshd,
$subid = $ipaclient::params::subid,
$sudo = $ipaclient::params::sudo,
$hostname = $ipaclient::params::hostname,
$force_join = $ipaclient::params::force_join
) inherits ipaclient::params {

package { $package:
ensure => installed,
install_options => $package_options,
}

if !str2bool($::ipa_enrolled) {
Expand All @@ -125,7 +131,7 @@

$opt_password = ['--password', $password]

if is_array($server) {
if $server =~ Array {
# Transform ['a','b'] -> ['--server','a','--server','b']
$opt_server = split(join(prefix($server, '--server|'), '|'), '\|')
} elsif !empty($server) {
Expand Down Expand Up @@ -194,6 +200,14 @@
$opt_force = ''
}

if !empty($::ipa_client_version) and
versioncmp($::ipa_client_version, "4.9.10") >= 0 and
str2bool($subid) {
$opt_subid = '--subid'
} else {
$opt_subid = ''
}

if !str2bool($sudo) {
$opt_sudo = '--no-sudo'
} else {
Expand All @@ -209,14 +223,19 @@
# Flatten the arrays, delete empty options, and shellquote everything
$command = shellquote(delete(flatten([$installer,$opt_realm,$opt_password,
$opt_principal,$opt_mkhomedir,$opt_domain,$opt_hostname,
$opt_server,$opt_fixed_primary,$opt_ssh,$opt_sshd,$opt_ntp,$opt_sudo,
$opt_force,$opt_force_join,$options,'--unattended']), ''))
$opt_server,$opt_fixed_primary,$opt_ssh,$opt_sshd,$opt_ntp,
$opt_sudo,$opt_subid,$opt_force,$opt_force_join,$options,
'--unattended']), ''))

exec { 'ipa_installer':
command => $command,
unless => "/usr/sbin/ipa-client-install -U 2>&1 \
| /bin/grep -q 'already configured'",
require => Package[$package],
# Make sure we can collect the `ipa_client_version` fact first
# Makes us run twice, though :(
if !empty($::ipa_client_version) {
exec { 'ipa_installer':
command => $command,
unless => "/usr/sbin/ipa-client-install -U 2>&1 \
| /bin/grep -q 'already configured'",
require => Package[$package],
}
}

$installer_resource = Exec['ipa_installer']
Expand All @@ -236,7 +255,7 @@
# the first value of server parameter
if empty($server) {
$sudo_server = $::ipa_server
} elsif is_array($server) {
} elsif $server =~ Array {
$sudo_server = $server[0]
} else {
$sudo_server = $server
Expand Down
10 changes: 6 additions & 4 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
$sshd = true
$automount = false
$mkhomedir = true
$subid = false
$sudo = true
$fixed_primary = false
$options = ''
Expand All @@ -28,13 +29,14 @@
$sssd_sudo_smart_refresh = ''
$sssd_default_domain_suffix = ''
$force_join = false
$package_options = []

# Determine if client needs manual sudo configuration or not
# RHEL <=6.5 requires manual configuration
# RHEL 6.6 includes automatic sudo configuration
# RHEL 7.0 requires manual confifuration
# RHEL >=7.1 includes automatic sudo configuration
case $::osfamily {
case $facts['os']['family'] {
'RedHat': {
case $::operatingsystem {
'Fedora': {
Expand Down Expand Up @@ -72,12 +74,12 @@
}
}
default: {
fail("This module does not support operatingsystem ${::operatingsystem}")
fail("This module does not support os family " + facts['os']['family'])
}
}

# Name of IPA package to install
case $::osfamily {
case $facts['os']['family'] {
'RedHat': {
case $::operatingsystem {
'fedora': {
Expand All @@ -92,7 +94,7 @@
$package = 'freeipa-client'
}
default: {
fail("This module does not support operatingsystem ${::operatingsystem}")
fail("This module does not support os family " + $facts['os']['family'])
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions manifests/sudoers.pp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
if !empty($server) and !empty($domain) {
$realm = upcase($domain)

case $::osfamily {
case $facts['os']['family'] {
'RedHat': {

if ($::operatingsystem == 'Fedora' and
Expand Down Expand Up @@ -97,17 +97,20 @@
# Selecting the right provider is a PITA
if empty($::sssd_version) {
case $::osfamily {
RedHat: {
'RedHat': {
if (versioncmp($::operatingsystemrelease, '6.6') >= 0) {
$ipa_provider = 'ipa'
} else {
$ipa_provider = 'ldap'
}
}
Debian: {
'Debian': {
if (versioncmp($::operatingsystemrelease, '14.04') >= 0 and
$::operatingsystem == 'Ubuntu') {
$ipa_provider = 'ipa'
} elsif (versioncmp($::operatingsystemrelease, '7.0') >= 0 and
($::operatingsystem == 'Debian' or $::operatingsystem == 'Raspbian')) {
$ipa_provider = 'ipa'
} else {
$ipa_provider = 'ldap'
}
Expand Down