当前位置: 移动技术网 > IT编程>脚本编程>Python > Ansible安装

Ansible安装

2020年07月16日  | 移动技术网IT编程  | 我要评论

 

Ansible是一种自动化的运维工具,基于Python开发,它集合了众多运维工具(比如puppet、chef、func等)的优点,能够实现批量操作。但其实Ansible是基于模块工作的,本身没有批量部署的能力。真正具有批量部署的是Ansible所运行的模块,Ansible只是提供一种框架

yum install epel-release 
yum repolist 
yum install -y ansible 

#修改如下文件,新增定义Ansible模块

vi /etc/ansible/hosts 
#  接下来定义Ansible模块
#  ansible_ssh_port 连接目标远程主机的端口
#  ansible_ssh_user 连接目标远程主机默认用户
#  ansible_ssh_pass 连接目标远程主机默认用户密码

[bdp:children]
master
slaves

[bdp:vars]
ansible_ssh_port=22
#ansible_ssh_user=root
#ansible_ssh_pass='gis@bdp'
ansible_ssh_user=hadoop
ansible_ssh_pass='gis@hadoop'

[master:children]
m_master
s_master

[m_master]
192.168.254.121

[s_master]
192.168.254.122

[slaves:children]
dn
web

[dn]
192.168.254.123
192.168.254.124
192.168.254.125

[web]
192.168.254.126
# 修改该文件中 host_key_checking = False  (避免SSH_KEY问题)
vi /etc/ansible/ansible.cfg

host_key_checking = False 
# 基于passlib生成密码 假设加密后的值为 xxx
python -c 'import crypt; print (crypt.crypt("password","hadoop"))'  

# 添加组
ansible bdp -m group -a 'name=hadoop gid=666 state=present system=yes'

# 添加用户到指定组
ansible bdp -m user -a 'name=hadoop password=haN6/RvMI9uPo update_password=always  shell=/bin/bash group=hadoop state=present system=yes createhome=yes home=/home/hadoop' 

# 删除用户
ansible bdp -m user -a "name=hadoop state=absent"

 

本文地址:https://blog.csdn.net/Sampson_Hugo/article/details/107325457

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网