Example #1
0
def nginx_configureplaybook(prefix='/usr/local',
                            workproc='1',
                            pid='logs/nginx.pid',
                            workconn='1024',
                            port='80',
                            servername='localhost',
                            locations=''):
    _ext_vars = {
        'prefix': prefix,
        'basedir': '{{prefix}}/nginx',
        'user': '******',
        'workproc': workproc,
        'pid': pid,
        'workconn': workconn,
        'port': port,
        'servername': servername,
        'locations': locations,
    }
    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("configure nginx", 'no')
    task1 = PersonTask(
        module="template",
        args=
        "dest={{basedir}}/conf/nginx.conf src=%s/nginx.j2 owner=nginx group=nginx mode=644"
        % TEMPLATEDIR,
    )
    pb.add_task(task1)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #2
0
def java_installplaybook(version='7u79',
                         prefix='/usr/local',
                         checksum='9222e097e624800fdd9bfb568169ccad'):
    _ext_vars = {
        'version': version,
        'prefix': prefix,
        'file': 'jdk-{{version}}-linux-x64.tar.gz',
        'fro': 'http://%s/package/java/{{file}}' % FTP,
        'checksum': checksum
    }
    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("install java", 'no')
    task1 = PersonTask(
        module="get_url",
        args="checksum=md5:{{checksum}} url={{fro}} dest=~",
    )
    task2 = PersonTask(
        module="script",
        args="%s/java/java_install.sh -v {{version}} -f {{prefix}}" %
        SCRIPTS_DIR,
    )
    task3 = PersonTask(
        module="file",
        args="dest=~/{{file}} state=absent",
    )
    pb.add_task(task1)
    pb.add_task(task2)
    pb.add_task(task3)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #3
0
def base_personplaybook():
    _ext_vars={'yum_repo':'/etc/yum.repos.d',
               'md5sum':'ccd96d70ecfe3b1655c98d8dabd8dcb5',
               'url':'http://%s/repos/Zbjt.repo'%FTP,}
    personblock=PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb=PersonBook("install base soft",'no')
    task1=PersonTask(module="shell",args="tar -cvzf ~/bk.tar.gz {{yum_repo}}/* --remove-files",)
    task2=PersonTask(module="get_url",args="checksum=md5:{{md5sum}} url={{url}} dest={{yum_repo}}/",)
    task3=PersonTask(module="shell",args="yum clean all;yum makecache;",)
    #task4=PersonTask(module="yum", args="name=gcc state=present", )
    task4=PersonTask(module="shell",args='yum install gcc -y')
    #task5=PersonTask(module="yum",args="name=make state=present",)
    task5=PersonTask(module='shell',args='yum install make -y')
    #task6=PersonTask(module="yum",args="name=libaio state=present",)
    task6=PersonTask(module='shell',args='yum install libaio -y')
    #task7=PersonTask(module="yum",args="name=libselinux-python state=present",)
    task7=PersonTask(module='shell',args='yum install libselinux-python -y')
    #task8=PersonTask(module="yum",args="name=expect state=present")
    task8=PersonTask(module='shell',args='yum install expect -y')
    pb.add_task(task1)
    pb.add_task(task2)
    pb.add_task(task3)
    pb.add_task(task4)
    pb.add_task(task5)
    pb.add_task(task6)
    pb.add_task(task7)
    pb.add_task(task8)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #4
