Managing File permissions on Remote Host - RHCE.pdf

support8872 149 views 13 slides Oct 09, 2024
Slide 1
Slide 1 of 13
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13

About This Presentation

Slides on how to manage file permission on remote host using ansible - Part of RHCE syllabus


Slide Content

Managing File Permissions on
Remote Host

●Manage file and directory properties, such as permissions, ownership on
remote systems

●Attributes
○Mode: sets the permissions of the file
○owner: Sets the owner as root
○group: Sets the group as root
○state: Ensures that the path is a directory/file
○path: Specifies the file whose permissions will be changed

●Link: file – Manage files and file properties — Ansible Documentation


File Module

Create a file/directory on remote host

●Execute the playbook
Command: playbook-ansible <file-name> .yml

●stat: To get the file/file system status

○Attributes
■path: Specifies the file path whose status need to be
gathered
■register: Registers the output of the stat module into a
container

○Link: stat — Ansible Documentation





Stat Module

Debug Module

●debug: To display variables or output custom messages during playbook
execution

○Attributes
■msg: To display the file status

○Link: debug module— Ansible Documentation

Check Directory Status

●Execute the playbook
Command: playbook-ansible <file-name> .yml

●Verify the creation of demo directory of remote host
Command: ls <directory_path> | grep <directory-name>

●Note the permissions of the file on remote host
Command: ls -ltr <directory_path>
Note: (-rw-r--r–) means the owner can read and write the file and it is
readable by the group and others
Older file permissions

Change File permissions
Note : 0777 permission grants read, write, and execute access to the owner,
group, and others.

●Execute the playbook on control node
Command: playbook-ansible <file-name> .yml

●Verify the changed permissions of the file on remote host
Command: ls -ltr <directory_path>
Changed file permissions
Note: After adding permissions now the file has (-rwx-rwx-rwx-) meaning it is
readable, writable and executable by the owner, group, and others