标签:服务 ansi disco config 元数据 nod gdi soft exe
ansible是基于python开发的自动化运维工具,
它基于SSH远程连接服务,
可以实现批量系统配置、批量软件部署、批量文件拷贝、批量运行命令等多个运维功能
因为基于ssh连接,所以只需要受控端运行openssh服务即可,无需运行其他服务
只需主控端安装ansible即可
说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest
对应的源码可以访问这里获取: https://github.com/liuhongdi/
说明:作者:刘宏缔 邮箱: 371125307@qq.com
[root@centos8 liuhongdi]# dnf info ansible 上次元数据过期检查:0:01:12 前,执行于 2020年04月18日 星期六 14时39分54秒。 可安装的软件包 名称 : ansible 版本 : 2.9.5 发布 : 1.el8 架构 : noarch 大小 : 17 M 源 : ansible-2.9.5-1.el8.src.rpm 仓库 : epel 概况 : SSH-based configuration management, deployment, and task execution system URL : http://ansible.com 协议 : GPLv3+ 描述 : Ansible is a radically simple model-driven configuration management, : multi-node deployment, and remote task execution system. Ansible works : over SSH and does not require any software or daemons to be installed : on remote nodes. Extension modules can be written in any language and : are transferred to managed machines automatically.
如果没有安装epel源,执行以下命令安装epel源:
[root@centos8 liuhongdi]# dnf install epel-release
[root@centos8 liuhongdi]# dnf install ansible
1,查看版本
[root@centos8 liuhongdi]# ansible --version ansible 2.9.5 config file = /etc/ansible/ansible.cfg configured module search path = [‘/root/.ansible/plugins/modules‘, ‘/usr/share/ansible/plugins/modules‘] ansible python module location = /usr/lib/python3.6/site-packages/ansible executable location = /usr/bin/ansible python version = 3.6.8 (default, Nov 21 2019, 19:31:34) [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)]
2,查看帮助
[root@centos8 liuhongdi]# ansible --help
3,查看手册:
[root@centos8 liuhongdi]# man ansible
1,编辑ansible的配置文件
[root@centos8 liuhongdi]# vi /etc/ansible/hosts
内容:
#ansible_ssh_user: 指定用户名
#ansible_ssh_pass: 指定密码
[yujian] 121.122.123.47:12888 ansible_ssh_user=webop ansible_ssh_pass="weboppass"
2,检查是否能连接到服务器
[liuhongdi@centos8 ~]$ ansible -m ping yujian 121.122.123.47 | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/libexec/platform-python" }, "changed": false, "ping": "pong" }
连接成功
1,生成密钥
[liuhongdi@centos8 ~]$ ssh-keygen -t rsa
2,上传密钥到服务器:
[liuhongdi@centos8 ~]$ ssh-copy-id -p 12888 webop@121.122.123.47
3,登录到受控端的服务器检查,是否已把key写入
[webop@blog ~]$ more .ssh/authorized_keys
4,编辑配置文件,不再需要指定密码
[root@centos8 liuhongdi]# vi /etc/ansible/hosts
内容:
[yujian] 121.122.123.47:12888 ansible_ssh_user=webop
5,再次测试是否能连接
[liuhongdi@centos8 ~]$ ansible -m ping yujian 121.122.123.47 | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/libexec/platform-python" }, "changed": false, "ping": "pong" }
成功了
标签:服务 ansi disco config 元数据 nod gdi soft exe
原文地址:https://www.cnblogs.com/architectforest/p/12728555.html