0
def redis_configureplaybook(version='3.2.4',prefix='/usr/local',bind='0.0.0.0',port='6379',appendonly='yes',noonrewrite='no',saveoptions='save 900 300\nsave 30 10\nsave 2000 1',datadir='{{basedir}}',requirepass='******',slaveof='',masterauth='',cluster_enabled='',cluster_config_file='',extend=''):
    _ext_vars={
        'prefix':   prefix,
        'basedir':  '{{prefix}}/redis',
        'bind':bind,
        'port':port,
        'appendonly':appendonly,
        'noonrewrite':noonrewrite,
        'logfile':'{{basedir}}/{{port}}.log',
        'saveoptions':saveoptions,
        'dbfilename':'{{port}}.rdb',
        'dir':datadir,
        'requirepass':requirepass,
        #'slaveof':'slaveof mip mport',
        'slaveof':slaveof,
        #'masterauth':'masterauth Redis',
        'masterauth':masterauth,
        #'cluster_enabled':'cluster-enabled yes',
        'cluster_enabled':cluster_enabled,
        #'cluster_config_file':'cluster-config-file nodes-{{port}}.conf',
        'cluster_config_file':cluster_config_file,
        'extend':extend,
    }
    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("control redis", 'no')
    task1 = PersonTask(module="template", args="dest=/etc/redis.conf src=%s/redis/redis%s.j2 owner=redis group=redis mode=644"%(TEMPLATEDIR,version), )
    print('0000000')
    print("dest=/etc/redis.conf src=%s/redis/redis%s.j2 owner=redis group=redis mode=644"%(TEMPLATEDIR,version))
    pb.add_task(task1)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #5
0
def tomcat_installplaybook(version='7.0.72',prefix='/usr/local',java_opts='',checksum='c24bfae15bb9c510451a05582aae634d'):
    _ext_vars = {
        'version':version,
        'prefix': prefix,
        'basedir': '{{prefix}}/tomcat',
        'java_home':'{{prefix}}/java',
        'java_opts':java_opts,
        'file': 'apache-tomcat-{{version}}.tar.gz',
        'fro': 'http://%s/package/tomcat/{{file}}' % FTP,
        'checksum': checksum}
    personblock = PersonBlock()
    print(SCRIPTS_DIR)
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("install tomcat", 'no')
    task1 = PersonTask(module="get_url", args="checksum=md5:{{checksum}} url={{fro}} dest=~", )
    task2 = PersonTask(module="script",
                       args="%s/tomcat/tomcat_install.sh -v {{version}} -f {{prefix}}"%SCRIPTS_DIR, )
    task3 = PersonTask(module="file", args="dest=~/{{file}} state=absent", )
    task4 = PersonTask(module="template",
                       args="dest={{basedir}}/bin/setenv.sh src=%s/setenv.j2 owner=root group=root mode=755"%TEMPLATEDIR, )
    pb.add_task(task1)
    pb.add_task(task2)
    pb.add_task(task3)
    pb.add_task(task4)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #6
0
def iptables_controlplaybook(control='restart'):
    _ext_vars = {'control': control}
    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("control iptables ", 'no')
    task1 = PersonTask(
        module="shell",
        args="/etc/init.d/iptables {{control}}",
    )
    pb.add_task(task1)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #7
0
def redis_configureplaybook(
        version='3.2.4',
        prefix='/usr/local',
        bind='0.0.0.0',
        port='6379',
        appendonly='yes',
        noonrewrite='no',
        saveoptions='save 900 300\nsave 30 10\nsave 2000 1',
        datadir='{{basedir}}',
        requirepass='******',
        slaveof='',
        masterauth='',
        cluster_enabled='',
        cluster_config_file='',
        extend=''):
    _ext_vars = {
        'prefix': prefix,
        'basedir': '{{prefix}}/redis',
        'bind': bind,
        'port': port,
        'appendonly': appendonly,
        'noonrewrite': noonrewrite,
        'logfile': '{{basedir}}/{{port}}.log',
        'saveoptions': saveoptions,
        'dbfilename': '{{port}}.rdb',
        'dir': datadir,
        'requirepass': requirepass,
        #'slaveof':'slaveof mip mport',
        'slaveof': slaveof,
        #'masterauth':'masterauth Redis',
        'masterauth': masterauth,
        #'cluster_enabled':'cluster-enabled yes',
        'cluster_enabled': cluster_enabled,
        #'cluster_config_file':'cluster-config-file nodes-{{port}}.conf',
        'cluster_config_file': cluster_config_file,
        'extend': extend,
    }
    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("control redis", 'no')
    task1 = PersonTask(
        module="template",
        args=
        "dest=/etc/redis.conf src=%s/redis/redis%s.j2 owner=redis group=redis mode=644"
        % (TEMPLATEDIR, version),
    )
    print('0000000')
    print(
        "dest=/etc/redis.conf src=%s/redis/redis%s.j2 owner=redis group=redis mode=644"
        % (TEMPLATEDIR, version))
    pb.add_task(task1)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #8
