Trending Technology Machine Learning, Artificial Intelligent, Block Chain, IoT, DevOps, Data Science

Recent Post

Codecademy Code Foundations

Search This Blog

Ansible - Adhoc commands in DevOps

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.
            $ Ansible abc -m yum -a "name - demo-tomcat-1 state = present"
  • The following command check the package is not installed.
            $ Ansible abc -m yum -a "nam4 = demo-tomcat-1 state = absent"
  • The following command checks the latest version of package is installed.
           $ Ansible abc -m yum -a "name = demo-tomcat-1 state = latest"
Gathering Facts :
           $ Ansible all -m setup 

No comments:

Post a Comment

Popular Posts