06 August 2015

ad-hoc demo

  1. hosts inventory file

         $ pico hosts
         [local]
         127.0.0.1
    
  2. ping demo

         $ ansible local -i hosts -m ping
    
  3. ansible.cfg file

         $ pico ansible.cfg
         [defaults]
         hostfile=hosts
         remote_user=hqlgree2
    
  4. do not need -i

         $ ansible local -m ping
    
         $ ansible local -m command -a uptime
    
         # command is the default module
         $ ansible local -a uptime
    
  5. command contain space double quote it

         $ ansible local -a "tail /var/log/dmesg"
    
  6. sudo as root use -s flag

         $ ansible local -s -a "tail /var/log/syslog"
    
  7. install nginx on ubuntu

         $ ansible ubuntubox -s -m apt -a name=nginx
    
         # if fails
         $ ansible ubuntubox -s -m apt -a "name=nginx update_cache=yes"
    


blog comments powered by Disqus