Ansible Shell Module Tutorial - Complete Beginner's Guide

preview_player
Показать описание

The Ansible Shell Module allows you to run arbitrary commands on a remote host, just like you were logged into the shell. The Shell and Command modules are very similar, the major difference being that the shell module does not escape commands, allowing you to use shell operators like redirects ("greater than", "less than"), pipe ("|") and boolean operators ("&&", "||"). This does mean that the Shell module is susceptible to command injection/shell injection, but this is easy enough to overcome by using the "quote" filter when using variables with the Shell module.

- 0:00 -- Shell Module vs Command Module
- 3:39 -- Basic Shell Module Usage (+ args, environment and loops)
- 5:15 -- Preventing Shell Injection

SETUP/EDITOR/IDE

Thanks for watching and hope it's entertaining/useful for you! Hit me up in the comments if you have any questions or feedback 💪.

Related & Channel

Our Site & Socials
Рекомендации по теме
Комментарии
Автор

Got yourself a new sub from PH. Thanks for a very concise video

acbuddy
Автор

Thank you sir, very very effective and useful for me.

nagarajunagari
Автор

How did you setup your visual studio for ansible

kundansingh
Автор

Great video! Thumb up. I just wonder if I also can use the shell module to login to a ssh session and hit ENTER with the task as the first thing I need to do is "accept a EULA".

juergenschubert
Автор

Hi Percy, thanks for all of your videos. Clear explanation of all the concepts. It’s very easy so that layman can even do calkwalk. I have a scenario to install python3.7 on windows using ansible I tried using win_package and win_shell but not able to install. Please can I ask you do a video on the same

rizwankhana
Автор

Is it possible to perform ldap client add or remove via ansible playbook in linux?

ambhojshukla
Автор

In which case would shell injection be a practical attack vector? I.e.: in which case does an attacker have access to variables, but not to the playbook, or ssh keys?

thomassmit
Автор

Hi Percy, Can we use the shell module to request a certificate for an application? somehow when I run the following - name: Request new certs
shell: "/opt/OV/bin/ovcert -certreq", the client doesn't get any new cert from the server.

azamamer
Автор

Is there any way to run a shell script for both two hosts from local machine? What exactly we need to do for this? I'm pretty much stuck in this. The only thing I got is to copy the script on the host then running it using the command. Please let me know if there is another way to run the shell script file on the host which is placed on my local machine. Thanks in advance.

theamanjs
Автор

Hi, thanks for the video!


i have a question: is it possible to define a environment like this?:
HOSTNAMEKT: "echo "$(dmidecode -s system-serial-number)" | tr '[:upper:]' '[:lower:]'"
i want to change the hostname of a new machine to his serial number.

DCkn
Автор

Hi Sir,
May i know where u r mentioning the hosts names.Because i see u are not passing any parameters in the command.

venkatesh
Автор

Hi Percy,
Nice tutorial. I want to delete files inside directory. Directory contains authchild1.2.4, authchild1.3.7 and I have one another directory which contains file authchild1. 6.9 I want to copy this file into previous folder which contains 2 files (authchild1.2.4 and authchild1. 3.7) but after copy I want to delete same file which contains text authchild*.

manish
Автор

Do have to do some more steps executing powershel script? I have add in playbook  
tasks:
    - name: powercli script
      script: 1.ps1

but is not working DO I have to do sth. ANd when You help me start this is it possible to save otput from script?

jonpok
Автор

I need a simple playbook that would run this command: "netstat -tulpn | grep LISTEN" and provide the output in a file in /tmp/.

samuelbimbo
Автор

What platform and editor are you using for your demos?

gesnow