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 -------------------- 重要 ...
随机推荐
- 数列分段`Section II`(二分
https://www.luogu.org/problemnew/show/P1182 洛谷上的题目. 以后如果遇到1e5什么的 用二分试试! #include<iostream> # ...
- vimrc config and NERDTree
nmap <C-N> :tabnext<CR> 下载和配置 NERDTree插件的官方地址如下,可以从这里获取最新的版本 https://github.com/scrooloo ...
- Red Hat Enterprise Linux 7.0
简介 Red Hat Enterprise Linux是Red Hat公司的Linux发行版,面向商业市场,包括大型机.红帽公司从Red Hat Enterprise Linux 5开始对企业版LIN ...
- 基于SSM框架的通用权限框架设计
1. 整体解决方案概述 1.1 权限整体解决方案概述 权限设计主要有一下几大部分组成: PassPort: 针对现在系统的分析,系统之间有部分信息是共享的,这部分信息将由 ...
- selenium报错以及各解决方法
1.driver.findElement(By.name("wd")).sendKeys("selenium"); 报错:The method sendKeys ...
- BZOJ 4013/Luogu P3240 [HNOI2015] 实验比较 (树形DP)
题目传送门 分析 放一个dalao博客: xyz32768 的博客,看完再回来看本蒟蒻的口胡吧(其实嘛-不回来也行) 精髓是合并的方案数的计算,至于为什么是Ci−1j−1\large C_{i-1}^ ...
- spring 使用 context:property-placeholder 加载 多个 properties
一般使用PropertyPlaceholderConfigurer来替换占位符,例如: <bean class="org.springframework.beans.factory.c ...
- KETTLE 更新表的两种方式-更新控件和sql更新 2种方式的实现比较
在实际工作中,我们有可能遇见只更新不插入的情况,可以由以下2种方式去实现: 1.更新控件 如下图所示,根据id字段,更新name和cjsj时间字段 该控件不足的地方是,用来查询关键值得字段不够灵活,一 ...
- 慕课网SSM仿大众点评
目录: 配置部分: 1 配置报错不支持diamond运算符 运行部分: 1 登录的账号密码 2 运行项目是报错session超时 配置部分 1 配置报错不支持diamond运算符 原报错信息如下:id ...
- Appium自动化测试教程-自学网-app基础知识
Instrumentation的缺点是不支持跨应用,比如我想要先调起通讯录,在操作其他的app,则不支持. 第一步,应该确定系统哪些模块适合自动化.哪些不适合做自动化,明确做自动化给我们带来的好处是什 ...