Add Execute Permission 755 on Linux file — Ansible module file
How to automate the setting of execute permission 755 for example.sh Linux file with Ansible module file.
--
How to Add Execute Permission 755 on Linux file with Ansible?
I’m going to show you a live demo and some simple Ansible code.
I’m Luca Berton and welcome to today’s episode of Ansible Pilot.
Ansible Add Execute Permission
- `
ansible.builtin.file
` - Manage files and file properties
Today we’re talking about the Ansible module `file
`.
The full name is ansible.builtin.file, which means that is part of the collection of modules “builtin” with ansible and shipped with it.
It’s a module pretty stable and out for years.
It works in a different variety of operating systems.
It manages files and file properties.
For Windows targets, use the `ansible.windows.win_file
` module instead.
Main Parameters
- path string (dest, name) — file path
- owner string — user
- group string — group
- mode raw — Ex: ‘0644’ or ‘u=rw,g=r,o=r’
- state string — file/absent/directory/hard/link/touch
- setype/seuser/selevel — SELinux
This module has some parameters to perform any tasks.
The only required is “path”, where you specify the filesystem path of the file you’re going to edit.
The parameter “owner” set the user that should own the file/directory.
The parameter “group” set the group that should own the file/directory.
The parameter “mode” set the permissions in the UNIX way of the file/directory.
The state defines the type of object we are modifying, the default is “file” but we could handle also directories, hard links, symlinks, or only update the access…