MacBook安装Ansible

MacBook安装Ansible

Ansible介绍

ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet、chef、func、fabric)的优点,实现了批量系统配置、批量程序部署、批量运行命令等功能。

ansible是基于 paramiko 开发的,并且基于模块化工作,本身没有批量部署的能力。真正具有批量部署的是ansible所运行的模块,ansible只是提供一种框架。ansible不需要在远程主机上安装client/agents,因为它们是基于ssh来和远
程主机通讯的。ansible目前已经已经被红帽官方收购,是自动化运维工具中大家认可度最高的,并且上手容易,学习简单。是每位运维工程师必须掌握的技能之一。

ansible 特点
  • 部署简单,只需在主控端部署Ansible环境,被控端无需做任何操作;
  • 默认使用SSH协议对设备进行管理;
  • 有大量常规运维操作模块,可实现日常绝大部分操作;
  • 配置简单、功能强大、扩展性强;
  • 支持API及自定义模块,可通过Python轻松扩展;
  • 通过Playbooks来定制强大的配置、状态管理;
  • 轻量级,无需在客户端安装agent,更新时,只需在操作机上进行一次更新即可;
  • 提供一个功能强大、操作性强的Web管理界面和REST API接口——AWX平台。

Mac安装

brew install ansible 安装失败 有个包下不下来

brew install enca Mac将文件的编码改UTF-8

enca -v
或
python -V
pip --version

yum install python-pip -y 成功

sudo pip install ansible  成功

或 linux
yum install epel-release -y 成功
yum install ansible -y  成功


默认配置在 /etc/ansible

ansible --version
mkdir software/ansible

ansible -i /Users/liang/software/ansible/hosts iot-test -m ping
ansible -i /Users/liang/software/ansible/hosts all -m ping

cat /Users/liang/software/ansible/hosts
[iot-test]
# 在[]中的,为一组,iot-test为组名,后面会用到
#139.9.130.81 ansible_ssh_port=22 ansible_ssh_user=root ansible_ssh_pass=abcd_2020
114.116.194.17 ansible_ssh_port=22 ansible_ssh_user=root ansible_ssh_pass=abcd_2019
192.168.140.102 ansible_ssh_port=22 ansible_ssh_user=root ansible_ssh_pass=abcd123

cat /Users/liang/software/ansible/ansible.cfg   
[defaults]


先手动连接上去一次
ssh root@139.9.130.81
ssh root@114.116.194.17

在这里插入图片描述
在这里插入图片描述

报错
“msg”: “to use the ‘ssh’ connection type with passwords, you must install the sshpass program”

安装 sshpass

brew install https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb

参考链接:
https://hvops.com/articles/ansible-mac-osx/
https://www.cnblogs.com/The-day-of-the-wind/p/9605938.html
https://www.cnblogs.com/liuhuan086/p/12525027.html
https://blog.csdn.net/weixin_42193400/article/details/82148974
https://www.cnblogs.com/keerya/p/7987886.html#_label0_2
https://www.cnblogs.com/liuhuan086/p/12525027.html

  • 4
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

beyond阿亮

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值