![]() How to append Numbers to an ansible List. ![]() $ Ansible abc -m yum -a "name = demo-tomcat-1 state = latest"įacts can be used for implementing conditional statements in playbook. For creating a new ansible list you can either use vars or setfact as we have discussed earlier. ![]() The following command checks the latest version of package is installed. $ Ansible abc -m yum -a "name = demo-tomcat-1 state = absent" The following command check the package is not installed. $ Ansible abc -m yum -a "name = demo-tomcat-1 state = present" The following command checks if yum package is installed or not, but does not update it. Following are some Ad-hoc commands using yum. For community users, you are reading an unmaintained version of the Ansible documentation. The Ad-hoc commands are available for yum and apt. yum Manages packages with the yum package manager. $ Ansible abc -m file -a "dest = /path/user1/new state = absent" Ad hoc commands are used in Ansible to perform tasks or operations that are needed on an immediate basis, or only once, based upon the requirement. $ Ansible abc -m file -a "dest = /path/user1/new mode = 777 owner = user1 group = user1 state = directory" $ Ansible abc -m copy -a "src = /etc/yum.conf dest = /tmp/yum.conf" Transferring file to many servers/machines You can use the Ad-hoc commands for doing SCP (Secure Copy Protocol) lots of files in parallel on multiple machines. $ Ansible abc -a "/sbin/reboot" -f 12 -u username If you want to change this behavior, you will have to pass the username in Ad-hoc commands as follows − To run reboot for all your company servers in a group, 'abc', in 12 parallel forks −īy default, Ansible will run the above Ad-hoc commands form current user account. For this, we need to set up SSHagent for connection. Reboot your company server in 12 parallel forks at time. Ansible yum module to install a list of packages AND remove any other packages. These ad-hoc commands are not used for configuration management and deployment, because these commands are of one time usage.Īnsible-playbook is used for configuration management and deployment. For this, you will run the Adhoc commands from ‘ /usr/bin/ansible’. These commands need not be performed later.įor example, you have to reboot all your company servers. Ad hoc commands are commands which can be run individually to perform quick functions.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |