Esempio n. 1
0
def install_cobbler(args):
    '''
  Install cobbler on current host.

  '''
    app.print_verbose("Install cobbler version: %d" % SCRIPT_VERSION)
    version_obj = version.Version("installCobbler", SCRIPT_VERSION)
    version_obj.check_executed()

    # Initialize password.
    app.get_root_password_hash()

    # Disable SELINUX it just messes with me.
    x("echo 0 > /selinux/enforce")
    general.set_config_property("/etc/selinux/config", '^SELINUX=.*',
                                "SELINUX=permissive")

    _install_cobbler()

    iptables.add_cobbler_chain()
    iptables.save()

    _modify_cobbler_settings()

    _import_repos()
    setup_all_systems(args)

    # Start/Restart used services.
    x("/etc/init.d/dhcpd restart")

    version_obj.mark_executed()
Esempio n. 2
0
def install_cobbler(args):
  '''
  Install cobbler on current host.

  '''
  app.print_verbose("Install cobbler version: %d" % SCRIPT_VERSION)
  version_obj = version.Version("installCobbler", SCRIPT_VERSION)
  version_obj.check_executed()

  # Initialize password.
  app.get_root_password_hash()

  # Disable SELINUX it just messes with me.
  x("echo 0 > /selinux/enforce")
  general.set_config_property("/etc/selinux/config", '^SELINUX=.*', "SELINUX=permissive")

  _install_cobbler()

  iptables.add_cobbler_chain()
  iptables.save()

  _modify_cobbler_settings()

  _import_repos()
  setup_all_systems(args)

  # Start/Restart used services.
  x("/etc/init.d/dhcpd restart")

  version_obj.mark_executed()
  def set_kickstart_options(self):
    '''
    Properties that will be used to replace ${XXX} vars in kickstart file.

    '''
    prop = {}
    prop['\$hostname'] = self.hostname

    prop['\$front_ip'] = config.host(self.hostname).get_front_ip()
    prop['\$front_netmask'] = config.general.get_front_netmask()
    prop['\$front_gateway'] = config.general.get_front_gateway_ip()
    prop['\$front_nameserver'] = config.general.get_front_resolver_ip()

    prop['\$back_ip'] = config.host(self.hostname).get_back_ip()
    prop['\$back_netmask'] = config.general.get_back_netmask()
    prop['\$back_gateway'] = config.general.get_back_gateway_ip()
    prop['\$back_nameserver'] = config.general.get_back_resolver_ip()

    prop['\$default_password_crypted'] = app.get_root_password_hash()

    prop['\$disk_swap_mb'] = config.host(self.hostname).get_disk_swap_mb()
    prop['\$disk_var_mb'] = config.host(self.hostname).get_disk_var_mb()
    prop['\$total_disk_mb'] = config.host(self.hostname).get_total_disk_mb()
    prop['\$total_disk_gb'] = config.host(self.hostname).get_total_disk_gb()
    prop['\$boot_device'] = config.host(self.hostname).get_boot_device("vda")

    self.property_list = prop
