Adhoc Commands :
- Ad hoc commands are commands which can be run individually to perform quick functions
- For example , you have to reboot all your servers.
- For this , you will run the Adhoc commands from '.usr/bin/ansible'..
- Parallelism and Shell Commands
$ ssh-agent bash
$ ssh-add ~/.ssh/id_rsa
$ Ansible abc -a "/sbin/reboot" -f 12
$ Ansible abc -a "/sbin /reboot" -f 12 -u username
- File Transfer :
- Transferring file to many servers/machines :
$ Ansible abc -m copy -a "src = /etc/yum.conf dest = /tmp/yum.conf"
- Creating new directory
$ Ansible abc -m file -a "dest = /path/user1/new mode = 777 owner = user1 group = user1
state = directory"
- Deleting whole directory or file :
$ Ansible abc -m file -a "dest = /path/user1/new state = absent"
- Managing Packages :
- The Ad-hoc commands are available for yum and apt. Following are some Ad - hoc commands using yum.
- The following command checks if yum packages is installed or not, but does not update it.
- The following command check the package is not installed.
- The following command checks the latest version of package is installed.
Gathering Facts :
$ Ansible all -m setup
No comments:
Post a Comment