欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 科技 > 能源 > ansible常用的模块

ansible常用的模块

2025/2/23 21:39:14 来源:https://blog.csdn.net/qq_38978734/article/details/142765427  浏览:    关键词:ansible常用的模块
  1. shell: 执行相关命令,支持管道:
- name: Execute the command in remote shell; stdout goes to the specified file on the remoteansible.builtin.shell: somescript.sh >> somelog.txt
  1. command同shell,但是不支持管道
- name: Run command if /path/to/database does not exist (without 'args')ansible.builtin.command: /usr/bin/make_database.sh db_user db_name creates=/path/to/database
  1. unarchive: 将本地的压缩包,复制到远程机器上,然后解压
- name: Extract foo.tgz into /var/lib/fooansible.builtin.unarchive:src: foo.tgzdest: /var/lib/foo
  1. copy: 将本地的压缩包,复制到远程机器上
- name: Copy file with owner and permissionsansible.builtin.copy:src: /srv/myfiles/foo.confdest: /etc/foo.confowner: foogroup: foomode: '0644'
  1. fetch: 将远程的包拉取到本地
- name: Store file into /tmp/fetched/host.example.com/tmp/somefileansible.builtin.fetch:src: /tmp/somefiledest: /tmp/fetched
  1. template: 将jinjia2格式的模板,渲染到远程机器上
- name: Template a file to /etc/file.confansible.builtin.template:src: /mytemplates/foo.j2dest: /etc/file.confowner: bingroup: wheelmode: '0644'
  1. file: 创建和删除文件或目录
- name: Change file ownership, group and permissionsansible.builtin.file:path: /etc/foo.confowner: foogroup: foomode: '0644'
  1. fail:失败模块,遇到立即停止运行ansible
- name: Example using fail and when togetheransible.builtin.fail:msg: The system may not be provisioned according to the CMDB status.when: cmdb_status != "to-be-staged"
  1. wait_for: 等待端口存活
- name: Wait for port 8000 to become open on the host, don't start checking for 10 secondsansible.builtin.wait_for:port: 8000delay: 10
  1. selinux: 启动或者关闭selinux
- name: Enable SELinuxselinux:policy: targetedstate: enforcing
  1. blockinfile:渲染指定内容到某个文件内
- name: Insert/Update "Match User" configuration block in /etc/ssh/sshd_config prepending and appending a new lineansible.builtin.blockinfile:path: /etc/ssh/sshd_configappend_newline: trueprepend_newline: trueblock: |Match User ansible-agentPasswordAuthentication no
  1. yum: rpm包管理模块
- name: Install the latest version of Apacheansible.builtin.yum:name: httpdstate: latest
  1. user: 创建删除用户
- name: Add the user 'johnd' with a specific uid and a primary group of 'admin'ansible.builtin.user:name: johndcomment: John Doeuid: 1040group: admin

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词