server.pp 2.81 KB
Newer Older
1 2
# 
# @summary This class mainly defines options for the ipa install command, then install master or replica regarding the role set.
3 4 5
#
# @example
#   include freeipa::install::server
6
class freeipa::install::server {
7

8 9 10 11
  if $facts['iparole'] != 'client' {
    Exec {
        path    => '/usr/local/bin/:/bin/:/sbin',
    }
12

13 14 15
    package{$freeipa::ipa_server_package_name:
      ensure => present,
    }
16

17
    package{$freeipa::kstart_package_name:
18 19 20
      ensure => present,
    }

21 22 23 24 25
    if $freeipa::server_install_ldaputils {
      package { $freeipa::ldaputils_package_name:
        ensure => present,
      }
    }
26

27
    $server_install_cmd_opts_idstart = "--idstart=${freeipa::idstart}"
28

29 30 31 32 33 34
    if $freeipa::enable_hostname {
      $server_install_cmd_opts_hostname = "--hostname=${freeipa::ipa_server_fqdn}"
        end
    } else {
      $server_install_cmd_opts_hostname = ''
    }
35

36 37 38 39 40
    if $freeipa::enable_ip_address {
      $server_install_cmd_opts_ip_address = "--ip-address ${freeipa::ip_address}"
    } else {
      $server_install_cmd_opts_ip_address = ''
    }
41

42 43 44 45 46
    if $freeipa::final_configure_dns_server {
      $server_install_cmd_opts_setup_dns = '--setup-dns'
    } else {
      $server_install_cmd_opts_setup_dns = ''
    }
47

48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
    if $freeipa::configure_ntp {
      $server_install_cmd_opts_no_ntp = ''
    } else {
      $server_install_cmd_opts_no_ntp = '--no-ntp'
    }

    if $freeipa::final_configure_dns_server {
      if size($freeipa::custom_dns_forwarders) > 0 {
        $server_install_cmd_opts_forwarders = join(
          prefix(
            $freeipa::custom_dns_forwarders,
            '--forwarder '),
          ' '
        )
      }
      else {
        $server_install_cmd_opts_forwarders = '--no-forwarders'
      }
66 67
    }
    else {
68
      $server_install_cmd_opts_forwarders = ''
69 70
    }

71 72 73 74 75
    if $freeipa::no_ui_redirect {
      $server_install_cmd_opts_no_ui_redirect = ''
    } else {
      $server_install_cmd_opts_no_ui_redirect = '--no-ui-redirect'
    }
76

77 78 79 80 81
    if $freeipa::ipa_role == 'master' {
      contain 'freeipa::install::server::master'
    } elsif $freeipa::ipa_role == 'replica' {
      contain 'freeipa::install::server::replica'
    }
82

83 84 85 86 87
    ensure_resource (
      'service',
      'httpd',
      {ensure => 'running'},
    )
88

89
    contain 'freeipa::config::webui'
90

91
    service { 'ipa':
92 93
      ensure  => 'running',
      enable  => true,
94
      require => Exec["server_install_${freeipa::ipa_server_fqdn}"],
95 96
    }

97 98 99 100 101 102 103
    if $freeipa::install_sssd {
      service { 'sssd':
        ensure  => 'running',
        enable  => true,
        require => Package[$freeipa::sssd_package_name],
      }
    }
104

105 106 107 108 109
    freeipa::helpers::flushcache { "server_${freeipa::ipa_server_fqdn}": }
    class {'freeipa::config::admin_user': }
  } else {
    fail ("to change ipa_role from '${facts['iparole']}' to '${freeipa::ipa_role}' is not supported.")
  }
110
}