ansible

Kubernetes之五----ansible部署K8S

核能气质少年 提交于 2020-01-20 00:27:31
一、基础集群环境搭建 架构图: 服务器清单 1、安装最小化Ubuntu系统 1、修改内核参数,修改网卡名称,将ens33改为eth0 root@ubuntu:vim /etc/default/grub GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0" root@ubuntu:update-grub 2、修改系统的IP地址 root@node4:~# vim /etc/netplan/50-cloud-init.yaml network: version: 2 renderer: networkd ethernets: eth0: dhcp4: no addresses: [192.168.7.110/24] gateway4: 192.168.7.2 nameservers: addresses: [192.168.7.2] 3、应用ip配置并重启测试: root@node4:~# netplan apply 4、修改apt源仓库 /etc/apt/sources.list :1804版本的Ubuntu,参考阿里云仓库:https://developer.aliyun.com/mirror/ubuntu?spm=a2c6h.13651102.0.0.53322f701347Pq deb http://mirrors.aliyun

Python多环境扩展管理-Virtualenv

自作多情 提交于 2020-01-19 16:10:32
Python多环境管理工具,这两款可能都不错: Pyenv 和 Virtualenv 。 Pyenv ,是对Python的版本进行管理,实现版本的切换。 Virtualenv ,是通过创建虚拟环境,实现Python环境间的隔离,避免相互干扰。 Virtualenv 部署 首先得先准备好Python和pip。Windows系统去官网下载安装后就都有了。 CentOS7安装python3可以看这篇: https://blog.51cto.com/steed/2288045 用pip安装Virtualenv pip install virtualenv 安装过程: $ pip install virtualenv Collecting virtualenv Downloading https://files.pythonhosted.org/packages/b6/30/96a02b2287098b23b875bc8c2f58071c35d2efe84f747b64d523721dc2b5/virtualenv-16.0.0-py2.py3-none-any.whl (1.9MB) 100% |████████████████████████████████| 1.9MB 59kB/s Installing collected packages: virtualenv

(3)ansible文件介绍

情到浓时终转凉″ 提交于 2020-01-19 16:08:16
ansible安装建议使用rpm安装,简单便捷容易上手,作为初学者来说是再好不过的安装方法了,安装了ansible,让我们来了解下他的目录结构,以及配置文件结构。 一、 ansible目录结构介绍 shell> rpm -ql ansible | more 目录主要是以下几项 /etc/ansible #配置文件目录,主要功能为inventory主机信息配置、ansible工具功能配置; /etc/ansible/ansible.cfg /etc/ansible/hosts /etc/ansible/roles /usr/bin/ansible #执行文件目录,ansible命令默认存放目录 /usr/bin/ansible-2 /usr/bin/ansible-2.7 /usr/bin/ansible-config /usr/lib/python2.7/site-packages/ansible #lib库依赖目录和python存放在一起 /usr/lib/python2.7/site-packages/ansible-2.7.10-py2.7.egg-info /usr/lib/python2.7/site-packages/ansible-2.7.10-py2.7.egg-info/PKG-INFO /usr/share/doc/ansible-2.7.10 #帮助文档目录

Best way to launch aws ec2 instances with ansible