0
def java_removeplaybook(prefix='/usr/local'):
    _ext_vars = {'prefix': prefix}
    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("remove java", 'no')
    task1 = PersonTask(
        module="script",
        args="%s/java/java_remove.sh -f {{prefix}}" % SCRIPTS_DIR,
    )
    pb.add_task(task1)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #9
0
def redis_removeplaybook(prefix='/usr/local'):
    _ext_vars = {'prefix': prefix, 'user': '******'}
    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("install redis", 'no')
    task1 = PersonTask(
        module="script",
        args="%s/redis/redis_remove.sh -u {{user}} -f {{prefix}}" %
        SCRIPTS_DIR,
    )
    pb.add_task(task1)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #10
0
def mysql_initializationplaybook(mysqlpasswd='000000'):
    _ext_vars = {
        'mysqlpasswd': mysqlpasswd,
    }
    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("initialization mysql", 'no')
    task1 = PersonTask(
        module="script",
        args="%s/mysql/mysql_answer.exp {{mysqlpasswd}}" % SCRIPTS_DIR,
    )
    pb.add_task(task1)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #11
0
def tomcat_controlplaybook(control='start'):
    _ext_vars = {
        'control': control,
    }
    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("control tomcat", 'no')
    task1 = PersonTask(
        module="script",
        args="%s/tomcat/tomcat_control.sh {{control}}" % SCRIPTS_DIR,
    )
    pb.add_task(task1)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #12
0
def shell_book(shell='hostname'):
    _ext_vars = {
        'shell': shell,
    }
    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("shell iptables ", 'no')
    task1 = PersonTask(
        module="shell",
        args="{{shell}}",
    )
    pb.add_task(task1)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #13
0
def java_removeplaybook(prefix='/usr/local'):
    _ext_vars={
        'prefix':prefix
    }
    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("remove java", 'no')
    task1 = PersonTask(module="script", args="%s/java/java_remove.sh -f {{prefix}}"%SCRIPTS_DIR, )
    pb.add_task(task1)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #14
0
def redis_removeplaybook(prefix='/usr/local'):
    _ext_vars={
        'prefix':prefix,
        'user': '******'
    }
    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("install redis", 'no')
    task1 = PersonTask(module="script", args="%s/redis/redis_remove.sh -u {{user}} -f {{prefix}}"%SCRIPTS_DIR, )
    pb.add_task(task1)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #15
0
def tomcat_controlplaybook(control='start'):
    _ext_vars = {
        'control':control,
    }
    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("control tomcat", 'no')
    task1 = PersonTask(module="script",
                       args="%s/tomcat/tomcat_control.sh {{control}}"%SCRIPTS_DIR,)
    pb.add_task(task1)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #16
0
def nginx_controlplaybook(control='start',
                          pid='/usr/local/nginx/logs/nginx.pid'):
    _ext_vars = {
        'control': control,
        'pid': pid,
    }
    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("control nginx", 'no')
    task1 = PersonTask(
        module="script",
        args="%s/nginx/nginx_control.sh {{control}} {{pid}}" % SCRIPTS_DIR,
    )
    pb.add_task(task1)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #17
0
def nginx_removeplaybook(prefix='/usr/local', ):
    _ext_vars = {
        'prefix': prefix,
        'user': '******',
    }

    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("remove nginx", 'no')
    task1 = PersonTask(
        module="script",
        args="%s/nginx/nginx_remove.sh -f {{prefix}}" % SCRIPTS_DIR,
    )
    pb.add_task(task1)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #18
0
def redis_controlplaybook(control='start',passwd='000000'):
    _ext_vars={
        'control':control,
        'passwd':passwd,
    }
    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("control redis", 'no')
    if control=='stop':
        task1 = PersonTask(module="script", args="%s/redis/redis_control.sh {{control}} {{passwd}}"%SCRIPTS_DIR, )
    else:
        task1 = PersonTask(module="script", args="%s/redis/redis_control.sh {{control}}"%SCRIPTS_DIR, )
    pb.add_task(task1)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #19
