コード例 #1
0
def uninstall(state=None, host=None):
    supported_schema_versions = [
        v1beta3.HttpData,
    ]

    validate_schema_version(host.data.http, supported_schema_versions)

    if 'apache2.service' in host.fact.systemd_status:
        systemd.service(
            name='Stop apache2',
            service='apache2',
            running=False,
            sudo=True,
            state=state,
            host=host,
        )

    files.file(
        name='Remove custom config',
        path=str(Path('/etc') / 'apache2' / 'conf-available' / 'root.conf'),
        present=False,
        sudo=True,
        state=state,
        host=host,
    )

    apt.packages(
        name='Ensure apache2 package is not present',
        packages=['apache2'],
        present=False,
        sudo=True,
        state=state,
        host=host,
    )
コード例 #2
0
def delete(state=None, host=None):
    supported_schema_versions = [
        v1beta3.DhcpData,
    ]

    validate_schema_version(host.data.dhcp, supported_schema_versions)

    filename = "dhcp-disable.sh.j2"
    file_path = './dhcp-disable.sh'

    files.template(
        name='Render configuration script',
        src=deploy_dir / 'templates' / filename,
        dest=file_path,
        mode='700',
        state=state,
        host=host,
    )

    server.shell(
        name="Execute configuration script",
        commands=[file_path],
        state=state,
        host=host,
    )
コード例 #3
0
def configure(state=None, host=None):
    supported_schema_versions = [
        v1beta3.PxeData,
    ]

    validate_schema_version(host.data.pxe, supported_schema_versions)

    #
    # Download bootfile(s)
    #

    for bootfile in host.data.pxe.bootfiles:
        bootfile_dir = (host.data.pxe.tftp.root_dir /
                        bootfile.get_path()).parent

        files.directory(
            name='Ensure bootfile directory',
            path=str(bootfile_dir),
            present=True,
            sudo=True,
            host=host,
            state=state,
        )

        files.download(
            name=f'Download bootfile {bootfile.get_path()}',
            src=str(bootfile.image_source_url),
            dest=str(host.data.pxe.tftp.root_dir / bootfile.get_path()),
            sha256sum=bootfile.image_sha256sum,
            sudo=True,
            host=host,
            state=state,
        )

    if host.data.pxe.installer.type == InstallerType.autoinstall_v1:
        configure_installer_type_autoinstall_v1(state=state, host=host)
    elif host.data.pxe.installer.type == InstallerType.legacy_netboot:
        configure_installer_type_legacy_netboot(state=state, host=host)
    else:
        raise UnsupportedInstallerTypeError(host.data.pxe.installer)

    # TODO: Check if this should be moved to apache2.py and if doing that requires
    #       that pxe.configure be executed prior to apache2.configure
    files.directory(
        name=
        f"Ensure www-data has read permissions in {host.data.pxe.http.root_dir}",
        path=str(host.data.pxe.http.root_dir),
        user='******',
        group='www-data',
        mode='0755',
        recursive=True,
        sudo=True,
        state=state,
        host=host,
    )
コード例 #4
0
def configure(state=None, host=None):
    supported_schema_versions = [
        v1beta3.HttpData,
    ]

    validate_schema_version(host.data.http, supported_schema_versions)

    apt.packages(
        name='Install package',
        packages=['apache2'],
        sudo=True,
        state=state,
        host=host,
    )

    files.directory(
        name=f'Ensure HTTP root dir {host.data.http.root_dir}',
        path=str(host.data.http.root_dir),
        present=True,
        recursive=True,
        sudo=True,
        state=state,
        host=host,
    )

    apache_conf = files.template(
        name='Render config file',
        src=str(deploy_dir / 'templates' / 'apache2-directory.conf.j2'),
        dest=str(Path('/etc') / 'apache2' / 'conf-available' / 'root.conf'),
        mode='744',
        user='******',
        group='root',
        sudo=True,
        http=host.data.http,
        state=state,
        host=host,
    )

    server.shell(
        name='Enable root.conf',
        commands=['a2enconf root'],
        sudo=True,
        state=state,
        host=host,
    )

    systemd.service(
        name='Restart apache2',
        service='apache2',
        running=True,
        restarted=apache_conf.changed,
        sudo=True,
        state=state,
        host=host,
    )
