首页 > 其他分享 >ansible模块 playbook

ansible模块 playbook

时间:2024-04-14 21:33:36浏览次数:17  
标签:shell selinux yaml ansible playbook 模块

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

常看所有模块: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"

 

标签:shell,selinux,yaml,ansible,playbook,模块
From: https://www.cnblogs.com/xiangyu5945/p/18134739

相关文章

  • day13- 模块和包
    这节我们学习模块和包,这块呢,我们在实际使用的过程中,首先保证自己会用就可以,其次也可以加深对Python代码的理解。1、什么是模块开始之前,那我们思考下,之前学的过变量,函数属于一个模块吗?模块呢,就是Python程序,简单来说,就是一个.py的文件,就是属于一个模块那说明我们之前的函数和变......
  • ansible 入门测试
    所有步骤均在ansibleserver主机上执行。安装ansiblewget-O/etc/yum.repos.d/epel.repohttp://mirrors.aliyun.com/repo/epel-7.repoyuminstallansible-ycansible到workder节点免密登录生成公钥ssh-keygen-trsa公钥拷贝到woker节点 *2 ssh-copy-i......
  • ansible基础--摘抄 超哥
    抄自:https://www.cnblogs.com/sxy-blog/p/17543464.html只为自己记录查看运维自动化Ansible 1、ansible介绍运维神器ansible 一句话,学好ansible,学精ansible,就直接是普通运维、和自动化运维的一个质的飞跃。ansible提供了大量的模块、帮助运维完成服务器批量化部署操作......
  • ansible常用模块 --摘抄 chaoge
    摘自:https://www.cnblogs.com/sxy-blog/p/17543471.htmlansible核心内容(模块学习)ansible执行命令结果(状态颜色)绿色:命令以用户期望的执行了,但是状态没有发生改变;黄色:命令以用户期望的执行了,并且状态发生了改变;紫色:警告信息,说明ansible提示你有更合适的用法;红色:命令错误,执......
  • 配置ansible server
    centos7-asible:20.20.43.0 安装nginxyum install -ynginx配置upstreamdemo-dev{server20.20.45.177:5000;server20.20.41.213:5000;}server{server_namedev.nops.icu;listen80;access_log/var/log/test.nops.icu_access.log;......
  • ansible 修改密码
    hosts[centos-root]192.168.174.129ansible_ssh_port=22192.168.174.130ansible_ssh_port=22192.168.174.131ansible_ssh_port=22AnsibleVault文件创建AnsibleVault文件#ansible-vaultcreatepasswords.ymlNewVaultpassword:#123456......
  • 4-WIFI&蓝牙(ESP32)转CAN或RS485总线&串口TTL模块-CSDK-设备作为TCP客户端,实现上位机
    <p><iframename="ifd"src="https://mnifdv.cn/resource/cnblogs/ESP32_CAN"frameborder="0"scrolling="auto"width="100%"height="1500"></iframe></p> 说明这节设备作为TCP客户端,连接上位......
  • Python常用模块-20个常用模块总结
    目录time模块datetime模块random模块os模块sys模块json和pickle模块hashlib和hmac模块logging模块numpy模块pandas模块matplotlib模块re模块typing模块collections模块pathlib模块shutil模块xml模块subprocess模块configparser模块Python常用模块小结time模块......
  • 3-WIFI&蓝牙(ESP32)转CAN或RS485总线&串口TTL模块-CSDK--设备作为TCP服务器,实现上位
    <p><iframename="ifd"src="https://mnifdv.cn/resource/cnblogs/ESP32_CAN"frameborder="0"scrolling="auto"width="100%"height="1500"></iframe></p> 说明这节设备作为TCP服务器,上位机T......
  • 14.lua模块(多文件)
    导入其他模块用:require("文件路径,注意去掉后缀");小括号本身可以省略,即:require"文件路径,注意去掉后缀名"如:现在有如下文件模块model.lua,代码如下:calArea={}calArea.pi=3.14--计算三角形面积functioncalArea.triangle(w,h) return0.5*w*hend--计算矩形......