Run Shell Scripts on Remote
Hosts
Shell script
● Text file containing a sequence of shell
commands to automate tasks
● Available shells are stored in /etc/shells
● Types of shells are bourne shell, bash shell
etc.
Run shell script on remote host
● Shell script on remote host to create file using touch command
● Verify the permission of shell file existing on remote host
Command: ls-ltr
● Owner, group and others none of them are having executable
permissions
owner
group others
● Assign executable permission to the shell file and verify the permissions
Command: chmod a+x <file-name>.sh
Executable permissions are given to the user, group and other users
● Playbook for running the shell script on remote host
● Module used:
○ shell -Used to executes shell commands or scripts on remote
host
Shell module
Path of shell file
● Execute the playbook on control node
Command: ansible-playbook <file-name>.yml
● Verify file creation on remote host by using ls command in root dir. Of
remote host
○ Command : ls

Run Shell Scripts on Remote Hosts - RHCE.pdf

  • 1.
    Run Shell Scriptson Remote Hosts
  • 2.
    Shell script ● Textfile containing a sequence of shell commands to automate tasks ● Available shells are stored in /etc/shells ● Types of shells are bourne shell, bash shell etc.
  • 3.
    Run shell scripton remote host ● Shell script on remote host to create file using touch command
  • 4.
    ● Verify thepermission of shell file existing on remote host Command: ls-ltr ● Owner, group and others none of them are having executable permissions owner group others
  • 5.
    ● Assign executablepermission to the shell file and verify the permissions Command: chmod a+x <file-name>.sh Executable permissions are given to the user, group and other users
  • 6.
    ● Playbook forrunning the shell script on remote host ● Module used: ○ shell -Used to executes shell commands or scripts on remote host Shell module Path of shell file
  • 7.
    ● Execute theplaybook on control node Command: ansible-playbook <file-name>.yml
  • 8.
    ● Verify filecreation on remote host by using ls command in root dir. Of remote host ○ Command : ls