Friday, January 20, 2017

Handy Linux Commands


  1. Syntax: ansible  <pattern> -u <username> -i <inventory_file>  -m <module_name> -a <arguments>
    • <pattern> : represents the group name of the list of hosts defined
    • <username>: user name to override any values defined in config file
    • <inventory_file>: path to the static ansible inventory file
    • <module_name>: ansible modules to use
    • <arguments>: arguments module to specify
  2. ansible prod-webserver -u autouser -i inventory/dc_chicago -m command -a "date" /*Execute an ansible ad-hoc command  as an user*/
  3. ansible-galaxy init <ansible_role_name> /*Will create a default ansible project directory structure*/
  4. vim -c "<command>"  <file to execute the script on>  
    eg:- vim -c "%s/\s\+$//e"  -c "wq"  file1.txt /*Deletes space at the end of each line without prompting  error*/