御风而翔  
个人云笔记

推荐原生模块:大部分幂等性,能重复执行。

常看所有模块:3k个

https://docs.ansible.com/ansible/2.9/modules/list_of_all_modules.html    找关键字

常见重要模块: service  selinux  hosname file copy cron yum script shell 

使用方式:

1、命令行   : ansible  all  -m shell  -a  "date"

2、编辑yaml文件,通过执行ansible-playbook

- name:get date
  shell: date

 

例子:

编辑文件:/etc/ansible/roles/close_selinux.yaml

---
- hosts: '{{ target }}'
  gather_facts: no
  remote_user: root
  tasks:
  - name: Disable SELinux
    selinux:
     state: disabled

执行命令

ansible-playbook close_selinux.yaml  -e target=client01

或者命令行

ansible client02  -m  selinux -a "state=disabled"

 

posted on   个人记录  阅读(8)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
 
点击右上角即可分享
微信分享提示