Esempio n. 4
0
    def set_kickstart_options(self):
        '''
    Properties that will be used to replace ${XXX} vars in kickstart file.

    '''
        prop = {}
        prop['\$hostname'] = self.hostname

        prop['\$front_ip'] = config.host(self.hostname).get_front_ip()
        prop['\$front_netmask'] = config.general.get_front_netmask()
        prop['\$front_gateway'] = config.general.get_front_gateway_ip()
        prop['\$front_nameserver'] = config.general.get_front_resolver_ip()

        prop['\$back_ip'] = config.host(self.hostname).get_back_ip()
        prop['\$back_netmask'] = config.general.get_back_netmask()
        prop['\$back_gateway'] = config.general.get_back_gateway_ip()
        prop['\$back_nameserver'] = config.general.get_back_resolver_ip()

        prop['\$default_password_crypted'] = app.get_root_password_hash()

        prop['\$disk_swap_mb'] = config.host(self.hostname).get_disk_swap_mb()
        prop['\$disk_var_mb'] = config.host(self.hostname).get_disk_var_mb()
        prop['\$total_disk_mb'] = config.host(
            self.hostname).get_total_disk_mb()
        prop['\$total_disk_gb'] = config.host(
            self.hostname).get_total_disk_gb()
        prop['\$boot_device'] = config.host(
            self.hostname).get_boot_device("vda")

        self.property_list = prop
    def set_kickstart_options(self):
        '''
        Properties that will be used to replace ${XXX} vars in kickstart file.

        '''
        prop = {}
        prop['\$hostname'] = self.hostname

        if config.general.is_back_enabled():

            back_line = \
                "network --bootproto=static --ip=" + \
                config.host(self.hostname).get_back_ip() + \
                " --netmask=" + \
                config.general.get_back_netmask() + \
                " --hostname=" + \
                self.hostname + \
                " --device=eth0 --onboot=on --noipv6"

            #Resolver and gateway optional on back net
            if config.general.get_back_resolver_ip() is not None:
                back_line += " --nameserver=" + \
                    config.general.get_back_resolver_ip()

            if config.general.get_back_gateway_ip() is not None:
                back_line += " --gateway=" + \
                    config.general.get_back_gateway_ip()

            front_if = "eth1"
        else:
            back_line = ""
            front_if = "eth0"

        front_line = \
            "network --bootproto=static --ip=" + \
            config.host(self.hostname).get_front_ip() + \
            " --netmask=" + \
            config.general.get_front_netmask() + \
            " --gateway=" + \
            config.general.get_front_gateway_ip() + \
            " --hostname=" + \
            self.hostname + \
            " --device=" + \
            front_if + \
            " --onboot=on --nameserver=" + \
            config.general.get_front_resolver_ip() + \
            " --noipv6"

        prop['\$backnet_kickstart_line'] = back_line
        prop['\$frontnet_kickstart_line'] = front_line

        prop['\$default_password_crypted'] = app.get_root_password_hash()

        prop['\$disk_swap_mb'] = config.host(self.hostname).get_disk_swap_mb()
        prop['\$disk_var_mb'] = config.host(self.hostname).get_disk_var_mb()
        prop['\$disk_log_mb'] = config.host(self.hostname).get_disk_log_mb()
        prop['\$total_disk_mb'] = config.host(self.hostname).get_total_disk_mb()
        prop['\$total_disk_gb'] = config.host(self.hostname).get_total_disk_gb()
        prop['\$boot_device'] = config.host(self.hostname).get_boot_device("vda")
        prop['\$vol_group'] = config.host(self.hostname).get_vol_group()

        self.property_list = prop
Esempio n. 6
0
    def set_kickstart_options(self):
        '''
        Properties that will be used to replace ${XXX} vars in kickstart file.

        '''
        prop = {}
        prop['\$hostname'] = self.hostname

        if config.general.is_back_enabled():

            back_line = \
                "network --bootproto=static --ip=" + \
                config.host(self.hostname).get_back_ip() + \
                " --netmask=" + \
                config.general.get_back_netmask() + \
                " --hostname=" + \
                self.hostname + \
                " --device=eth0 --onboot=on --noipv6"

            #Resolver and gateway optional on back net
            if config.general.get_back_resolver_ip() is not None:
                back_line += " --nameserver=" + \
                    config.general.get_back_resolver_ip()

            if config.general.get_back_gateway_ip() is not None:
                back_line += " --gateway=" + \
                    config.general.get_back_gateway_ip()

            front_if = "eth1"
        else:
            back_line = ""
            front_if = "eth0"

        front_line = \
            "network --bootproto=static --ip=" + \
            config.host(self.hostname).get_front_ip() + \
            " --netmask=" + \
            config.general.get_front_netmask() + \
            " --gateway=" + \
            config.general.get_front_gateway_ip() + \
            " --hostname=" + \
            self.hostname + \
            " --device=" + \
            front_if + \
            " --onboot=on --nameserver=" + \
            config.general.get_front_resolver_ip() + \
            " --noipv6"

        prop['\$backnet_kickstart_line'] = back_line
        prop['\$frontnet_kickstart_line'] = front_line

        prop['\$default_password_crypted'] = app.get_root_password_hash()

        prop['\$disk_swap_mb'] = config.host(self.hostname).get_disk_swap_mb()
        prop['\$disk_var_mb'] = config.host(self.hostname).get_disk_var_mb()
        prop['\$disk_log_mb'] = config.host(self.hostname).get_disk_log_mb()
        prop['\$total_disk_mb'] = config.host(
            self.hostname).get_total_disk_mb()
        prop['\$total_disk_gb'] = config.host(
            self.hostname).get_total_disk_gb()
        prop['\$boot_device'] = config.host(
            self.hostname).get_boot_device("vda")
        prop['\$vol_group'] = config.host(self.hostname).get_vol_group()

        self.property_list = prop
