Lab 3 - Solution

Mandatory

Try out ansible-doc

  • print out all available modules
  • check the docu of the module command
  • check the docu of the modules yum and apt
ansible-doc -l
ansible-doc command
ansible-doc yum
ansible-doc apt

Ping all hosts

  • Run the ansible module “ping” on all hosts in your inventory
  • Run the ansible module “ping” only on web1.<firstname>.lab
ansible -m ping all

ansible -m ping web1.firstname.lab

Run the command modul

  • Run uname -a on all servers via command module
  • Run whoami on all servers via command module
  • Run cat /etc/redhat-release only on web2.<firstname>.lab
  • Run cat /etc/redhat-release only on web1.<firstname>.lab
ansible -a "uname -a" all

# should be root
ansible -a "whoami" all

ansible -a "cat /etc/redhat-release" web2.pascal.lab

# will fail! it's a Debian OS
ansible -a "cat /etc/redhat-release" web1.pascal.lab