Friday, July 28, 2017

Difference between Shell & Command module : Ansible

  • The command module takes the command name followed by a list of space-delimited arguments.
  • The given command will be executed on all selected nodes. It will not be processed through the shell, so variables like $HOME and operations like “<”“>”“|””;” and “&” will not work (use the shell module if you need these features).
Command args (common for shell & command)

chdir - Change into this directory before running the command.
creates - A filename or (since 2.0) glob pattern, when it already exists, this step will not be run.
removes - A filename or (since 2.0) glob pattern, when it does not exist, this step will not be run.

args: only for shell module
executable - change the shell used to execute the command. Should be an absolute path to the executable.

Tuesday, July 18, 2017

Adding pre-tasks and post-tasks to playbooks

- hosts: www
  remote_user: vagrant
  sudo: yes
     - shell: echo 'I":" Beginning to configure web server..'
     - nginx
     - shell: echo 'I":" Done configuring nginx web server...'