ansible
  • 安装
  • 第一个ansible例子
  • playbook
  • role
  • ansible模块
    • copy模块
    • file模块
    • yum模块
    • selinux模块
    • service_facts
  • notify与handler
  • register
  • 实战
    • 安装k8s集群
  • FAQ
Powered by GitBook
On this page

Was this helpful?

  1. ansible模块

file模块

用于对文件进行操作

group:默认为空
owner:默认为空
path:默认为空,别名:'dest', `name'
recurse:yes, no 默认为no
src:创建连接文件时有用
state:file, link, directory, hard, touch, absent
file 默认属性,如果文件不存在则不创建,并且报错,用于修改已存在文件的属性
directory 如果目录不存在,则创建目录和子目录
absent 递归删除文件或目录
link 在创建软链接是有用
hard 创建硬链接

示例

- name: file module
  hosts: group1
  tasks:
  - name: delete a file
    file:
      path: /etc/yum.repos.d/peng.test
      state: absent
Previouscopy模块Nextyum模块

Last updated 4 years ago

Was this helpful?