ping模块:

ansible webservers -m service -a “name=httpd state=started enabled=yes”
启动 开机自启
查看是否能够通讯
cron script

yum模块

(latest安装最新版present 默认安装installed安装absent卸载remove卸载):

ansible webservers -m yum -a “name=httpd state=installed”
工具 指定的ip 选项 模块 选项 名字 状态(安装还是卸载‘’absent‘’)

ansible webservers -m yum -a “name=httpd start=started”
工具 指定的组(里面的指定的IP)指定模块 yum模块 选项

iptables模块:

ansible webservers -m service -a “name=iptables state=stopped enable=no ”
永久关闭

Shell模块 (可以支持shell的特殊符号):

ansible webservers -m shell -a “setenforce 0”
当前环境要执行的命令(关闭指定ip防火墙)
ansible模块

Command(默认)模块(不支持shell的特殊符号):

ansible模块

service模块

(started(启动) stopped(停止) restarted(重启) reloaded(重载))
ansible模块
ansible模块

file模块(用来创建文件、目录、链接文件)

ansible模块
path:必选项,定义文件/目录的路径 directory:如果目录不存在,创建目录
ansible模块
touch:如果文件不存在,则会创建一个新的文件,如果文件或目录存在,更新也修改时间
ansible模块
mode:定义文件/目录的权限
ansible模块
修改为600ansible模块
ansible模块
src:要被链接的源文件的路径 dest:被链接到的路径

User模块(用来创建用户)

ansible模块
name:创建的用户名字state: 是创建还是删除。(present,absent),默认是创建
remove:删除用户家目录,默认为no
ansible模块
password:设置密码,密码必须是密文 Openssl passwd
ansible模块
shell: 指定用户登录的shell环境

groud模块(用来创建用户组)

ansible webservers -m groud -a “name=tom state=absent”
state:是创建还是删除。(present,absent)name:指定用户名

Copy模块(用来复制文件至目标主机)

ansible模块
src:文件在管理主机的据对路径或者相对路径 dest:将文件复制到目标主机的路径
ansible模块
backup:是否将目标主机的同名文件备份,默认为no

Unarchive模块(用来解压文件)

ansible模块
ansible模块

get_url模块(用于从http、ftp、https服务器上下载文件//url指定要下载的文的URL地址)

Sshd优化

ansible模块
ansible模块
ansible模块
ansible模块

相关文章:

  • 2021-09-07
  • 2019-10-05
  • 2021-11-05
  • 2021-11-20
  • 2020-04-29
  • 2021-10-09
  • 2020-03-16
  • 2019-11-18
猜你喜欢
  • 2020-05-28
  • 2019-12-18
  • 2019-05-30
  • 2021-12-20
  • 2021-11-12
  • 2021-10-20
  • 2020-03-19
  • 2019-03-21
相关资源
相似解决方案