Commit 1568808e authored by Fabien Combernous's avatar Fabien Combernous

Merge branch '10-ensure-administrators-accounts-are-under-puppet-control' into 'master'

Resolve "ensure administrator account is updated"

Closes #10

See merge request !35
parents b24339ef 768c6ea0
# @summary This class manages admin accounts. It will create/give rights to any admin accounts missing. It will delete accounts set in Hiera to be deleted.
#
# @example
# include freeipa::config::humanadmins
class freeipa::config::humanadmins {
# Get domain in shape for ldappasswd
$dc_domain_split = regsubst($freeipa::domain, '([^.]+)\.*', 'dc=\1,', 'G')
$dc = regsubst($dc_domain_split, ',$', '')
exec { 'kinit as puppet_admin':
command => 'kinit admin -k -t /home/admin/admin.keytab',
}
# Loop through $human_admins
$freeipa::humanadmins.each | String $adminname, Hash[Enum['password','ensure'], String] $adminsettings | {
$_ensure_admin = $adminsettings['ensure'] ? {
Undef => 'present',
default => assert_type(Enum['present','absent'], $adminsettings['ensure']),
}
case $_ensure_admin {
'present': {
exec { "Create ${adminname} account":
command => "ipa user-add ${adminname} --first=${adminname} --last=${adminname} ",
unless => "ipa user-show ${adminname} | grep login",
}
-> exec { "Add ${adminname} account to admins group in FreeIPA":
command => "ipa group-add-member admins --users=${adminname}",
unless => "ipa group-show admins | grep ${adminname}",
}
-> exec { "Update ${adminname} password":
command => "ldappasswd -Z -H ldap://localhost -x -D \"cn=Directory Manager\" -w ${freeipa::directory_services_password} -s ${adminsettings['password']} \"uid=${adminname},cn=users,cn=accounts,${dc}\"",
}
}
'absent': {
exec { "Delete ${adminname} account":
command => "ipa user-del ${adminname}",
}
}
default: { fail("unexpected value ${adminsettings['ensure']}") }
}
}
}
......@@ -6,7 +6,7 @@
# ipa_role => 'master',
# domain => 'example.lan',
# ipa_server_fqdn => 'ipa-server-1.example.lan',
# admin_password => 'vagrant123',
# puppet_admin_password => 'vagrant123',
# directory_services_password => 'vagrant123',
# install_ipa_server => true,
# ip_address => '10.10.10.35',
......@@ -17,6 +17,7 @@
# webui_disable_kerberos => true,
# webui_enable_proxy => true,
# webui_force_https => true,
# admins => [ 'admin', 'admin2' ],
# }
#
# Parameters
......@@ -69,23 +70,26 @@
# This is necessary to allow the WebUI to be accessed behind a reverse proxy when using nonstandard ports.
# @param webui_proxy_external_fqdn The public or external FQDN used to access the IPA Web UI behind the reverse proxy.
# @param webui_proxy_https_port The HTTPS port to use for the reverse proxy. Cannot be 443.
# @param $admins The list of admin accounts in freeipa. (The list of users who belong to admins group)
#
#
class freeipa (
Stdlib::Fqdn $domain,
Enum['master','replica','client'] $ipa_role,
String[8] $admin_password,
String[8] $puppet_admin_password,
String[8] $directory_services_password,
Stdlib::IP::Address $ip_address,
Stdlib::Fqdn $ipa_master_fqdn,
Stdlib::Fqdn $realm = upcase($domain),
Freeipa::Humanadmins $humanadmins = {},
String $autofs_package_name = 'autofs',
Boolean $client_install_ldaputils = false,
Boolean $configure_dns_server = true,
Boolean $configure_ntp = true,
Array[String] $custom_dns_forwarders = [],
String $principal_usedto_joindomain = 'admin',
String $password_usedto_joindomain = $directory_services_password,
String $password_usedto_joindomain = $puppet_admin_password,
Boolean $enable_manage_admins = true,
Boolean $enable_hostname = true,
Boolean $enable_ip_address = false,
Boolean $fixed_primary = false,
......@@ -142,4 +146,3 @@ class freeipa (
class {'::freeipa::install':}
}
......@@ -104,6 +104,10 @@ class freeipa::install::server {
freeipa::helpers::flushcache { "server_${freeipa::ipa_server_fqdn}": }
class {'freeipa::config::admin_user': }
if $freeipa::ipa_role == 'master' and $freeipa::enable_manage_admins {
class {'freeipa::config::humanadmins':}
}
} else {
fail ("to change ipa_role from '${facts['iparole']}' to '${freeipa::ipa_role}' is not supported.")
}
......
......@@ -9,7 +9,7 @@ class freeipa::install::server::master {
${freeipa::install::server::server_install_cmd_opts_hostname} \
--realm=${freeipa::realm} \
--domain=${freeipa::domain} \
--admin-password='${freeipa::admin_password}' \
--admin-password='${freeipa::puppet_admin_password}' \
--ds-password='${freeipa::directory_services_password}' \
${freeipa::install::server::server_install_cmd_opts_setup_dns} \
${freeipa::install::server::server_install_cmd_opts_forwarders} \
......@@ -40,6 +40,7 @@ class freeipa::install::server::master {
minute => '*/1',
require => Package[$freeipa::kstart_package_name],
}
} else {
fail ("to change ipa_role from '${facts['iparole']}' to 'master' is not supported.")
}
......
require 'spec_helper'
describe 'freeipa::install::autofs' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }
let(:pre_condition) do
manifest = <<-EOS
class{ 'freeipa' :
ipa_role => 'master',
ipa_master_fqdn => 'master.example.lan',
ipa_server_fqdn => 'foo.example.lan',
domain => 'example.lan',
password_usedto_joindomain => 'foobartest',
puppet_admin_password => 'foobartest',
directory_services_password => 'foobartest',
ip_address => '10.10.10.35',
}
EOS
manifest
end
it { is_expected.to compile }
end
end
end
......@@ -9,12 +9,14 @@ describe 'freeipa class' do
ipa_role => 'master',
domain => 'example.lan',
ipa_server_fqdn => 'ipa-server-1.example.lan',
admin_password => 'vagrant123',
puppet_admin_password => 'vagrant123',
directory_services_password => 'vagrant123',
humanadmins => { foo => { password => 'vagrant123', ensure => 'present'}, bar => { password => 'vagrant123', ensure => 'present'} },
install_ipa_server => true,
ip_address => '10.10.10.35',
enable_ip_address => true,
enable_hostname => true,
enable_manage_admins => false,
manage_host_entry => true,
install_epel => true,
webui_disable_kerberos => true,
......@@ -42,7 +44,7 @@ describe 'freeipa class' do
ipa_role => 'replica',
domain => 'example.lan',
ipa_server_fqdn => 'ipa-server-2.example.lan',
admin_password => 'vagrant123',
puppet_admin_password => 'vagrant123',
directory_services_password => 'vagrant123',
password_usedto_joindomain => 'vagrant123',
install_ipa_server => true,
......@@ -73,7 +75,7 @@ describe 'freeipa class' do
class {'freeipa':
ipa_role => 'client',
domain => 'example.lan',
admin_password => 'vagrant123',
puppet_admin_password => 'vagrant123',
directory_services_password => 'vagrant123',
password_usedto_joindomain => 'vagrant123',
ip_address => '10.10.10.37',
......@@ -96,7 +98,7 @@ describe 'freeipa class' do
ipa_role => 'replica',
domain => 'example.lan',
ipa_server_fqdn => 'ipa-server-1.example.lan',
admin_password => 'vagrant123',
puppet_admin_password => 'vagrant123',
directory_services_password => 'vagrant123',
install_ipa_server => true,
ip_address => '10.10.10.35',
......@@ -123,7 +125,7 @@ describe 'freeipa class' do
class { 'freeipa':
ipa_role => 'client',
domain => 'example.lan',
admin_password => 'vagrant123',
puppet_admin_password => 'vagrant123',
directory_services_password => 'vagrant123',
password_usedto_joindomain => 'vagrant123',
ip_address => '10.10.10.35',
......@@ -195,4 +197,62 @@ describe 'freeipa class' do
end
end
end
context 'Test creation of admin accounts' do
hosts_as('master').each do |master|
it 'updates admin password' do
pp = <<-EOS
class { 'freeipa':
ipa_role => 'master',
domain => 'example.lan',
ipa_server_fqdn => 'ipa-server-1.example.lan',
puppet_admin_password => 'vagrant123',
directory_services_password => 'vagrant123',
humanadmins => { foo => { password => 'vagrant123', ensure => 'present'}, bar => { password => 'vagrant123'} },
install_ipa_server => true,
ip_address => '10.10.10.35',
enable_ip_address => true,
enable_hostname => true,
manage_host_entry => true,
install_epel => true,
webui_disable_kerberos => true,
webui_enable_proxy => true,
webui_force_https => true,
ipa_master_fqdn => 'ipa-server-1.example.lan',
}
EOS
apply_manifest_on(master, pp, catch_failures: true)
end
end
end
context 'Test update and delete on admin accounts' do
hosts_as('master').each do |master|
it 'updates admin password' do
pp = <<-EOS
class { 'freeipa':
ipa_role => 'master',
domain => 'example.lan',
ipa_server_fqdn => 'ipa-server-1.example.lan',
puppet_admin_password => 'vagrant123',
directory_services_password => 'vagrant123',
humanadmins => { foo => { password => 'beaker456', ensure => 'present'}, bar => { password => 'vagrant123', ensure => 'absent'} },
install_ipa_server => true,
ip_address => '10.10.10.35',
enable_ip_address => true,
enable_hostname => true,
manage_host_entry => true,
install_epel => true,
webui_disable_kerberos => true,
webui_enable_proxy => true,
webui_force_https => true,
ipa_master_fqdn => 'ipa-server-1.example.lan',
}
EOS
apply_manifest_on(master, pp, catch_failures: true)
end
end
end
end
......@@ -13,7 +13,7 @@ describe 'freeipa::config::admin_user' do
ipa_server_fqdn => 'foo.example.lan',
domain => 'example.lan',
password_usedto_joindomain => 'foobartest',
admin_password => 'foobartest',
puppet_admin_password => 'foobartest',
directory_services_password => 'foobartest',
ip_address => '10.10.10.35',
}
......
require 'spec_helper'
describe 'freeipa::config::humanadmins' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:pre_condition) do
manifest = <<-EOS
class{ 'freeipa' :
ipa_role => 'master',
ipa_master_fqdn => 'master.example.lan',
ipa_server_fqdn => 'foo.example.lan',
domain => 'example.lan',
password_usedto_joindomain => 'foobartest',
puppet_admin_password => 'foobartest',
directory_services_password => 'foobartest',
ip_address => '10.10.10.35',
}
EOS
manifest
end
let(:facts) { os_facts }
it { is_expected.to compile }
end
end
end
......@@ -13,7 +13,7 @@ describe 'freeipa::config::webui' do
ipa_server_fqdn => 'foo.example.lan',
domain => 'example.lan',
password_usedto_joindomain => 'foobartest',
admin_password => 'foobartest',
puppet_admin_password => 'foobartest',
directory_services_password => 'foobartest',
ip_address => '10.10.10.35',
}
......
......@@ -12,7 +12,7 @@ describe 'freeipa' do
ipa_master_fqdn: 'foo.example.lan',
domain: 'example.lan',
password_usedto_joindomain: 'foobartest',
admin_password: 'vagrant123',
puppet_admin_password: 'vagrant123',
directory_services_password: 'vagrant123',
ip_address: '10.10.10.35'
}
......
......@@ -12,11 +12,11 @@ describe 'freeipa', type: :class do
let :params do
{
ipa_role: 'master',
domain: 'rspec.example.lan',
admin_password: 'rspecrspec123',
domain: 'example.lan',
puppet_admin_password: 'rspecrspec123',
directory_services_password: 'rspecrspec123',
ip_address: '10.10.10.35',
ipa_master_fqdn: 'master.rspec.example.lan'
ipa_master_fqdn: 'master.example.lan'
}
end
......@@ -48,11 +48,11 @@ describe 'freeipa', type: :class do
let :params do
{
ipa_role: 'replica',
domain: 'rspec.example.lan',
admin_password: 'rspecrspec123',
domain: 'example.lan',
puppet_admin_password: 'rspecrspec123',
directory_services_password: 'rspecrspec123',
ip_address: '10.10.10.36',
ipa_master_fqdn: 'replica.rspec.example.lan',
ipa_master_fqdn: 'replica.example.lan',
password_usedto_joindomain: 'rspecrspec123'
}
end
......@@ -87,11 +87,11 @@ describe 'freeipa', type: :class do
let :params do
{
ipa_role: 'client',
domain: 'rspec.example.lan',
admin_password: 'rspecrspec123',
domain: 'example.lan',
puppet_admin_password: 'rspecrspec123',
directory_services_password: 'rspecrspec123',
ip_address: '10.10.10.36',
ipa_master_fqdn: 'client.rspec.example.lan',
ipa_master_fqdn: 'client.example.lan',
password_usedto_joindomain: 'rspecrspec123'
}
end
......
......@@ -14,7 +14,7 @@ describe 'freeipa::install::autofs' do
ipa_server_fqdn => 'foo.example.lan',
domain => 'example.lan',
password_usedto_joindomain => 'foobartest',
admin_password => 'foobartest',
puppet_admin_password => 'foobartest',
directory_services_password => 'foobartest',
ip_address => '10.10.10.35',
}
......
......@@ -13,7 +13,7 @@ describe 'freeipa::install::client' do
ipa_server_fqdn => 'foo.example.lan',
domain => 'example.lan',
password_usedto_joindomain => 'foobartest',
admin_password => 'foobartest',
puppet_admin_password => 'foobartest',
directory_services_password => 'foobartest',
ip_address => '10.10.10.35',
}
......@@ -38,7 +38,7 @@ describe 'freeipa::install::client' do
ipa_server_fqdn => 'foo.example.lan',
domain => 'example.lan',
password_usedto_joindomain => 'foobartest',
admin_password => 'foobartest',
puppet_admin_password => 'foobartest',
directory_services_password => 'foobartest',
ip_address => '10.10.10.35',
}
......@@ -63,7 +63,7 @@ describe 'freeipa::install::client' do
ipa_server_fqdn => 'foo.example.lan',
domain => 'example.lan',
password_usedto_joindomain => 'foobartest',
admin_password => 'foobartest',
puppet_admin_password => 'foobartest',
directory_services_password => 'foobartest',
ip_address => '10.10.10.35',
}
......
......@@ -12,7 +12,7 @@ describe 'freeipa::install::server::master' do
ipa_server_fqdn => 'foo.example.lan',
domain => 'example.lan',
password_usedto_joindomain => 'foobartest',
admin_password => 'foobartest',
puppet_admin_password => 'foobartest',
directory_services_password => 'foobartest',
ip_address => '10.10.10.35',
}
......@@ -38,7 +38,7 @@ describe 'freeipa::install::server::master' do
ipa_server_fqdn => 'foo.example.lan',
domain => 'example.lan',
password_usedto_joindomain => 'foobartest',
admin_password => 'foobartest',
puppet_admin_password => 'foobartest',
directory_services_password => 'foobartest',
ip_address => '10.10.10.35',
}
......@@ -63,7 +63,7 @@ describe 'freeipa::install::server::master' do
ipa_server_fqdn => 'foo.example.lan',
domain => 'example.lan',
password_usedto_joindomain => 'foobartest',
admin_password => 'foobartest',
puppet_admin_password => 'foobartest',
directory_services_password => 'foobartest',
ip_address => '10.10.10.35',
}
......@@ -88,7 +88,7 @@ describe 'freeipa::install::server::master' do
ipa_server_fqdn => 'foo.example.lan',
domain => 'example.lan',
password_usedto_joindomain => 'foobartest',
admin_password => 'foobartest',
puppet_admin_password => 'foobartest',
directory_services_password => 'foobartest',
ip_address => '10.10.10.35',
}
......
......@@ -12,7 +12,7 @@ describe 'freeipa::install::server::replica' do
ipa_server_fqdn => 'foo.example.lan',
domain => 'example.lan',
password_usedto_joindomain => 'foobartest',
admin_password => 'foobartest',
puppet_admin_password => 'foobartest',
directory_services_password => 'foobartest',
ip_address => '10.10.10.35',
}
......@@ -38,7 +38,7 @@ describe 'freeipa::install::server::replica' do
ipa_server_fqdn => 'foo.example.lan',
domain => 'example.lan',
password_usedto_joindomain => 'foobartest',
admin_password => 'foobartest',
puppet_admin_password => 'foobartest',
directory_services_password => 'foobartest',
ip_address => '10.10.10.35',
}
......@@ -63,7 +63,7 @@ describe 'freeipa::install::server::replica' do
ipa_server_fqdn => 'foo.example.lan',
domain => 'example.lan',
password_usedto_joindomain => 'foobartest',
admin_password => 'foobartest',
puppet_admin_password => 'foobartest',
directory_services_password => 'foobartest',
ip_address => '10.10.10.35',
}
......@@ -88,7 +88,7 @@ describe 'freeipa::install::server::replica' do
ipa_server_fqdn => 'foo.example.lan',
domain => 'example.lan',
password_usedto_joindomain => 'foobartest',
admin_password => 'foobartest',
puppet_admin_password => 'foobartest',
directory_services_password => 'foobartest',
ip_address => '10.10.10.35',
}
......
......@@ -15,7 +15,7 @@ describe 'freeipa::install::server' do
ipa_server_fqdn => 'foo.example.lan',
domain => 'example.lan',
password_usedto_joindomain => 'foobartest',
admin_password => 'foobartest',
puppet_admin_password => 'foobartest',
directory_services_password => 'foobartest',
ip_address => '10.10.10.35',
}
......@@ -40,7 +40,7 @@ describe 'freeipa::install::server' do
ipa_server_fqdn => 'foo.example.lan',
domain => 'example.lan',
password_usedto_joindomain => 'foobartest',
admin_password => 'foobartest',
puppet_admin_password => 'foobartest',
directory_services_password => 'foobartest',
ip_address => '10.10.10.35',
}
......@@ -65,7 +65,7 @@ describe 'freeipa::install::server' do
ipa_server_fqdn => 'foo.example.lan',
domain => 'example.lan',
password_usedto_joindomain => 'foobartest',
admin_password => 'foobartest',
puppet_admin_password => 'foobartest',
directory_services_password => 'foobartest',
ip_address => '10.10.10.35',
}
......
......@@ -14,7 +14,7 @@ describe 'freeipa::install::sssd' do
ipa_server_fqdn => 'foo.example.lan',
domain => 'example.lan',
password_usedto_joindomain => 'foobartest',
admin_password => 'foobartest',
puppet_admin_password => 'foobartest',
directory_services_password => 'foobartest',
ip_address => '10.10.10.35',
}
......
......@@ -14,9 +14,10 @@ describe 'freeipa::install' do
ipa_server_fqdn => 'foo.example.lan',
domain => 'example.lan',
password_usedto_joindomain => 'foobartest',
admin_password => 'foobartest',
puppet_admin_password => 'foobartest',
directory_services_password => 'foobartest',
ip_address => '10.10.10.35',
humanadmins => { foo => { password => 'vagrant123', ensure => 'present'}, bar => { password => 'vagrant123', ensure => 'present'} },
}
EOS
manifest
......
......@@ -11,7 +11,7 @@ describe 'freeipa::helpers::flushcache' do
ipa_server_fqdn => 'foo.example.lan',
domain => 'example.lan',
password_usedto_joindomain => 'foobartest',
admin_password => 'foobartest',
puppet_admin_password => 'foobartest',
directory_services_password => 'foobartest',
ip_address => '10.10.10.35',
}
......
type Freeipa::Humanadmins = Hash[String, Hash[Enum['username','password','ensure'], String]]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment