def help(c): c = conn(c, True) system.help(c, ''' only support install now''') # install(hosts.conn(0))
def use_help(c): """ fab -H 192.168.0.81 source.use_help """ c = conn(c, True) system.help( c, ''' yum --disablerepo="*" --enablerepo="{name}" list available yum --disablerepo="*" --enablerepo="{name}" install -y python36u '''.format(name=local.http_repo))
def help(c): c = conn(c, True) system.help( c, ''' monitor node: {base}/{node} monitor client: {base}/{client} monitor rules; {base}/*_rules.yaml\n'''.format( base=local.base, node=local.node_config, client=local.client_config), 'config')
def help(c): c = conn(c, True) system.help( c, ''' fab install && fab cluster fab stat fab clear && fab cluster fab clean ''')
def help(c): c = conn(c, True) system.help(c,''' fab install fab start fab topic -t create -o test1 -r 1 -p 1 fab topic -o test1 fab produce -t test1 -c 5 fab consume -t test1 -g local fab group -d -g local''')
def use_proxy(c, url, add=True): """ fab -H 192.168.0.82 source.use_proxy --url 192.168.0.81 yum makecache 有时要多执行几次 """ c = conn(c) sed.path('/etc/yum.conf') sed.grep(**{'sep': '='}) sed.append(c, 'proxy=http://{url}:3142'.format(url=url)) system.help( c, ''' yum install -y epel-release yum install -y apt-cacher-ng''', 'test') system.help(c, ''' yum makecache ''')
def help(c): c = conn(c, True) system.help( c, ''' http://192.168.0.81:9090 fab install-server fab start-server node: http://192.168.0.81:9100 fab install-node fab start-node ''', 'server') # install_server(conn(0)) # install_node(conn(0)) # start_server(conn(0)) # stop(conn(0)) # clean(conn(0)) # start_node(conn(0))
def use_repo(c, file, name, path, test): print(path) print('-------------') c.run('''cat << EOF > /etc/yum.repos.d/{file} [{name}] name=local {name} repo baseurl={type}://{path} gpgcheck=0 enabled=1 priority=1 proxy=_none_ EOF'''.format(file=file, name=name, type='file' if path.startswith('/') else 'http', path=path)) if test: test = '''yum --disablerepo="*" --enablerepo="{name}" list available'''.format( name=name) c.run(test) system.help(c, ''' {test}\n'''.format(test=test), 'test')
def help(c): c = conn(c, True) system.help( c, ''' psql -U postgres psql -U postgres -h 192.168.0.81 -p5432 [密码:111111]''')
def proxy(c, path=local.proxy_path): """ fab -H 192.168.0.81 source.proxy --path /home/proxy yum remove -y apt-cacher-ng systemctl restart apt-cacher-ng.service tail -f /var/log/apt-cacher-ng/* https://www.pitt-pladdy.com/blog/_20150720-132951_0100_Home_Lab_Project_apt-cacher-ng_with_CentOS/ https://fabianlee.org/2018/02/11/ubuntu-a-centralized-apt-package-cache-using-apt-cacher-ng/ docker: https://hub.docker.com/r/minimum2scp/apt-cacher-ng """ c = conn(c) c.run('rm {conf} -rf'.format(conf=local.proxy_conf)) """ 这里需要分开安装:先安装 epel-release 之后,才能安装 其他server """ system.install(c, 'source') system.install(c, 'apt-cacher-ng') from common.disk import file_exist if not file_exist(c, local.proxy_conf): print("conf file {} not exist".format(local.proxy_conf)) exit(-1) c.run('mkdir -p {path}; chmod 777 {path}'.format(path=path)) c.run('''curl https://www.centos.org/download/full-mirrorlist.csv \ | sed 's/^.*"http:/http:/' | sed 's/".*$//' | grep ^http > /etc/apt-cacher-ng/centos_mirrors''' ) """ 修改配置 """ sed.path(local.proxy_conf) sed.grep(**{'sep': ': '}) sed.append( c, '''VfilePatternEx: ^(/\\\\?release=[0-9]+&arch=.*|.*/RPM-GPG-KEY-examplevendor)$''', '# WfilePatternEx:') # sed.append(c, '''VfilePatternEx: ^/\\\\?release=[0-9]+&arch=''', '# WfilePatternEx:') sed.append(c, 'Remap-centos: file:centos_mirrors \/centos', 'Remap-debrep', pos=-1) sed.append( c, 'PassThroughPattern: (mirrors\\\\.fedoraproject\\\\.org|some\\\\.other\\\\.repo|yet\\\\.another\\\\.repo):443', '# PassThroughPattern: private-ppa', pos=5) sed.update(c, 'CacheDir', path) """ 启动服务 """ if globing.invoke: c.run('''cat << EOF > /start.sh #!/bin/bash echo "start proxy" touch /var/log/apt-cacher-ng/a.log #/etc/init.d/apt-cacher-ng start /usr/sbin/apt-cacher-ng -c /etc/apt-cacher-ng pidfile=/var/run/apt-cacher-ng/pid SocketPath=/var/run/apt-cacher-ng/socket foreground=0 tail -f /var/log/apt-cacher-ng/* EOF''') else: c.run('systemctl restart apt-cacher-ng.service') system.help( c, ''' http://{host}:3142 http://{host}:3142/acng-report.html tail -f /var/log/apt-cacher-ng/*'''.format(host=c.host), 'you can visit') # proxy(hosts.conn(0))
def help(c): c = conn(c, True) system.help(c, ''' http://192.168.0.81:8081''')
def help(c): c = conn(c, True) system.help(c,''' mysql -u root -p111111 mysql -u long -p111111 -h 192.168.0.85 -P3306''')