、安装ansible

1.1、源码安装

源码安装参照 https://www.cnblogs.com/guxiong/p/7218717.html

[root@kube-node3 ~]# tar xf ansible-1.7..tar.gz -C /usr/local/

[root@kube-node3 ~]# cd /usr/local/ansible-1.7./
[root@kube-node3 ansible-1.7.]# python setup.py install 配置文件: [root@kube-node3 ~]# find / -name ansible.cfg
/usr/local/ansible-1.7./examples/ansible.cfg
/usr/local/ansible-1.7./test/units/ansible.cfg [root@kube-node3 ~]# cd /usr/local/ansible-1.7./examples
[root@kube-node3 examples]# ls
ansible.cfg DOCUMENTATION.yml hosts issues playbooks scripts [root@kube-node3 ~]# mkdir /etc/ansible [root@kube-node3 examples]# cp ansible.cfg hosts /etc/ansible/ 1.2、yum安装(推荐) rpm包安装 https://www.jianshu.com/p/b411608a17bf [root@kube-node3 ~]# yum install -y ansible 查看版本: [root@kube-node3 ~]# ansible --version
ansible 1.7. 1.3、pip安装 python3 -m pip install ansible 、配置ssh登录 服务端:192.168.0.64 客户端:192.168.0.65 一键生成非交互式秘钥对 ssh-keygen -t rsa -f /root/.ssh/id_rsa -P "" 然后把公钥(id_rsa.pub)拷贝到客户端上: ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.0.65 本机也要拷贝: cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys chmod /root/.ssh/authorized_keys      # 必须是600, 否则用ansible连接本机报错 在服务端测试ssh是否可以登录 、配置主机组 如果没有ansible目录创建即可 mkdir -p /etc/ansible/
touch /etc/ansible/hosts
cat > /etc/ansible/hosts << EOF
[k8s]
192.168.0.91
192.168.0.92
192.168.0.93
192.168.0.94
[test1]
192.168.0.91
[test2]
192.168.0.92
[test3]
192.168.0.93
[test4]
192.168.0.94
EOF 、创建、配置ansible配置文件 touch /etc/ansible/ansible.cfg cat > /etc/ansible/ansible.cfg << EOF
[defaults]
inventory = /etc/ansible/hosts
sudo_user=root
remote_port=
host_key_checking=False
remote_user=root
log_path=/var/log/ansible.log
module_name=command
private_key_file=/root/.ssh/id_rsa #关闭报错信息显示
deprecation_warnings=False pipelining = True #不收集系统变量
gather_facts: no #开启时间显示
callback_whitelist = profile_tasks #关闭秘钥检测
host_key_cheking=False
EOF 测试: [root@test2 ~]# time ansible -m ping all
127.0.0.1 | SUCCESS => {
"changed": false,
"ping": "pong"
}
192.168.0.92 | SUCCESS => {
"changed": false,
"ping": "pong"
} real 0m10.623s
user 0m7.961s
sys 0m1.075s 报错解决: "msg": "Aborting, target uses selinux but python bindings (libselinux-python) aren't installed!" 出现这个的原因是因为selinux开着的,关闭即可。安装libselinux-python是不管用的 查看当前selinux的状态命令为
getenforce cat > /etc/selinux/config << EOF
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted EOF 两个都要关。注意先看看有么有这两个文件,如果没有就创建一个,否则后期会出现很多问题 sed -i 's/enforcing/disabled/g' /etc/selinux/config sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux 再次查看当前selinux的状态命令为 getenforce

