コード例 #1
0
def push_only_ASP_script():
    """push only /usr/local/bin/apply_system_patches script to the latest vesion"""

    # upload shell
    src = os.path.join(TEMPLATE_DIR, 'patch', 'apply_system_patches')
    dst = '/usr/local/bin/apply_system_patches'
    upload(src, dst, use_sudo=True, mode=0700)
コード例 #2
0
ファイル: repos.py プロジェクト: zipi85/AWL
def add_cron_clean_all():
    """
    upload crontab to clean up /var/cache/yum/

    Usage: fab repos.add_cron_clean_all -H host1,hostn
    """

    src = os.path.join(TEMPLATE_DIR, 'repos', 'yum-clean-all.cron')
    dst = '/etc/cron.d/yum-clean-all'
    upload(src, dst, use_sudo=True, mode=0600)
コード例 #3
0
def add_menu_watchdog():
    """upload menu watchdog for integ"""

    # only available on C6+
    if get_distrib_version().startswith('6'):
        src_sudo = os.path.join(TEMPLATE_DIR, 'watchdog', 'menu-watchdog.sudoers')
        dst_sudo = '/etc/sudoers.d/menu-watchdog'
        upload(src_sudo, dst_sudo, use_sudo=True, mode=0440)

        src_menu = os.path.join(TEMPLATE_DIR, 'watchdog', 'menu-watchdog.c6')
        dst_menu = '/opt/local/watch_script/Watchdog_LWDA_menu.ksh'
	run_as_root('mkdir -p /opt/local/watch_script && chmod 755 /opt/local/watch_script')
        upload(src_menu, dst_menu, use_sudo=True, mode=0755)
    else:
        abort('OS not supported')
コード例 #4
0
ファイル: patchmonthly.py プロジェクト: zipi85/AWL
def upload_dependencies(table_patchxpress):
    """create dependencie file and upload it"""

    # search hostname in the table patchxpress
    row = table_patchxpress.find_one(HOST=env.host)
    if row:
        content = "%(CHECK_HOSTS)s \n" % row
        # create an in-memory file object and delivers it on host
        src = StringIO(content)
        dst = '/etc/apply_system_patches.dependencies'
        upload(src, dst, use_sudo=True, mode=0600)
    else:
        # a planing must exists in patchxpress but we want to be able to upload the shells anyway
        print yellow(
            '%s does not exist in patchxpress, do not upload dependencies' %
            env.host)
コード例 #5
0
ファイル: repos.py プロジェクト: zipi85/AWL
def add_yum_post_action():
    """
    upload yum post-actions script to delete official centos repos

    Usage: fab repos.add_yum_post_action -H host1,hostn
    """

    # post-actions is available only on C6+
    if get_distrib_version().startswith('6'):
        with settings(hide('stdout')):
            run_as_root(
                'yum -y install yum-plugin-post-transaction-actions.noarch')

        src = os.path.join(TEMPLATE_DIR, 'repos', 'remove-centos-repos.action')
        dst = '/etc/yum/post-actions/remove-centos-repos.action'
        upload(src, dst, use_sudo=True, mode=0644)
コード例 #6
0
ファイル: repos.py プロジェクト: zipi85/AWL
def add_disable_repos():
    """
    upload crontab and shell to disable the repos

    Usage: fab repos.add_disable_repos -H host1,hostn
    """

    # cron file
    src_cron = os.path.join(TEMPLATE_DIR, 'repos', 'disable-repos.cron')
    dst_cron = '/etc/cron.d/disable-repos'

    # shell
    src_shell = os.path.join(TEMPLATE_DIR, 'repos', 'disable-repos')
    dst_shell = '/usr/local/bin/disable-repos'

    # upload cron
    upload(src_cron, dst_cron, use_sudo=True, mode=0600)

    # upload shell
    upload(src_shell, dst_shell, use_sudo=True, mode=0700)
コード例 #7
0
ファイル: patchmonthly.py プロジェクト: zipi85/AWL
def upload_cron(table_patchxpress):
    """create cron file and upload it"""

    # search hostname in the table patchxpress
    rows = table_patchxpress.find(HOST=env.host)
    content = []

    # there can be several definition for one host
    for row in rows:
        line = "%(CRONTAB_ACTIF)s%(CRONTAB_MINUTES)s %(CRONTAB_HEURES)s %(CRONTAB_JOUR_MOIS)s %(CRONTAB_MOIS)s %(CRONTAB_JOUR_SEMAINE)s %(CRONTAB_BINAIRE)s %(REBOOT)s %(WARNING_PILOTAGE)s %(CRONTAB_TRACE)s \n" % row
        content.append(line)

    if content:
        # create an in-memory file object and delivers it on host
        print content
        src = StringIO("\n".join(content))
        dst = '/etc/cron.d/apply_system_patches'
        upload(src, dst, use_sudo=True, mode=0600)
    else:
        # a planing must exists in patchxpress, but we want to be able to upload the shells anyway
        print yellow(
            '%s does not exist in patchxpress, do not upload crontab' %
            env.host)
コード例 #8
0
ファイル: patchmonthly.py プロジェクト: zipi85/AWL
def upload_shell():
    """upload apply_system_patches shell to manage patches and reboot"""

    # upload shell
    src = os.path.join(TEMPLATE_DIR, 'patch', 'apply_system_patches')
    dst = '/usr/local/bin/apply_system_patches'
    upload(src, dst, use_sudo=True, mode=0700)

    # upload disable shell
    src = os.path.join(TEMPLATE_DIR, 'patch', 'DISABLE_apply_system_patches')
    dst = '/usr/local/bin/DISABLE_apply_system_patches'
    upload(src, dst, use_sudo=True, mode=0700)

    # upload enable shell
    src = os.path.join(TEMPLATE_DIR, 'patch', 'ENABLE_apply_system_patches')
    dst = '/usr/local/bin/ENABLE_apply_system_patches'
    upload(src, dst, use_sudo=True, mode=0700)

    # touch /etc/apply_system_patches.LAUNCH
    append('/etc/apply_system_patches.LAUNCH', 'True', use_sudo=True)

    # upload sudoers permissions
    # RHEL5: If the permissions of a file under /etc/sudoers.d/ are wrong,
    #        sudo cannot be use anymore until the correction is made.
    #        the files ending with a `~' or `.' character are ignore.
    # RHEL6: A message is shown and the commands in the file are not made available
    #        but it doesn't stop our script
    src = os.path.join(TEMPLATE_DIR, 'patch', 'manage_patches')
    if get_distrib_version().startswith('5'):
        tmp = '/etc/sudoers.d/manage_patches~'
        dst = '/etc/sudoers.d/manage_patches'
        upload(src, tmp, use_sudo=True, mode=0440)
        sudo('mv %s %s' % (tmp, dst))
    else:
        dst = '/etc/sudoers.d/manage_patches'
        upload(src, dst, use_sudo=True, mode=0440)

    # upload post-update for RHEL5
    if get_distrib_version().startswith('5'):
        src = os.path.join(TEMPLATE_DIR, 'patch', 'post-update')
        dst = '/usr/local/bin/post-update'
        upload(src, dst, use_sudo=True, mode=0700)
コード例 #9
0
ファイル: sudoers.py プロジェクト: zipi85/AWL
def upload_sudo_lcmd():
    """upload /usr/local/bin/sudo_lcmd"""
    src = os.path.join(TEMPLATE_DIR, 'sudoers', 'sudo_lcmd')
    dest = '/usr/local/bin/sudo_lcmd'

    upload(src, dest, use_sudo=True, mode=0755)