首页 > 其他 > 详细

ansible(基础)

时间:2019-05-01 15:33:02      阅读:134      评论:0      收藏:0      [点我收藏+]

Ansible自动化配置管理

 

1.ansible安装:
ip: 192.168.215.128 (虚拟机)
ip: 47.103.34.26 (aliyun)

 

2.获取elep源:
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aiyun.com/repo/epel-7.repo

yum install ansible

 

3. ansible配置文件查找顺序:
$ANSIBLE_CONFIG
ansible.cfg #当目录下
.ansible.cfg #家目录下
/etc/ansible/ansible.cfg #etc下的配置文件


4. 基于密钥的链接:
ssh-keygen #创建密钥
ssh-copy-id -i ~/.ssh/id_rsa.pub root@47.103.34.26 #将公钥发送给主机

 

5. 简单的测试下:
ssh root@47.103.34.26 #测试是否可以无密码登录

 

6. Ad-Hoc 的常用模块:

command    #执行shell命令(不支持管道等特殊字符)
shell    #执行shell命令
script    #执行shell脚本
yum仓库    #yum_repository
安装    #yum
配置    #copy
启动    #service , systemd
联网下载    #get_url
创建用户与组    #user,group
授权    #file
定时任务    #crond
挂载    #mount    
firewalld , selinux    #firewall selinx

 

 

7. ansible 如何查看帮助文档:
[root@centos7 ~]# ansible-doc -l #查看所有文档
[root@centos7 ~]# ansible-doc yum #查看某个模块的用法

8. command命令模块不支持重定向或管道
#默认模块, 执行命令
[root@centos7 ~]# ansible webservers -a "touch /root/file"

9. 如果需要一些管道操作,则使用shell
[root@centos7 ~]# ansible webservers -m shell -a "ls /root/file"

 

ansible(基础)

原文:https://www.cnblogs.com/gukai/p/10799830.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!