ansible安装、配置ssh、hosts、测试连接的更多相关文章

  1. Ansible安装配置及命令使用详解

    Ansible和saltstack目前市面上一些其它的项目管理工具有很大的不同,它的设计初衷就是为了更方便.快捷的进行配置管理.它易于安装和使用.语法也非常简单易学.你可以用Ansible将平常复杂的 ...

  2. Ansible安装配置

    Ansible工具的安装与配置 Ansible基于SSH,不需要在远程端安装任何软件,只需要在管理端安装ansible及其组件即可. Ansible使用前提是已配置ssh密钥免登陆. 一.安装组件: ...

  3. ansible安装配置及最佳实践roles

    ansible是什么? ansible是一款轻量级配置管理工具,用于远程批量部署.安装.配置.类似的还有puppet.saltstack,各有所长,任君自选. 官方文档:http://docs.ans ...

  4. linux服务器间配置ssh免密连接

    先说一下,我用的centos7,root用户.ssh的原理就不说了,网上介绍的文章很多,直接开始说操作步骤吧: 1.首先确认有没有安装ssh,输入 rpm -qa |grep ssh查看 这样就表示安 ...

  5. Ansible安装配置及使用

    一.Ansible特点 1.不需要安装客户端,通过sshd通信 2.基于模块工作,模块可以由任何序言开发 3.不仅支持命令行使用模块,也支持编写yaml格式的playbook 4.支持sudo 5.有 ...

  6. Windows上安装配置SSH教程(6)——综合应用:在Windows上实现SSH远程登陆与文件传输

    ----------------- 声明:本教程现已经弃用.由于客户端同时安装Cygwin和OpenSSH for Windows会出现问题(Cygwin的shell下无法使用ssh命令),建议直接在 ...

  7. 配置ssh免密码连接

    建立ssh连接步骤: 1,在主机安装ssh-server,执行指令: apt-get install openssh-server 2,在主机上执行指令: netstat -atpn | grep 可 ...

  8. Ansible安装配置Nginx

    一.思路 现在一台机器上编译安装好nginx.打包,然后在用ansible去下发 cd /etc/ansible 进入ansible配置文件目录 mkdir roles/{common,install ...

  9. Windows上安装配置SSH教程(8)——综合应用:在Windows上使用手动方式实现SSH远程登陆与文件传输

    服务器端操作系统:Windows XP 客户端操作系统:Windows10 安装与配置顺序 1.服务端安装OpenSSH 2.服务端配置OpenSSH 3.客户端安装OpenSSH 4.客户端安装Wi ...

  10. Windows上安装配置SSH教程(4)——WinSCP+OpenSSH 使用公钥自动登陆

    -------------------- 知识点汇总:http://www.cnblogs.com/feipeng8848/p/8559803.html -------------------- 重要 ...

随机推荐

  1. 连接mongodb服务器

    连接mongodb有几种方法 一种是使用mongodb编译时生成的客户端进行连接,就是我们之前介绍过的mongo客户端 另一种是使用各种驱动进行连接 这次使用mongo客户端进行连接,之前我们启动了一 ...

  2. tsp问题-遍历算法/随机算法

    旅行商问题,即TSP问题(Traveling Salesman Problem)又译为旅行推销员问题.货郎担问题,是数学领域中著名问题之一.假设有一个旅行商人要拜访n个城市,他必须选择所要走的路径,路 ...

  3. string::clear

    void clear() noexcept;功能:把string对象置为空 #include <iostream>#include <string> using namespa ...

  4. DeviceSupport 路径

    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSuppor

  5. 基于Mint UI和MUI开发VUE项目一之环境搭建和首页的实现

    一:简介 Mint UI 包含丰富的 CSS 和 JS 组件,能够满足日常的移动端开发需要.通过它,可以快速构建出风格统一的页面,提升开发效率.真正意义上的按需加载组件.可以只加载声明过的组件及其样式 ...

  6. Python和Shell交互工具 ShellPy

    ShellPy 是一款Python和Shell的交互工具.一般来说,我们会通过Subprocess.Popen或者Command模块执行一条Shell命令或脚本,然后通过返回的标准输出和错误输出来得到 ...

  7. 关于b站爬虫的尝试(二)

    前几天学习了scrapy的框架结构和基本的使用方法,部分内容转载自:http://blog.csdn.net/qq_30242609/article/details/52810840 scrapy由编 ...

  8. process 请求数据解析问题

    开发过程中发现ajax提交的数据无法被express正确的解析,主要的情况是这样的: // 浏览器端post一个对象 $.ajax({ url:"/save", type:&quo ...

  9. harbor1.9仓库同步迁移

    harbor 1.9 实战的仓库迁移,过程实际上就是从A push 到B.16个tag 不到100G,挺快的 1分钟多. 假设我们从A迁移到B. 1.先在A上面建立一个目标仓库.    

  10. SIGAI深度学习第五集 自动编码器

    深度学习模型-自动编码器(AE),就是一个神经网络的映射函数,f(x)——>y,把输入的一个原始信号,如图像.声音转换为特征. 大纲: 自动编码器的基本思想 网络结构 损失函数与训练算法 实际使 ...