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!
@swapnan76974 жыл бұрын
I just want to know if the pig is installed or not to validate from ansible
@1BAmir4 жыл бұрын
Thank you so much for all you helpful videos!!! I wish you all the best ! :D
@toptechskills4 жыл бұрын
Thank you, and to you also 🙏
@swapnan76974 жыл бұрын
I have to validate group of packages are installed or not and how to get output of pkgs which are not installed
@toptechskills4 жыл бұрын
I'd use the `command` module to run the necessary commands to validate your packages: www.toptechskills.com/ansible-tutorials-courses/ansible-command-module-tutorial-examples/#how-to-capture-command-module-output
@fanindia75132 жыл бұрын
I need to run script A, for which I need to pass script B as a parameter during the command line execution. Kindly help me how to pass the command in yaml in this situation where I'm using ansible tower for execution of yaml script
@toptechskills2 жыл бұрын
Scripts A and B both need to exist on the target machine. If that's the case, you can simply call it in the same way as you would in the shell: ``` - command: /path/to/script_a.sh /path/to/script_b.sh ```
@1theblacksheep4 жыл бұрын
OK nice, I have a problem, when I try to install a package my playbook freezes waiting for my YES or NO! I think there is something wrong cause some packages are asking for dependencies and the yum module is not doing the work, the playbook can not proceed, what do I need to do? My remote managed machine is looking for packages in my local remote repository.
@toptechskills4 жыл бұрын
Hi 1theblacksheep, the `yum` module runs in a way to ensure that it will never need your input and will fail if it does. The module should also automatically install dependencies and recommended packages, just like if you were to run `yum install -y`. My gut feeling if you are not getting any error messages is that yum is just running really slowly on your target host, either because of limited CPU (e.g. maybe it has hit its CPU credit limit if it's in EC2, or some other process is hogging the CPU), or there are network problems (e.g. your bandwidth may be extremely limited, or the DNS resolver is timing out).
@1theblacksheep4 жыл бұрын
@@toptechskills Thanks for answerin, I understood my problem.. in fact I Built 2 vms but of them... the managed host was looking for some packages at the local repository in the controller machine... the thing is... the managed was trying to install dependencies but my repository wasn't complete, that was the problem.I fixed. Thank you 😊
@MagnumCarta3 жыл бұрын
Is there a way to force the yum module to run yum localinstall? I've been able to circumvent this issue by using rpm -ivh --force inside of the shell module, however this gives annoying warnings. I can tell the playbook was failing earlier because instead of trying to install the local rpms, yum was trying to find the packages through repos where they won't be found.
@toptechskills3 жыл бұрын
According to the examples in the documentation (docs.ansible.com/ansible/latest/modules/yum_module.html#examples), you should be able to install local RPM files by setting an absolute file path for `name`: - name: install nginx rpm from a local file yum: name: /usr/local/src/nginx-release-centos-6-0.el6.ngx.noarch.rpm state: present Does this not work?
@MagnumCarta3 жыл бұрын
@@toptechskills Hi Percy, thank you for replying back to me. I have not tried the absolute path for name but did find that by using "allow_downgrade" set to "yes", I was able to get the yum module to successfully install the rpm files.
@RaleighGuevarra5 жыл бұрын
Hi, I would like to ask how to do it playbook for the yum info (ie yum info sudo). Thank you
@toptechskills5 жыл бұрын
Hi Raleigh, you can always use the `command` module for arbitrary commands and the `register` keyword to store the output (more details here: www.toptechskills.com/ansible-tutorials-courses/ansible-command-module-tutorial-examples/#how-to-capture-command-module-output) What's your use case? What exactly are you trying to do?
@thamkinathkounain39014 жыл бұрын
Sorry, user test is not allowed to execute '/usr/bin/whoami' as root on server Any pointers on how to avoid this error
@toptechskills4 жыл бұрын
Hi Thamkinath Kounain, as I mentioned in the reply to another one of your comments, I think this should help: docs.ansible.com/ansible/latest/user_guide/become.html#id1 Thanks
@trublaster1014 жыл бұрын
Very nice presentation.
@toptechskills4 жыл бұрын
Thank you Arjun 🙏
@rohitmeachu53474 жыл бұрын
I would like to setup a condition : 1. my playbook checks if the pkg is installed or not 2. if its installed it wont bother to execute rest of playbook for pkg installation 3. if its not installed then it will proceed with the playbook execution how can i do that? ## above video was helpful though:)
@toptechskills4 жыл бұрын
Hi rohit meachu, the best way to achieve what you're trying to do is probably to use the `yum` module to install your package and then register the output and use this as a conditional later. Here's an example: ``` - name: install nginx if not installed yum: name: nginx state: present register: install_nginx_result - name: run post-install tasks only if nginx was installed import_tasks: post_install.yml when: install_nginx_result is changed ``` If the `nginx` package is already installed, the first task will have `changed == false` and the second task won't include the tasks. Hope this helps. Thanks for your comment.
@mrmiked65775 жыл бұрын
Excellent video, thanks! I learned how to do my first Ansible install, upgrade, and remove of packages. Just one thing for other readers......... Using AWS AMI Linux instances and the 'Removal' process: Your technique of swapping 'update_cache' for 'autoremove' didn't work for me. I just deleted the 'update_cache' altogether and it worked perfectly.
@toptechskills5 жыл бұрын
Hi Far Too Much, thanks for the comment, I hope it's useful for other viewers if they have the same problem with AWS Linux. What was the error message you got when using `autoremove` with AWS Linux?
@mrmiked65775 жыл бұрын
@@toptechskills Ok, I just went back and re-created the playbook that didn't work for me. My playbook (using 3 AWS Linux AMI's and utilizing nano as a test app): --- - name: run tasks on all hosts hosts: "*" tasks: - name: uninstall nano yum: name: nano state: absent autoremove: true become: true And here is the relevant error: TASK [uninstall nano] ************************************************************************************************************************************************ fatal: [10.0.1.174]: FAILED! => {"changed": false, "failed": true, "msg": "Unsupported parameters for (yum) module: autoremove Supported parameters include: allow_downgrade,conf_file,disable_gpg_check,disablerepo,enablerepo,exclude,install_repoquery,installroot,list,name,security,skip_broken,state,update_cache,validate_certs"} As I said, it works flawlessly when I skip 'autoremove'.........
@toptechskills5 жыл бұрын
@@mrmiked6577 looks like the problem is either your Ansible version on your control machine. The `autoremove` parameter is available for the yum module in Ansible 2.7+ only. It may also be the case that Amazon Linux has an older version of yum. The `autoremove` feature is available in yum >= 3.4.3. I got this info from the manual page for the yum module here: docs.ansible.com/ansible/latest/modules/yum_module.html#yum-module. Hope this helps.
@mrmiked65775 жыл бұрын
@@toptechskills Good catch, I hadn't thought of the versions. I'll give it a shot when I get a chance.....
@kafuiathiogbey76286 жыл бұрын
Thank you so much for the video. Question. Is there a way to install multiple development tools at the same time without having a dozen module lines? I ask because I need to install clamav and it requires a few tools before install (openssl openssl-devel libcurl-devel zlib-devel libpng-devel libxml2-devel json-c-devel bzip2-devel pcre2-devel ncurses-devel)
@kafuiathiogbey76286 жыл бұрын
Please ignore my comment. If I had watched the whole video before commenting, I would've realized that you showed how to install multiple tools. I got too excited when the first 1min 30secs fixed my issue.
@toptechskills6 жыл бұрын
Thanks for watching, glad you found what you were looking for. You can also install package groups like "Development Tools" in CentOS/RHEL with the yum module. This package group includes a bunch of compilers and tools by default. Check out bit.ly/2N94MJA if you want more info about package groups in yum and how to install them with the yum module.