ansible安装、配置ssh、hosts、测试连接
、安装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、测试连接的更多相关文章
- Ansible安装配置及命令使用详解
Ansible和saltstack目前市面上一些其它的项目管理工具有很大的不同,它的设计初衷就是为了更方便.快捷的进行配置管理.它易于安装和使用.语法也非常简单易学.你可以用Ansible将平常复杂的 ...
- Ansible安装配置
Ansible工具的安装与配置 Ansible基于SSH,不需要在远程端安装任何软件,只需要在管理端安装ansible及其组件即可. Ansible使用前提是已配置ssh密钥免登陆. 一.安装组件: ...
- ansible安装配置及最佳实践roles
ansible是什么? ansible是一款轻量级配置管理工具,用于远程批量部署.安装.配置.类似的还有puppet.saltstack,各有所长,任君自选. 官方文档:http://docs.ans ...
- linux服务器间配置ssh免密连接
先说一下,我用的centos7,root用户.ssh的原理就不说了,网上介绍的文章很多,直接开始说操作步骤吧: 1.首先确认有没有安装ssh,输入 rpm -qa |grep ssh查看 这样就表示安 ...
- Ansible安装配置及使用
一.Ansible特点 1.不需要安装客户端,通过sshd通信 2.基于模块工作,模块可以由任何序言开发 3.不仅支持命令行使用模块,也支持编写yaml格式的playbook 4.支持sudo 5.有 ...
- Windows上安装配置SSH教程(6)——综合应用:在Windows上实现SSH远程登陆与文件传输
----------------- 声明:本教程现已经弃用.由于客户端同时安装Cygwin和OpenSSH for Windows会出现问题(Cygwin的shell下无法使用ssh命令),建议直接在 ...
- 配置ssh免密码连接
建立ssh连接步骤: 1,在主机安装ssh-server,执行指令: apt-get install openssh-server 2,在主机上执行指令: netstat -atpn | grep 可 ...
- Ansible安装配置Nginx
一.思路 现在一台机器上编译安装好nginx.打包,然后在用ansible去下发 cd /etc/ansible 进入ansible配置文件目录 mkdir roles/{common,install ...
- Windows上安装配置SSH教程(8)——综合应用:在Windows上使用手动方式实现SSH远程登陆与文件传输
服务器端操作系统:Windows XP 客户端操作系统:Windows10 安装与配置顺序 1.服务端安装OpenSSH 2.服务端配置OpenSSH 3.客户端安装OpenSSH 4.客户端安装Wi ...
- Windows上安装配置SSH教程(4)——WinSCP+OpenSSH 使用公钥自动登陆
-------------------- 知识点汇总:http://www.cnblogs.com/feipeng8848/p/8559803.html -------------------- 重要 ...
随机推荐
- Python 文件操作(2)
上一篇学习了用内置函数 open() 来打开文件,并且用 f.close() 来关闭文件. 今天来学习对这个文件对象的其他操作:读.写.找到文件当前位置-- 1.读取文件 三种方法: read([si ...
- Paper Reading:个性化推荐系统的研究进展
论文:个性化推荐系统的研究进展 发表时间:2009 发表作者:刘建国,周涛,汪秉宏 论文链接:论文链接 本文发表在2009,对经典个性化推荐算法做了基本的介绍,是非常好的一篇中文推荐系统方面的文章. ...
- win服务器 解决apache 80端口被占用问题
是系统的服务占用了80端口,所以要么结束系统服务,要么修改apache端口. PID4的服务是World Wide Web Publishing Service 这里选择结束这个系统服务,运行serv ...
- Java 基础 - Collection集合通用方法及操作/ArrayList和LinkedList的差别优势 /弃用的Vector
Collection的笔记: /**存储对象考虑使用: * 1.数组, ①一旦创建,其长度不可变!② 长度难于应对实际情况 * 2.Java集合, ①Collection集合: 1.set: 元素无序 ...
- 【反向多源点同时BFS一个强连通图+类最短路题面】Fair-986C-Codeforce
借鉴博客:https://www.cnblogs.com/zhangjiuding/p/9112273.html 986-A. Fair /* 986-A-Fair,codeforce: 大致题意: ...
- IP选项处理
1:引言 I P输入函数(i p i n t r)将在验证分组格式(检验和,长度等)之后,确定分组 是否到达目的地之前,对选项进行处理.这表明,分组所遇到的每个路由器以及最终的目的主机都要对分组的选项 ...
- "Class does not support Automation or does not support expected interface"数据库连接错误问题分析与解决
1,故障现象 本人编译的英文版程序在本机上运行OK,换台电脑运行,发现启动时连接数据库出错. 错误信息如下: --------------------------- Error start datab ...
- Java并发包--ThreadPoolExecutor
转载请注明出处:http://www.cnblogs.com/skywang12345/p/3509941.html ThreadPoolExecutor简介 ThreadPoolExecutor是线 ...
- 父元素设置固定宽度并设置overflow:scroll,如何让子元素撑开父元素
<div class="a"> <div class="b"> <div class="c">内容内容, ...
- 分页控件Webdiyer.MvcPager
MVC 1.安装控件 install-package Webdiyer.MvcPager 2.Cotroller using System; using System.Collections.Gene ...