0
def tomcat_installplaybook(version='7.0.72',
                           prefix='/usr/local',
                           java_opts='',
                           checksum='c24bfae15bb9c510451a05582aae634d'):
    _ext_vars = {
        'version': version,
        'prefix': prefix,
        'basedir': '{{prefix}}/tomcat',
        'java_home': '{{prefix}}/java',
        'java_opts': java_opts,
        'file': 'apache-tomcat-{{version}}.tar.gz',
        'fro': 'http://%s/package/tomcat/{{file}}' % FTP,
        'checksum': checksum
    }
    personblock = PersonBlock()
    print(SCRIPTS_DIR)
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("install tomcat", 'no')
    task1 = PersonTask(
        module="get_url",
        args="checksum=md5:{{checksum}} url={{fro}} dest=~",
    )
    task2 = PersonTask(
        module="script",
        args="%s/tomcat/tomcat_install.sh -v {{version}} -f {{prefix}}" %
        SCRIPTS_DIR,
    )
    task3 = PersonTask(
        module="file",
        args="dest=~/{{file}} state=absent",
    )
    task4 = PersonTask(
        module="template",
        args=
        "dest={{basedir}}/bin/setenv.sh src=%s/setenv.j2 owner=root group=root mode=755"
        % TEMPLATEDIR,
    )
    pb.add_task(task1)
    pb.add_task(task2)
    pb.add_task(task3)
    pb.add_task(task4)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #20
0
def iptables_configureplaybook(dport="80", protocol="tcp", jump="ACCEPT"):
    _ext_vars = {
        'chain': "INPUT",
        'dport': dport,
        'ctstate': 'NEW',
        'protocol': protocol,
        'jump': jump,
    }
    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("configure iptables ", 'no')
    task1 = PersonTask(
        module="iptables",
        args=
        "chain={{chain}} destination_port={{dport}} ctstate={{ctstate}} protocol={{protocol}} action=insert jump={{jump}}",
    )
    pb.add_task(task1)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #21
0
def mysql_removeplaybook(prefix='/usr/local', datadir='/usr/local/mysql/data'):
    _ext_vars = {
        'prefix': prefix,
        'basedir': '{{prefix}}/mysql',
        'datadir': datadir,
        'user': '******',
        'conf': '/etc/my.cnf',
    }
    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("remove mysql", 'no')
    task1 = PersonTask(
        module="script",
        args=
        "%s/mysql/mysql_remove.sh -f {{prefix}} -u {{user}} -d {{datadir}} -c {{conf}}"
        % SCRIPTS_DIR,
    )
    pb.add_task(task1)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #22
0
def mysql_configureplaybook(port='3306',
                            socket='/tmp/mysql.sock',
                            prefix='/usr/local',
                            datadir='/usr/local/mysql/data',
                            key_buffer_size='256M',
                            table_open_cache='256',
                            sort_buffer_size='1M',
                            read_buffer_size='1M',
                            read_rnd_buffer_size='4M',
                            query_cache_size='16M',
                            thread_cache_size='8',
                            server_id='1',
                            extend=''):
    _ext_vars = {
        'port': port,
        'socket': socket,
        'prefix': prefix,
        'basedir': '{{prefix}}/mysql',
        'datadir': datadir,
        'key_buffer_size': key_buffer_size,
        'table_open_cache': table_open_cache,
        'sort_buffer_size': sort_buffer_size,
        'read_buffer_size': read_buffer_size,
        'read_rnd_buffer_size': read_rnd_buffer_size,
        'query_cache_size': query_cache_size,
        'thread_cache_size': thread_cache_size,
        'server_id': server_id,
        'extend': extend,
    }
    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("configure mysql", 'no')
    task1 = PersonTask(
        module="template",
        args="dest=/etc/my.cnf src=%s/my.j2 owner=mysql group=mysql mode=644" %
        TEMPLATEDIR,
    )
    pb.add_task(task1)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #23