Esempio n. 7
0
def _modify_cobbler_settings():
    app.print_verbose("Update cobbler config files")
    general.set_config_property(
        "/etc/cobbler/settings", '^server:.*',
        "server: " + config.general.get_installation_server_ip())
    general.set_config_property(
        "/etc/cobbler/settings", '^next_server:.*',
        "next_server: " + config.general.get_installation_server_ip())
    general.set_config_property("/etc/cobbler/settings",
                                '^default_virt_bridge:.*',
                                "default_virt_bridge: br0")
    general.set_config_property(
        "/etc/cobbler/settings", '^default_password_crypted:.*',
        "default_password_crypted: " + app.get_root_password_hash())
    general.set_config_property("/etc/cobbler/settings",
                                '^default_virt_type:.*',
                                "default_virt_type: qemu")
    general.set_config_property("/etc/cobbler/settings", '^anamon_enabled:.*',
                                "anamon_enabled: 1")
    general.set_config_property("/etc/cobbler/settings",
                                '^yum_post_install_mirror:.*',
                                "yum_post_install_mirror: 1")
    general.set_config_property("/etc/cobbler/settings", '^manage_dhcp:.*',
                                "manage_dhcp: 1")

    # Email out a report when cobbler finishes installing a system.
    general.set_config_property('/etc/cobbler/settings',
                                '^build_reporting_enabled:.*',
                                'build_reporting_enabled: 1')
    general.set_config_property(
        '/etc/cobbler/settings', '^build_reporting_email::.*',
        "build_reporting_email: [ '%s' ]" % config.general.get_admin_email())

    # Setup kickstart files.
    shutil.copyfile(app.SYCO_PATH + "/var/kickstart/cobbler.ks",
                    "/var/lib/cobbler/kickstarts/cobbler.ks")

    # Configure DHCP
    shutil.copyfile(app.SYCO_PATH + "/var/dhcp/dhcp.template",
                    "/etc/cobbler/dhcp.template")

    # Config crontab to update repo automagically
    general.set_config_property2(
        "/etc/crontab", "01 4 * * *  root       syco install-cobbler-refresh")

    # Set apache servername
    general.set_config_property(
        "/etc/httpd/conf/httpd.conf", "#ServerName www.example.com:80",
        "ServerName " + config.general.get_installation_server() + ":80")
    x("/etc/init.d/httpd restart")

    x("/etc/init.d/cobblerd restart")

    # Wait for cobblered to restart
    time.sleep(1)

    # Iptables rules need be fixed now.
    x("cobbler get-loaders")

    # Setup distro/repo for centos
    x("cobbler check")
Esempio n. 8
0
def _modify_cobbler_settings():
  app.print_verbose("Update cobbler config files")
  general.set_config_property("/etc/cobbler/settings", '^server:.*', "server: " + config.general.get_installation_server_ip())
  general.set_config_property("/etc/cobbler/settings", '^next_server:.*', "next_server: " + config.general.get_installation_server_ip())
  general.set_config_property("/etc/cobbler/settings", '^default_virt_bridge:.*', "default_virt_bridge: br0")
  general.set_config_property("/etc/cobbler/settings", '^default_password_crypted:.*', "default_password_crypted: " + app.get_root_password_hash())
  general.set_config_property("/etc/cobbler/settings", '^default_virt_type:.*', "default_virt_type: qemu")
  general.set_config_property("/etc/cobbler/settings", '^anamon_enabled:.*', "anamon_enabled: 1")
  general.set_config_property("/etc/cobbler/settings", '^yum_post_install_mirror:.*', "yum_post_install_mirror: 1")
  general.set_config_property("/etc/cobbler/settings", '^manage_dhcp:.*', "manage_dhcp: 1")

  # Email out a report when cobbler finishes installing a system.
  general.set_config_property(
    '/etc/cobbler/settings',
    '^build_reporting_enabled:.*',
    'build_reporting_enabled: 1'
  )
  general.set_config_property(
    '/etc/cobbler/settings',
    '^build_reporting_email::.*',
    "build_reporting_email: [ '%s' ]" % config.general.get_admin_email()
  )

  # Setup kickstart files.
  shutil.copyfile(app.SYCO_PATH + "/var/kickstart/cobbler.ks", "/var/lib/cobbler/kickstarts/cobbler.ks")

  # Configure DHCP
  shutil.copyfile(app.SYCO_PATH + "/var/dhcp/dhcp.template", "/etc/cobbler/dhcp.template")

  # Config crontab to update repo automagically
  general.set_config_property2("/etc/crontab", "01 4 * * *  root       syco install-cobbler-refresh")

  # Set apache servername
  general.set_config_property("/etc/httpd/conf/httpd.conf", "#ServerName www.example.com:80", "ServerName " + config.general.get_installation_server() + ":80")
  x("/etc/init.d/httpd restart")

  x("/etc/init.d/cobblerd restart")

  # Wait for cobblered to restart
  time.sleep(1)

  # Iptables rules need be fixed now.
  x("cobbler get-loaders")

  # Setup distro/repo for centos
  x("cobbler check")