御风而翔  
个人云笔记

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

常看所有模块: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 2024-04-14 21:31  个人记录  阅读(5)  评论(0编辑  收藏  举报