0
def redis_installplaybook(version='3.2.4',
                          prefix='/usr/local',
                          checksum='2f8b49e8004fbbfc807ca7f5faeabec8',
                          datadir='{{prefix}}/redis/data'):
    _ext_vars = {
        'version': version,
        'prefix': prefix,
        'basedir': '{{prefix}}/redis',
        'user': '******',
        'datadir': datadir,
        'file': 'redis-{{version}}.tar.gz',
        'fro': 'http://%s/package/redis/{{file}}' % FTP,
        'checksum': checksum
    }
    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("install redis", 'no')
    task1 = PersonTask(
        module="get_url",
        args="checksum=md5:{{checksum}} url={{fro}} dest=~",
    )
    task2 = PersonTask(
        module="script",
        args=
        "%s/redis/redis_install.sh -v {{version}} -f {{prefix}} -u {{user}}" %
        SCRIPTS_DIR,
    )
    task3 = PersonTask(
        module="file",
        args="dest=~/{{file}} state=absent",
    )
    task4 = PersonTask(
        module="file",
        args="dest={{datadir}} mode=755 owner=root state=directory")
    pb.add_task(task1)
    pb.add_task(task2)
    pb.add_task(task3)
    pb.add_task(task4)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #24
0
def java_installplaybook(version='7u79',prefix='/usr/local',checksum='9222e097e624800fdd9bfb568169ccad'):
    _ext_vars = {
        'version':version,
        'prefix':prefix,
        'file':'jdk-{{version}}-linux-x64.tar.gz',
        'fro':'http://%s/package/java/{{file}}'%FTP,
        'checksum':checksum}
    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("install java", 'no')
    task1 = PersonTask(module="get_url", args="checksum=md5:{{checksum}} url={{fro}} dest=~", )
    task2 = PersonTask(module="script", args="%s/java/java_install.sh -v {{version}} -f {{prefix}}"%SCRIPTS_DIR, )
    task3 = PersonTask(module="file", args="dest=~/{{file}} state=absent", )
    pb.add_task(task1)
    pb.add_task(task2)
    pb.add_task(task3)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #25
0
def redis_controlplaybook(control='start', passwd='000000'):
    _ext_vars = {
        'control': control,
        'passwd': passwd,
    }
    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("control redis", 'no')
    if control == 'stop':
        task1 = PersonTask(
            module="script",
            args="%s/redis/redis_control.sh {{control}} {{passwd}}" %
            SCRIPTS_DIR,
        )
    else:
        task1 = PersonTask(
            module="script",
            args="%s/redis/redis_control.sh {{control}}" % SCRIPTS_DIR,
        )
    pb.add_task(task1)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #26
0
def nginx_installplaybook(version='1.10.1',
                          prefix='/usr/local',
                          checksum='088292d9caf6059ef328aa7dda332e44'):
    _ext_vars = {
        'version': version,
        'prefix': prefix,
        'basedir': '{{prefix}}/nginx',
        'file': 'nginx-{{version}}.tar.gz',
        'fro': 'http://%s/package/nginx/{{file}}' % FTP,
        'checksum': checksum,
        'user': '******',
    }

    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("install nginx", 'no')
    #task0=PersonTask(module='yum',args='name=pcre-devel state=present')
    task1 = PersonTask(module='shell', args='yum install pcre-devel -y')
    task2 = PersonTask(module='shell', args='yum install zlib-devel -y')
    task3 = PersonTask(
        module="get_url",
        args="checksum=md5:{{checksum}} url={{fro}} dest=~",
    )
    task4 = PersonTask(
        module="script",
        args="%s/nginx/nginx_install.sh -v {{version}} -f {{prefix}}" %
        SCRIPTS_DIR,
    )
    task5 = PersonTask(
        module="file",
        args="dest=~/{{file}} state=absent",
    )
    pb.add_task(task1)
    pb.add_task(task2)
    pb.add_task(task3)
    pb.add_task(task4)
    pb.add_task(task5)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #27