倖福魔咒の 提交于 2020-01-19 04:46:37
问题 I'm trying to create an small webapp infrastructure with ansible on Amazon AWS and I want to do all the process: launch instance, configure services, etc. but I can't find a proper tool or module to deal with that from ansible. Mainly EC2 Launch. Thanks a lot. 回答1: This is the short answer of your question, if you want detail and fully automated role, please let me know. Thanks Prerequisite : Ansible Python boto library Set up the AWS access and secret keys in the environment settings (best

Linux下python2.x升级python3.7

こ雲淡風輕ζ 提交于 2020-01-19 03:51:12
一、 查看当前python版本 [root@ansible ~]# python -V Python 2.7.5 二、 下载新的python包并安装 进入python官网(https://www.python.org),选择需要的版本。此处我选择当前最新版本Python3.6.1 [root@ansible soft]#yum install gcc gcc-c++ -y [root@ansible soft]# wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz [root@ansible soft]# tar xvf Python-3.7.3.tar.xz [root@ansible soft]# cd Python-3.7.3/ [root@ansible Python-3.7.3]# ./configure [root@ansible Python-3.7.3]# make [root@ansible Python-3.7.3]#make install 三、 验证 #python -V #一个是旧版本,一个是新版本 Python 2.7.5 # python3 -V Python 3.7.3 四、 设置3.X为默认版本 查看 Python 的路径,在 /usr/bin 下面。可以看到

关于 yum

本小妞迷上赌 提交于 2020-01-18 14:59:48
CentOS-Base.repo 文件详解 vim /etc/yum.repos.d/CentOS-Base.repo [base] name=CentOS-$releasever - Base - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/ #baseurl是服务器设置中最重要的部分,只有设置正确,才能从上面获取软件。 mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os #上面的这一行是指定一个镜像服务器的地址列表,通常是开启的,本例中加了注释符号禁用了 gpgcheck=1 #gpgchkeck= 有1和0两个选择,分别代表是否是否进行gpg校验,如果没有这一项,默认是检查的。 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 关于yum 的报错 安装ansible yum -y install ansible 可能出现报错: GPG key retrieval failed: [Errno 14] Could not

ansible 批量修改密码

五迷三道 提交于 2020-01-18 14:53:27
ansible-playbook 批量修改密码 创建playbook脚本 vim change_passwd.yml --- - hosts: a 备注:ip组 配置在hosts文件中 sudo: yes remote_user: root 备注:远程的用户 gather_facts: false tasks: - name: change user passwd user: name={{ item.user }} password={{ item.password | password_hash('sha512') }} update_password=always with_items: - { user: 'version', password: '******' } 备注:修改远程服务器所有的用户和所修改成的密码****** - { user: 'root', password: '******' } 备注:多个用户继续加 执行命令:ansible-playbook change_passwd.ym 来源: 51CTO 作者: 时光在飞 链接: https://blog.51cto.com/zhanjun/2467668

Ansible之优化提升执行效率

左心房为你撑大大i 提交于 2020-01-17 23:49:01
今天分享一下Ansible在工作环境中有那些可以优化的配置 环境介绍:以前在公司工作处理服务器问题,需要用批量操作都是用shell脚本编写的工具,后来发现Ansible这个自动化工具,安装简单,操作起来很方便,支持多个模块,由python开发基于SSH协议通信的工具。这里有个问题就是如果服务器越来越多,Ansibe执行效率会变得比较慢,可以通过优化Ansible提供工作效率,具体优化的方法如下: 线上管理机器:操作系统Linux,cpu为4核,内存8G,用这个机器管理上千台Linux服务器都没有太大压力 1.修改ansible的并发数 Ansible默认只会创建5个进程并发执行任务,所以一次任务只能同时控制5台机器执行。如果有大量的机器需要控制,例如20台,Ansible执行一个任务时会先在其中5台上执行,执行成功后再执行下一批5台,直到全部机器执行完毕。使用-f选项可以指定进程数,指定的进程数量多一些,不仅会实现全并发,对异步的轮训poll也会有正面影响。 #forks = 60 2.关闭ansible的SSH密钥检测 ansible默认是以ssh来实现远程推送执行的,是基于ssh秘钥检测,会检测远程主机的公钥,并记录在本地中known_host文件中,下次访问主机时,会核对公钥,如果公钥不同,openssh会发出警告,如果相同,会提示输入密码 SSH对主机的public

How communicate two remote machine through ansible

被刻印的时光 ゝ 提交于 2020-01-17 12:41:32
问题 I am running ansible playbook from system 1 which runs tasks on system 2 to take backup and after that, I want to copy backup file from system 2 to system 3. I am doing this task for automating below command where /bck1/test on system 2 and opt/backup on system 3 rsync -r -v -e ssh /bck1/test.* root@host3:/opt/backup 回答1: You can run the raw rsync command with the shell module. tasks: - shell: rsync -r -v -e ssh /bck1/test.* root@host3:/opt/backup For this to work, you will either need to

Ansible: Create instances in different subnets

空扰寡人 提交于 2020-01-17 05:30:30
问题 I'm trying to use Ansible to create two instances, one each in two subnets using the play below. I'm using exact_count with tag Name to keep track of instances. There are two issues here: Ansible ends up creating two instances in the first subnet and reports [ok] for the second subnet. Ansible doesn't seem to care about stopped instances. It creates new instances, instead of starting existing ones, or atleast considering them as part of the group of instances. - name: Create kafka instances