ansible服务的部署与使用

安装

#该软件是用来对selinux进行设置的,确保即使服务器selinux服务开启,依旧能够通过ansible 软件管理
yum install libselinux-python -y
#安装ansible软件
yum install ansible -y
#修改hosts文件
cat >>/etc/ansible/hosts<<EOF
[test]
192.168.2.22 ansible_ssh_user=test ansible_ssh_port='22' ansible_ssh_pass='123' ansible_become_pass='123'
EOF

使用场景

普通用户sudo执行命令

修改ansible.cfg配置文件

[defaults]
inventory=/etc/ansible/hosts
remote_temp=~/.ansible/tml
host_key_checking = False
[privilege_escalation]
become=True
become_method=sudo
become_user=root
become_ask_pass=False

sudo测试

$ ansible test -m shell -a "chmod 744 /etc/sudoer"
posted @ 2019-03-19 16:00  MegaloBox  阅读(293)  评论(0编辑  收藏  举报