0
def dispatch_getcnf(cnffile):
    t=time.time()
    _ext_vars={'cnffile':cnffile,
               'filename':t,
               }
    personblock=PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb=PersonBook("dispatch getcnf",'no')
    task1=PersonTask(module="fetch",args="src={{cnffile}} dest=/tmp/{{filename}} flat=yes",)
    pb.add_task(task1)
    personblock.set_playbook(pb)
    personblock.run_block()
    f = open(FILENAME%t)
    try:
        str=f.read()
    finally:
        f.close()
        #os.remove(FILENAME%t)
    return (str,FILENAME%t)
Example #28
0
def dispatch_setcnf(src,dest):#src=/tmp/aaaa dest=/etc/hosts dir=/etc file=hosts dispatch_srcdeploy解析地址
    data=dispatch_srcdeploy(dest)
    dir=data[0]
    file=data[1]
    _ext_vars = {
                'src':src,
                'dest':dest,
                'dir': dir,
                'file': file,
                 }
    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("dispatch setcnf", 'no')
    task1 = PersonTask(module="copy", args="src={{src}} mode=644 dest={{dest}} backup=yes", )
    task2 = PersonTask(module="shell",args="find %s -name %s -mmin +61 -exec rm -f {} \;"%(dir,BACK_NAME%file))#删除旧分配备份
    pb.add_task(task1)
    pb.add_task(task2)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #29
0
def mysql_installplaybook(version='10.1.12',
                          prefix='/usr/local',
                          checksum='30a86202c8fe30ad3548988a7ddbf5a3',
                          datadir='/usr/local/mysql/data'):
    _ext_vars = {
        'version': version,
        'prefix': prefix,
        'basedir': '{{prefix}}/mysql',
        'datadir': datadir,
        'user': '******',
        #'file': 'mariadb-{{version}}-linux-{{ansible_architecture}}.tar.gz',
        'file': 'mariadb-{{version}}-linux-x86_64.tar.gz',
        'fro': 'http://%s/package/mysql/{{file}}' % FTP,
        'checksum': checksum
    }
    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("install mysql", 'no')
    task1 = PersonTask(
        module="get_url",
        args="checksum=md5:{{checksum}} url={{fro}} dest=~",
    )
    task2 = PersonTask(
        module="script",
        args=
        "%s/mysql/mysql_install.sh -v {{version}} -f {{prefix}} -u {{user}} -d {{datadir}}"
        % SCRIPTS_DIR,
    )
    task3 = PersonTask(
        module="file",
        args="dest=~/{{file}} state=absent",
    )
    pb.add_task(task1)
    pb.add_task(task2)
    pb.add_task(task3)
    personblock.set_playbook(pb)
    personblock.run_block()
Example #30
0
def redis_installplaybook(version='3.2.4',prefix='/usr/local',checksum='2f8b49e8004fbbfc807ca7f5faeabec8',datadir='{{prefix}}/redis/data'):
    _ext_vars = {
        'version':version,
        'prefix':prefix,
        'basedir':'{{prefix}}/redis',
        'user':'******',
        'datadir':datadir,
        'file':'redis-{{version}}.tar.gz',
        'fro':'http://%s/package/redis/{{file}}'%FTP,
        'checksum':checksum
    }
    personblock = PersonBlock()
    personblock.add_extendvars(_ext_vars)
    pb = PersonBook("install redis",'no')
    task1 = PersonTask(module="get_url", args="checksum=md5:{{checksum}} url={{fro}} dest=~", )
    task2 = PersonTask(module="script", args="%s/redis/redis_install.sh -v {{version}} -f {{prefix}} -u {{user}}"%SCRIPTS_DIR, )
    task3 = PersonTask(module="file", args="dest=~/{{file}} state=absent", )
    task4 = PersonTask(module="file",args="dest={{datadir}} mode=755 owner=root state=directory")
    pb.add_task(task1)
    pb.add_task(task2)
    pb.add_task(task3)
    pb.add_task(task4)
    personblock.set_playbook(pb)
    personblock.run_block()