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 -------------------- 重要 ...
随机推荐
- Http协议与TCP协议
背景 在日常工作中,经常会遇到某某框架是基于Http协议或者TCP协议,今天,就针对于该协议,整理下 从本质上来说,Http协议与TCP协议是应用在不同网络层,Http协议处于应用层,TCP处于传输层 ...
- windows下mysql5.6.x的日志正确配置方法(my.ini) (网上的都是5.6之前的版本)
https://blog.csdn.net/databatman/article/details/49951853 感谢楼主,找了好久,试了一下楼主的,果然是对的,网上的日志配置都是5.6之前的版本: ...
- 一步步来用C语言来写python扩展
本文介绍如何用 C 语言来扩展 python.所举的例子是,为 python 添加一个设置字符串到 windows 的剪切板(Clipboard)的功能.我在写... 本文介绍如何用 C 语言来扩展 ...
- 可嵌入的脚本引擎 Jx9
Jx9是一个可嵌入的脚本引擎,基于JSON实现了图灵完备(Turing complete)的编程语言. Jx9 是那些需要流行和高效率脚本支持应用程序(比如:游戏.数据库系统,文本编辑器,网络应用程序 ...
- Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) A. Forgetting Things
链接: https://codeforces.com/contest/1247/problem/A 题意: Kolya is very absent-minded. Today his math te ...
- 12、Spring Boot 2.x 集成 MongoDB
1.12 Spring Boot 2.x 集成 MongoDB 完整源码: Spring-Boot-Demos
- python第三方库的更新和安装指定版本
安装指定版本: pip install openpyxl==2.3.4 更新到最新版本: pip install --upgrade openpyxl
- springmvc集成webService需要的jar包
- vue编辑、新增弹框(引用外部页面)
vue编辑.新增弹框(引用外部页面) 2018年06月15日 09:37:20 会飞的猪biubiu 阅读数 10265 版权声明:本文为博主原创文章,未经博主允许不得转载. https://b ...
- 如何实现对ArrayList排序 sort()
package com.collection; import java.util.ArrayList;import java.util.Collections;import java.util.Com ...