コード例 #5
0
def configure(state=None, host=None):
    supported_schemas = [
        v1beta3.DnsmasqData
    ]

    validate_schema_version(host.data.dnsmasq, supported_schemas)

    apt.packages(
        name='Install dnsmasq',
        packages=['dnsmasq'],
        sudo=True,

        state=state, host=host,
    )

    if host.data.dnsmasq.tftp is not None:
        files.directory(
            name=f'Ensure TFTP root dir {host.data.dnsmasq.tftp.root_dir}',
            path=str(host.data.dnsmasq.tftp.root_dir),
            present=True,
            recursive=True,
            sudo=True,

            state=state, host=host,
        )

    dnsmasq_conf = files.template(
        name='Render the dnsmasq config',
        src=str(deploy_dir / 'templates' / 'dnsmasq.conf.j2'),
        dest=str(Path('/etc') / 'dnsmasq.conf'),
        mode='744',
        user='******',
        group='root',
        sudo=True,
        dnsmasq=host.data.dnsmasq,

        state=state, host=host,
    )

    systemd.service(
        name='Restart dnsmasq',
        service='dnsmasq',
        running=True,
        restarted=dnsmasq_conf.changed,
        sudo=True,

        state=state, host=host,
    )
コード例 #6
0
def uninstall(state=None, host=None):
    supported_schemas = [
        v1beta3.DnsmasqData
    ]

    validate_schema_version(host.data.dnsmasq, supported_schemas)

    if 'dnsmasq.service' in host.fact.systemd_status:
        systemd.service(
            name='Stop dnsmasq',
            service='dnsmasq',
            running=False,
            sudo=True,

            state=state, host=host,
        )

    files.file(
        name='Remove dnsmasq config',
        path=str(Path('/etc') / 'dnsmasq.conf'),
        present=False,
        sudo=True,

        state=state, host=host,
    )

    if host.data.dnsmasq.tftp is not None:
        files.directory(
            name=f'Remove TFTP root dir {host.data.dnsmasq.tftp.root_dir}',
            path=str(host.data.dnsmasq.tftp.root_dir),
            present=False,
            recursive=False,
            sudo=True,

            state=state, host=host,
        )

    apt.packages(
        name='Ensure dnsmasq package is not present',
        packages=['dnsmasq'],
        present=False,
        sudo=True,

        state=state, host=host,
    )
コード例 #7
0
def configure(state=None, host=None):
    supported_schema_versions = [
        v1beta3.PxeData,
    ]

    validate_schema_version(host.data.pxe, supported_schema_versions)

    #
    # Download bootfile(s)
    #

    for bootfile in host.data.pxe.bootfiles:
        bootfile_dir = (host.data.pxe.tftp.root_dir /
                        bootfile.get_path()).parent

        files.directory(
            name='Ensure bootfile directory',
            path=str(bootfile_dir),
            present=True,
            sudo=True,
            host=host,
            state=state,
        )

        files.download(
            name=f'Download bootfile {bootfile.get_path()}',
            src=str(bootfile.image_source_url),
            dest=str(host.data.pxe.tftp.root_dir / bootfile.get_path()),
            sha256sum=bootfile.image_sha256sum,
            sudo=True,
            host=host,
            state=state,
        )

    if host.data.pxe.installer.type == InstallerType.autoinstall_v1:
        configure_installer_type_autoinstall_v1(state=state, host=host)
    elif host.data.pxe.installer.type == InstallerType.legacy_netboot:
        configure_installer_type_legacy_netboot(state=state, host=host)
    else:
        raise UnsupportedInstallerTypeError(host.data.pxe.installer)