Ansible Command Module Tutorial - Complete Beginner's Guide

  Рет қаралды 13,307

Percy Grunwald from TopTechSkills

Percy Grunwald from TopTechSkills

Күн бұрын

Пікірлер: 53
@toptechskills
@toptechskills 8 ай бұрын
G'day everyone, if you're currently learning Ansible and want to see how all these modules fit together to build something useful, please consider checking out my course and letting me know what you think! It's currently in "early access" while I finish off the last chapter, and the first part of the course is free so you can try it out: learn.toptechskills.com/courses/productive-with-ansible. Thanks for all your support and happy coding!
@bhupendrasinghsuri496
@bhupendrasinghsuri496 4 ай бұрын
Thanks for sharing. Like to see more content on Ansible...
@karthickbaskar6886
@karthickbaskar6886 5 жыл бұрын
Astonished with your clarity of teaching. Thanks to you.
@SaravanaKumar-tz7ge
@SaravanaKumar-tz7ge 4 жыл бұрын
As a beginner, it is Really Useful for me sir !!!. Thank you:)
@toptechskills
@toptechskills 4 жыл бұрын
Thank you for your comment, so glad it was useful for you 🙏
@shrashthiagarwal7108
@shrashthiagarwal7108 5 жыл бұрын
Great Content !! Kindly prepare and share complete series to learn Ansible. This will really help !!
@toptechskills
@toptechskills 5 жыл бұрын
Thanks Shrashthi Agarwal, I am working on a Udemy course about Ansible in my spare time and I hope to release it as soon as I can. Thanks for your support.
@chinnapaladugu7245
@chinnapaladugu7245 5 жыл бұрын
It's really awesome 😊..I m expecting more videos on different useful modules and ansible roles ..keep going awesome 👍👌
@toptechskills
@toptechskills 5 жыл бұрын
I'll do my best to make more useful content ASAP, thank you for your comment
@purnimashanti26
@purnimashanti26 4 жыл бұрын
Very good explanation.. Pls upload more videos on ansible modules and roles.. Thank you.
@toptechskills
@toptechskills 4 жыл бұрын
Thank you, will do!
@rahul_raj7
@rahul_raj7 4 жыл бұрын
I like your videos and the way you explain is great..👍👍 Do more hands-on example Thanks
@sameerthorappa3356
@sameerthorappa3356 5 жыл бұрын
very good video excellent quality crystal clear voice .. moreover great content...
@toptechskills
@toptechskills 5 жыл бұрын
Thank you for your comment Sameer, hope the video helped you out!
@raphaelaraujo4790
@raphaelaraujo4790 4 жыл бұрын
Thanks for the video! Is possible to run command module and issue database statements like INSERT INTO?
@toptechskills
@toptechskills 4 жыл бұрын
Hi Raphael, yes that should certainly be possible. The `command` and `shell` modules can do pretty much anything you can do if you were using the shell directly. Running `mysql` commands directly from the command line is certainly possible: stackoverflow.com/questions/39215064/insert-into-mysql-from-bash-script.
@metalmasterlp
@metalmasterlp 6 жыл бұрын
Your videos are awesome, keep it up
@toptechskills
@toptechskills 6 жыл бұрын
Hi metalmasterlp, thanks for the huge compliment, glad you enjoyed it. I'll do my best to keep useful tutorials coming out regularly.
@chikkusingh460
@chikkusingh460 4 жыл бұрын
How can we achieve round robin strategy while deploying an app with ansible on multiple servers ?
@toptechskills
@toptechskills 4 жыл бұрын
Hi Chikku, I answered this question on other comment, hopefully it works for you, thanks.
@sujithreddy5032
@sujithreddy5032 4 жыл бұрын
can you please tell how to make command module idempotent
@toptechskills
@toptechskills 4 жыл бұрын
Hi sujith reddy, the `command` module doesn't really have any idempotence checks built in, but you can use things like the `creates` argument to the `command` module (docs.ansible.com/ansible/latest/modules/command_module.html). This argument lets you run the command only when the file *doesn't* exist. This gives you some level of idempotence, but it only covers a small section of use cases. Generally if you want your command to be idempotent, you need to do it within the command itself (i.e. use conditionals in your command to only make changes in certain circumstances). You can then use the `changed_when` argument to make sure the task only reports a change in circumstances where something actually changed. Another thing I do often is to use the `when` parameter to only run the command in certain cases. Hope this helps, thanks for your comment.
@willreid7835
@willreid7835 2 жыл бұрын
when I try to run command module the tasks are skipped. Any idea what I am missing?
@toptechskills
@toptechskills 2 жыл бұрын
Can you show the full task YAML?
@ahsan-li7sh
@ahsan-li7sh 6 жыл бұрын
Could you please make a video how to deploy apache spark on docker containers using ansible. I haven't find any good resource
@toptechskills
@toptechskills 6 жыл бұрын
Hi Ahsan, great suggestion, thank you. I need to spend some time upskilling with regard to containerized applications over the next few weeks (Docker, Kubernetes, ECS, etc.), especially how it relates to Ansible. Hopefully I can start making some videos about these aspects soon.
@lionaldo8159
@lionaldo8159 4 жыл бұрын
How can we use diff command and store the changes in file?
@toptechskills
@toptechskills 4 жыл бұрын
Hi LioNaldo, you can use the `shell` module and pipe (or tee) the results of the diff command into a file, just like you would in the shell. The other way would be to use the `register` argument to store the output from `command` as a variable and then use the `copy` module to write the stdout into a file: - www.toptechskills.com/ansible-tutorials-courses/ansible-command-module-tutorial-examples/#how-to-capture-command-module-output - www.toptechskills.com/ansible-tutorials-courses/ansible-copy-module-tutorial-examples/#how-to-write-plain-text-into-a-file-on-the-remote-host-with-copy Hope that helps, thanks for your comment!
@ChazRagg
@ChazRagg 5 жыл бұрын
i am looking to autpmatically install docker on a series of raspberry pi's, i use the "curl -sSl get.docker.com | sh" would this be the best modual to use or is there a more efficient way of doing this ?
@toptechskills
@toptechskills 5 жыл бұрын
Hi chazragg, I'd suggest using a role from Ansible Galaxy, such as Jeff Geerling's "docker" role: galaxy.ansible.com/geerlingguy/docker In general, these roles are very well tested and well maintained. If your Raspberry Pi is running a non-standard distribution, the role may not work by default, but it will give you a good starting point if you need to modify the role to make it work. Hope this helps, thanks!
@jackcsprat
@jackcsprat 5 жыл бұрын
Hello, nice video !! Can you tell me how to install the command module please ? When I attempt to use the command module with like mkdir, ansible complains that command is not there.
@toptechskills
@toptechskills 5 жыл бұрын
Hi jackcsprat, the command module is an Ansible core module, so if you have Ansible installed you will have it available. If you share the error message with me I can help you debug what's going on.
@jackcsprat
@jackcsprat 5 жыл бұрын
@@toptechskills I created a file called demoplays.yaml as follows. I then created a host file that has [groupA] and then the hostname. I then issue the command: ansible-playbook -i hosts demoplays.yaml and get an error of: ERROR! 'command' is not a valid attribute for a Play --- - hosts: groupA tasks: - name: find disk space available command: df -h
@toptechskills
@toptechskills 5 жыл бұрын
Hi @jackcsprat, I think the error here is your indentation. YAML is sensitive to whitespace and it looks like your `command` keyword us at the same level of indentation as the `tasks` keyword, which would make YAML interpret it as part of the play, rather than the task. Try the following (just fixed the indentation): --- - hosts: groupA tasks: - name: find disk space available command: df -h See if that works and if so, just make sure you are careful with indentation in YAML.
@jackcsprat
@jackcsprat 5 жыл бұрын
@@toptechskills You were absolutely correct Percy !! Thank you so much !!
@sameerthorappa3356
@sameerthorappa3356 5 жыл бұрын
is it possible to use command module with network devices ? i mean with Cisco/Huawei routers and switches ?
@toptechskills
@toptechskills 5 жыл бұрын
Hi Sameer, thanks for your comment. The `command` module is targeted at Linux and Windows operating systems, so usually won't work on networking hardware, however there are specialized "command" modules for some network hardware transports. The full list of modules for network devices is available here: docs.ansible.com/ansible/latest/modules/list_of_network_modules.html#. If you search for "command" on this page, you'll see the command modules for specific network hardware transports. As I understand it, the specific transport will depend on the exact model of the networking hardware, not just the brand.
@alex_ventura
@alex_ventura 3 жыл бұрын
Wow man, how can you make it look so easy to learn Ansible? You’re really good at sharing knowledge, congrats! And now that you were talking about Ruby on Rails, I was wondering if you have a good way to installs RVM using Ansible? I’ve been trying without any look to accomplish it! Thanks I’m advanced!
@toptechskills
@toptechskills 3 жыл бұрын
Hi Alex, firstly thank you for your comment. Regarding installing RVM using Ansible, there are a few approaches I can suggest: 1. You can use the Ansible Galaxy role for RVM directly (galaxy.ansible.com/rvm/ruby). You can learn more about how to use Galaxy roles here: galaxy.ansible.com/docs/using/installing.html#roles 2. You can take a look at how the Ansible Galaxy role for RVM is implemented in the Github repo (github.com/rvm/rvm1-ansible/blob/master/tasks/main.yml) and replicate something similar yourself. 3. Look at the RVM documentation directly and convert each step of the installation instructions into a Ansible task: rvm.io/rvm/install Hope that helps, thanks!
@alex_ventura
@alex_ventura 3 жыл бұрын
@@toptechskills Yeah, I’ve been trying to install RVM in different ways without any luck. I’ve created a script that gets transferred to the server and then gets executed by Ansible in the server but it doesn’t work. I even have tried to use galaxy role but it seems not to work for me and maybe I’m doing it wrong but what I found is my major problem is the fact that Ansible does not run commands as a login shell and RVM is all about it. I feel kind of frustrated but I’ll keep trying to have it running and if you have any other suggestions or you find it worth, please create a video for doing this. Thanks in advance bro! 👍🏻
@toptechskills
@toptechskills 3 жыл бұрын
The problem you're describing is pretty common with things like package managers that install themselves into your `.bash_profile`/`.bashrc` files or equivalents for other shells. In general you can replicate this in Ansible by adding the RVM PATH to your `$PATH` for the shell environment like this: - name: Run some command with RVM command: gem install ... environment: PATH: "{{ ansible_env.PATH }}:/path/to/rvm/bin" (replace `/path/to/rvm/bin` with the path to where your RVM shims are installed).
@alex_ventura
@alex_ventura 3 жыл бұрын
@@toptechskills Thanks so much Percy, I’m going to try that out!
@SurajKumar-bm6fo
@SurajKumar-bm6fo 4 жыл бұрын
Thanq so much sir
@nL-ve4gi
@nL-ve4gi 4 жыл бұрын
vi thanks_PG The practice is wow ! I got ,what l was expecting? Thanks and keep uploading cat thanks_PG
@datworks3319
@datworks3319 6 жыл бұрын
nice tutorial. can you tell me what editor are you using?
@toptechskills
@toptechskills 6 жыл бұрын
Hi Dat Works, thanks for the comment. I'm using Visual Studio Code with the Ansible plugin by Microsoft. code.visualstudio.com marketplace.visualstudio.com/items?itemName=vscoss.vscode-ansible Thanks for watching!
@kanwarpreetsingh4819
@kanwarpreetsingh4819 5 жыл бұрын
@@toptechskills What is the theme you are using?
@hprangana
@hprangana 3 жыл бұрын
thanks a lot
@toptechskills
@toptechskills 3 жыл бұрын
Thanks for your kind comments Isuru 🙏
@monday6740
@monday6740 5 жыл бұрын
1:22 Well, no - you can't see that file being created by touch, you can see the file is there. That is a massive difference ... A lot of programming bugs come out of assumptions, here you are showing an example that is assuming things.
@toptechskills
@toptechskills 5 жыл бұрын
Thanks for your comment Mon Day, that's a great point, I didn't show that the file didn't exist before running the command, next time I could make that clear before running the playbook.
@japonezchb1
@japonezchb1 2 жыл бұрын
uuuuuuuooooouuuuuuuu !!!!!!!!!!!!!!!!
@ryanperkins1525
@ryanperkins1525 2 жыл бұрын
Thanks brother... your accent is so not Indian.
Ansible Yum Module Tutorial - Complete Beginner's Guide
9:47
Percy Grunwald from TopTechSkills
Рет қаралды 8 М.
Ansible Shell Module Tutorial - Complete Beginner's Guide
7:50
Percy Grunwald from TopTechSkills
Рет қаралды 24 М.
БАБУШКА ШАРИТ #shorts
0:16
Паша Осадчий
Рет қаралды 4,1 МЛН
ВЛОГ ДИАНА В ТУРЦИИ
1:31:22
Lady Diana VLOG
Рет қаралды 1,2 МЛН
Ansible File Module Tutorial - Complete Beginner's Guide
15:20
Percy Grunwald from TopTechSkills
Рет қаралды 28 М.
Tired of Repetitive Tasks? Learn the Magic of Ansible Handlers
13:56
Percy Grunwald from TopTechSkills
Рет қаралды 912
What is Ansible?
11:06
IBM Technology
Рет қаралды 190 М.
What is Ansible | Ansible Playbook explained | Ansible Tutorial for Beginners
16:41
Ansible Fetch Module Tutorial - Complete Beginner's Guide
9:17
Percy Grunwald from TopTechSkills
Рет қаралды 12 М.
Ansible blocks
9:19
Robert de Bock
Рет қаралды 1,8 М.
Make your Ansible playbooks flexible, maintainable, and scalable
47:26
Introduction to Ansible Playbooks (and demonstration)
18:02
Rapidly Build & Test Ansible Roles with Molecule + Docker
20:58
Percy Grunwald from TopTechSkills
Рет қаралды 32 М.