blockinfile
Collection: builtin
Full Name: parallax.builtin.blockinfile
Aliases: ansible.builtin.blockinfile, blockinfile
Synopsis
Manage blockinfile
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| path | string | yes | Path to the file to modify (alias: dest, destfile, name) | |
| block | string | text content to insert/update/remove in the block | ||
| state | string | present | present or absent state for the block, Choices: present and absent | |
| marker | string | # {mark} ANSIBLE MANAGED BLOCK | Template for the block markers | |
| marker_begin | string | BEGIN | Marker text for the beginning of the block | |
| marker_end | string | END | Marker text for the end of the block | |
| insertafter | string | Insert block after this line | ||
| insertbefore | string | Insert block before this line | ||
| create | bool | false | create the destination if it does not exist as a new file | |
| backup | bool | false | Create backup file with timestamp | |
| validate | string | validate the file after changes using a command | ||
| owner | string | Name of the user that should own the file | ||
| group | string | Name of the group that should own the file | ||
| mode | string | The permissions the resulting file should have | ||
| attributes | string | The attributes the resulting file should have | ||
| seuser | string | The user part of the SELinux file context | ||
| serole | string | The role part of the SELinux file context | ||
| setype | string | The type part of the SELinux file context | ||
| selevel | string | The level part of the SELinux file context | ||
| unsafe_writes | bool | false | Allow unsafe file operations | |
| dest | string | alias for path | ||
| destfile | string | alias for path | ||
| name | string | alias for path |
Example
- name: Example blockinfile task
blockinfile:
path: <your_path>